Average lead time

Is there any good GNU way to measure the average (worst case, best case) runtime of any command line program? I have an image filter, an unspecified number of images, filtering them using for-loop in bash. While I use time, but I can not find a way to get statistics.

+5
source share
5 answers

There's an interesting Perl program called dumbbench , which is essentially a wrapper around the team time. It launches your program several times, discards emissions, then calculates some statistics.

The author has several articles ( here and here ) that state: a) why benchmarking sucks, and b) what beautiful graphics you can do so that your benchmarking numbers suck a little less.

+4
source

You can send time output to some file, and then "work" with this file

echo "some info" >> timefile.txt
time ( ./yourprog parm1 parm2 ) 2>> timefile.txt
+6
source

time. , .

python , time. , 10 - 1000 , , .

- GNU-, .

+2
#!/bin/bash
for i in {1..100}
do
  env time --append -o time_output.txt   ./test_program --arguments-to-test-program
done
exit

, {1..100} , seq.

env time , , , , . , , , , , . -p (--portability) POSIX (, BASH ), -f . man 1 time .

, , perl python script .

+2
source

You should think about whether you need time for the outer loop and divide by repetition, not each iteration separately. If you are worried about dropping the high and low, just do a few more iterations to drown them out.

time for i in {1..1000}
do
    something
done

You can capture the output from time in a variable :

foo=$( { time {
    echo "stdout test message demo"
    for i in {1..30}
    do
        something
    done
    echo "stderr test message demo" >&2
} 1>&3 2>&4; } 2>&1 )

and do some fake math:

foo=${foo/.}          # "divide" by ...
echo "0.00${foo/#0}"  # ... 1000

Or just usebc :

echo "scale=8; $foo/1000" | bc
0
source

All Articles