blob: bc583024240b3e8bdb020dc4ce4658d0df5235ed [file] [log] [blame]
Nigel Tao51fadc42019-09-29 17:20:14 +10001#!/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
22num_commits=${NUM_COMMITS:-100}
23cc=${CC:-gcc}
24package=${PACKAGE:-gif}
25focus=${FOCUS:-wuffs_gif_decode_1000k_full_init}
26iterscale=${ITERSCALE:-50}
27reps=${REPS:-20}
28
29# ----
30
31save=`git log -1 --pretty=format:"%H"`
32
33i=0
34while [ $i -lt $num_commits ]; do
Nigel Tao1d8fb412021-11-22 13:12:57 +110035 set +e
Nigel Tao51fadc42019-09-29 17:20:14 +100036 $cc -O3 -o bench-history.out test/c/std/$package.c
Nigel Tao1d8fb412021-11-22 13:12:57 +110037 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 Tao51fadc42019-09-29 17:20:14 +100048 echo $this_hash $this_metric
49 git checkout --quiet HEAD^
50 i=$((i + 1))
51done
52
53rm -f ./bench-history.out
54git checkout --quiet $save