compare-commits.sh 942 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. if [ $# -lt 2 ]; then
  3. echo "usage: ./scripts/compare-commits.sh <commit1> <commit2> [additional llama-bench arguments]"
  4. exit 1
  5. fi
  6. set -e
  7. set -x
  8. # verify at the start that the compare script has all the necessary dependencies installed
  9. ./scripts/compare-llama-bench.py --check
  10. bench_args="${@:3}"
  11. rm -f llama-bench.sqlite > /dev/null
  12. # to test a backend, call the script with the corresponding environment variable (e.g. GGML_CUDA=1 ./scripts/compare-commits.sh ...)
  13. if [ -n "$GGML_CUDA" ]; then
  14. CMAKE_OPTS="${CMAKE_OPTS} -DGGML_CUDA=ON"
  15. fi
  16. dir="build-bench"
  17. function run {
  18. rm -fr ${dir} > /dev/null
  19. cmake -B ${dir} -S . ${CMAKE_OPTS} > /dev/null
  20. cmake --build ${dir} -t llama-bench > /dev/null
  21. ${dir}/bin/llama-bench -o sql -oe md $bench_args | sqlite3 llama-bench.sqlite
  22. }
  23. git checkout $1 > /dev/null
  24. run
  25. git checkout $2 > /dev/null
  26. run
  27. ./scripts/compare-llama-bench.py -b $1 -c $2