How to average time commands

benchmarkperformancetimetime-utility

I am timeing some of my commands. Now to average the measures, I'd like to run and time my commands a specified number of times, and get the results with a calculated mean and standard deviation. The result would be like:

avgtime -n 100 my_command

real    0m5.388s stdev 0m0.068s
user    0m5.380s stdev 0m0.067s
sys     0m0.004s stdev 0m0.000s

Is there a UNIX tool for this?
Does GNU/Linux have one?

Best Answer

You can to try use the timeit module, available in any system with Python:

$ python -m timeit "__import__('os').system('my command here')"
10 loops, best of 3: 591 msec per loop
Related Question