Basic Profiling with the Time Command
The time
command runs a specified program and prints out timing statistics. It is useful when you want to analyse how different configuration options affect how long a program takes to complete.
Prerequisite knowledge
Before using the time
command for high-level program timing, you will need to be familiar with running your program using the scheduler on the supercomputer.
Steps
To start using the time
command to find out how long your program takes to run:
Insert the
time
command in front of thesrun
command in your jobscript. For example, if the srun line of your jobscript was:srun ./exampleProgram
The updated jobscript would be:
time srun ./exampleProgram
- Submit your jobscript as usual using
sbatch
.
Result
The timing results from running the program will be appended to your job output:
<Usual output from existing program> real 0m1.683s user 0m0.031s sys 0m0.246s
The time
command has appended timings after the program output:
- real time is the total time the job took to run
- user time is the time the program spent executing parts of the code written by the programmer
- system time is the time the program spent executing underlying system calls in the operating system for the program
The user and system time may not add up to the real time, as there may be other programs running. For example, processes that are part of the operating system may be running in the background.