c++linuxbashcpu-timewall-time

CPUTIME and WALLTIME C++ code on Linux based cluster


I have a C++ code that i'm running a linux based cluster. I want to measure the CPU time and wall time. Here is how the bash file for submitting the job looks like:

#!/bin/bash
#$ -V
#$ -cwd
#$ -j y 
#$ -orte_onenode 2 
#$ -o out
#$ -N program
~/home/directory/executable

Thanks for the help in advance.


Solution

  • You can replace ~/home/directory/executable with time ~/home/directory/executable in your script. This runs the "time" program, which as you noted in a comment prints something like:

    145.58u 9.072s 2:36.27 98.9 0+0k 392+340672io 1pf+0w
    

    The first number there is the user-mode time (in seconds). The second is system (kernel) mode time. Third is the total elapsed wall time (minutes:seconds). 98.9 is the CPU utilization during the run. You can read more about these values and the time program here: http://linux.die.net/man/1/time