github.com/charlievieth/fastwalk@v1.0.3/scripts/bench_comp.bash (about) 1 #!/usr/bin/env bash 2 3 set -euo pipefail 4 5 COUNT=5 6 TESTS=( 7 'filepath' 8 'godirwalk' 9 'fastwalk' 10 ) 11 12 ROOT="$(go env GOROOT)" 13 if [[ ! -d "${ROOT}" ]]; then 14 echo >&2 "error: GOROOT (\"${ROOT}\") does not exist and is required to run benchmarks" 15 exit 1 16 fi 17 18 TEST_FLAGS=( 19 -run '^$' # skip all tests 20 -bench '^BenchmarkWalkComparison$' 21 -benchmem 22 -count "${COUNT}" 23 ) 24 TMP="$(mktemp -d -t fastwalk-bench.XXXXXX)" 25 26 for name in "${TESTS[@]}"; do 27 echo "## ${name}" 28 go test "${TEST_FLAGS[@]}" github.com/charlievieth/fastwalk -walkfunc "${name}" | 29 tee "${TMP}/${name}.out" 30 echo '' 31 done 32 33 echo '## Comparisons' 34 echo '########################################################' 35 echo '' 36 37 echo '## filepath vs. fastwalk' 38 benchstat "${TMP}/filepath.out" "${TMP}/fastwalk.out" 39 echo '' 40 41 echo '## godirwalk vs. fastwalk' 42 benchstat "${TMP}/godirwalk.out" "${TMP}/fastwalk.out" 43 echo '' 44 45 echo "## Temp: ${TMP}"