EN
Bash - measure command execution time in milliseconds
9 points
In this short article, we would like to show how in Bash, measure command execution duration in milliseconds.
Quick solution:
xxxxxxxxxx
1
t1=$(date +%s%3N); some_command_here; t2=$(date +%s%3N); echo "$((t2-t1)) ms"
In the below example the command line sleeps 3 seconds (returns sleeping + execution time).
xxxxxxxxxx
1
t1=$(date +%s%3N); sleep 3; t2=$(date +%s%3N); echo "$((t2-t1)) ms"
Example output:
xxxxxxxxxx
1
3028 ms