nnn/misc/test/benchmark.sh
lvgx bcbe8080be
Add support for Alexey Tourbin's QSORT code (#708)
* Add support for Alexey Tourbin's QSORT code

See https://github.com/svpv/qsort

* Add benchmark scripts and compilation mode

Compile with `make O_BENCHMARK=1`, and run benchmarks with e.g.:
  ./misc/test/benchmark.sh ./nnn '/' '/usr/bin' '/usr/lib' > benchdata
You can then plot basic violin graphs with:
  ./misc/test/plot-bench.py benchdata

* Update style, doc, haiku support, fix lint
2020-08-21 08:15:45 +05:30

38 lines
667 B
Bash
Executable file

#!/bin/sh
#
# Usage: ./misc/test/benchmark.sh ./nnn /tmp/testdir1 ./testdir2 ...
#
# Don't forget to build nnn in benchmark mode: make O_BENCH=1
# Use a test dir filled with genfiles.sh to get interesting output
# (or maybe /usr/lib/)
LANG=C
TIME_VAL=${TIME_VAL:-"real"}
SAMPLES=${SAMPLES:-100}
EXE=$1
bench_val () {
(time "$1" "$2") 2>&1 |\
awk '$1=="'"$TIME_VAL"'"{match($2, /[0-9]*\.[0-9]*/) ; print substr($2, RSTART, RLENGTH)}'
}
bench_dir () {
i=$SAMPLES
printf "$2"
while [ $((i--)) -gt 0 ] ; do
printf "\t%s" "$(bench_val "$1" "$2")"
done
printf "\n"
}
shift
for dir in "$@" ; do
bench_dir "$EXE" "$dir"
done