Measure exection time (Bash)
Naar navigatie springen
Naar zoeken springen
- Use
time
in front of the command or call - Record time at beginning and end, and calculate the difference
Using 'time'
Example:
$ time ./my-big-script.sh real 3m16,622s ← this is the actual number that I need user 2m21,774s sys 0m8,253s
Record & calculate
[1]:
start=`date +%s` ... end=`date +%s` echo Execution time was `expr $end - $start` seconds.
Measure as part of the script
Let's take it one step further: It's too much work to invoke time
before each script + doing some calculations afterwards: How to measure performance from within a given script?