Nigel Tao | 51fadc4 | 2019-09-29 17:20:14 +1000 | [diff] [blame] | 1 | #!/bin/bash -eu |
| 2 | # Copyright 2019 The Wuffs Authors. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # ---------------- |
| 17 | |
| 18 | # This script measures Wuffs benchmarks over recent commits. For example: |
| 19 | # |
| 20 | # PACKAGE=deflate FOCUS=wuffs_deflate_decode_100k script/bench-history.sh |
| 21 | |
| 22 | num_commits=${NUM_COMMITS:-100} |
| 23 | cc=${CC:-gcc} |
| 24 | package=${PACKAGE:-gif} |
| 25 | focus=${FOCUS:-wuffs_gif_decode_1000k_full_init} |
| 26 | iterscale=${ITERSCALE:-50} |
| 27 | reps=${REPS:-20} |
| 28 | |
| 29 | # ---- |
| 30 | |
| 31 | save=`git log -1 --pretty=format:"%H"` |
| 32 | |
| 33 | i=0 |
| 34 | while [ $i -lt $num_commits ]; do |
Nigel Tao | 1d8fb41 | 2021-11-22 13:12:57 +1100 | [diff] [blame] | 35 | set +e |
Nigel Tao | 51fadc4 | 2019-09-29 17:20:14 +1000 | [diff] [blame] | 36 | $cc -O3 -o bench-history.out test/c/std/$package.c |
Nigel Tao | 1d8fb41 | 2021-11-22 13:12:57 +1100 | [diff] [blame] | 37 | if [ $? -ne 0 ]; then |
| 38 | this_metric='compile_failed' |
| 39 | else |
| 40 | this_metric=`./bench-history.out -bench -focus=$focus -iterscale=$iterscale -reps=$reps | benchstat /dev/stdin | sed -ne '/^name.*speed$/,$ p' | grep $focus` |
| 41 | if [ $? -ne 0 ]; then |
| 42 | this_metric='bench_failed' |
| 43 | fi |
| 44 | fi |
| 45 | set -e |
| 46 | |
| 47 | this_hash=`git log -1 --pretty=format:"%h"` |
Nigel Tao | 51fadc4 | 2019-09-29 17:20:14 +1000 | [diff] [blame] | 48 | echo $this_hash $this_metric |
| 49 | git checkout --quiet HEAD^ |
| 50 | i=$((i + 1)) |
| 51 | done |
| 52 | |
| 53 | rm -f ./bench-history.out |
| 54 | git checkout --quiet $save |