Search This Blog

Pages

Monday, October 10, 2011

How to print time taken in milli seconds by a command on UNIX

Just replace "" in one line script below with your command and it will output the time taken by the command in milli seconds

You can also manipulate the dividing factor (1000000 in command below) to get output with varying degrees of precision

START=$(date +%s%N); ; END=$(date +%s%N); DIFF=$(( $END - $START )); echo "It took $(( $DIFF / 1000000)) milli seconds"

No comments:

Post a Comment