chore: add bench script to benchmark two commits
This will quickly benchmark your current commit against a commit you pass in. This will output the percentage difference so you can quickly get an idea in the performance changes in your current work
This commit is contained in:
parent
421c9b5999
commit
d707a6e15b
1 changed files with 24 additions and 0 deletions
24
scripts/bench
Executable file
24
scripts/bench
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
target_rev="$(git rev-parse $1)"
|
||||
current_rev="$(git rev-parse HEAD)"
|
||||
|
||||
current_branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
trap "git checkout "$current_branch"" EXIT
|
||||
|
||||
hyperfine \
|
||||
--style full \
|
||||
--warmup 3 \
|
||||
--export-json /tmp/bench.json \
|
||||
--parameter-list rev "${target_rev},${current_rev}" \
|
||||
--prepare "git checkout {rev} && cargo build --release" -n '{rev}' 'luajit ./scripts/benchmark.lua'
|
||||
|
||||
old_value=$(cat /tmp/bench.json | jq '.results[0].mean')
|
||||
new_value=$(cat /tmp/bench.json | jq '.results[1].mean')
|
||||
percentage_difference=$(echo "scale=2; (($new_value - $old_value) / $old_value) * 100" | bc)
|
||||
|
||||
echo ""
|
||||
echo "-------------------------------------"
|
||||
echo "The percentage difference is $percentage_difference%"
|
||||
echo "-------------------------------------"
|
||||
echo ""
|
||||
Loading…
Reference in a new issue