sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

benchmark.sh (667B)


      1 #!/bin/sh
      2 #
      3 # Usage: ./misc/test/benchmark.sh ./nnn /tmp/testdir1 ./testdir2 ...
      4 #
      5 # Don't forget to build nnn in benchmark mode: make O_BENCH=1
      6 
      7 # Use a test dir filled with genfiles.sh to get interesting output
      8 # (or maybe /usr/lib/)
      9 
     10 LANG=C
     11 
     12 TIME_VAL=${TIME_VAL:-"real"}
     13 
     14 SAMPLES=${SAMPLES:-100}
     15 
     16 EXE=$1
     17 
     18 bench_val () {
     19     (time "$1" "$2") 2>&1 |\
     20     awk '$1=="'"$TIME_VAL"'"{match($2, /[0-9]*\.[0-9]*/) ; print substr($2, RSTART, RLENGTH)}'
     21 }
     22 
     23 bench_dir () {
     24     i=$SAMPLES
     25     printf "$2"
     26     while [ $((i--)) -gt 0 ] ; do
     27         printf "\t%s" "$(bench_val "$1" "$2")"
     28     done
     29     printf "\n"
     30 }
     31 
     32 shift
     33 
     34 for dir in "$@" ; do
     35     bench_dir "$EXE" "$dir"
     36 done
     37