2011-07-01

Timing a shell script

Time some shell script code without the "time" command:

before=`date +%s`

# code goes here

after=`date +%s`
elapsed_seconds="$(expr $after - $before)"
echo Elapsed time: $(date -d $elapsed_seconds +%H:%M:%S)

No comments:

Post a Comment