Skip to content

Instantly share code, notes, and snippets.

@bubba-h57
Created April 25, 2017 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bubba-h57/e6f9822486ae6c8de394ac1dada814b7 to your computer and use it in GitHub Desktop.
Save bubba-h57/e6f9822486ae6c8de394ac1dada814b7 to your computer and use it in GitHub Desktop.
Run a command 100 times and get the average.
#!/bin/bash
rm -f /tmp/mtime.$$
for x in {1..100}
do
/usr/bin/time -f "real %e user %U sys %S" -a -o /tmp/mtime.$$ $@
tail -1 /tmp/mtime.$$
done
awk '{ et += $2; ut += $4; st += $6; count++ } END { printf "Average:\nreal %.3f user %.3f sys %.3f\n", et/count, ut/count, st/count }' /tmp/mtime.$$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment