#!/bin/rc # average multiple 'time' runs. do something like this: # {for (i in `{seq 1 10}) {time cmd1 ; time cmd2 }>/dev/null} |[2] timeavg # and you'll get a report like: # cmd1 (10 runs): 0.00 0.00 0.07 # cmd2 (10 runs): 0.00 0.00 0.04 # BUG: differentiates based on command, without args, so you can't # time the difference between 'foo -a' and 'foo -b' (they're both foo). sed -n 's/([0-9]+\.[0-9]+)[usr]/\1/gp' | awk ' { usert[$4] += $1 systemt[$4] += $2 realt[$4] += $3 runs[$4] +=1 } END{ for (i in runs) { r = runs[i] printf("%s (%d runs): ", i, r) printf("%.2f %.2f %.2f\n", usert[i]/r, systemt[i]/r, realt[i]/r) } } '