Skip to content

Commit 8e8d21d

Browse files
committed
Add run-bench.py to run bench-compare and branch-compare
1 parent 85fbe7d commit 8e8d21d

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

.github/workflows/c-cpp.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ jobs:
9494
env:
9595
CXX: g++-12
9696
GBENCH: ${{ github.workspace }}/benchmark
97-
run: bash -x bench-compare.sh
97+
run: bash -x scripts/bench-compare.sh avx

bench-compare.sh renamed to scripts/branch-compare.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#~/bin/bash
22
set -e
33
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4-
cd $SCRIPT_DIR
4+
cd $SCRIPT_DIR/..
55
branch=$(git rev-parse --abbrev-ref HEAD)
66
echo "Comparing main branch with $branch"
77

@@ -34,5 +34,10 @@ meson setup --warnlevel 0 --buildtype plain builddir-main
3434
cd builddir-main
3535
ninja
3636
cd ..
37-
echo "Running benchmarks .."
38-
$compare benchmarks ./builddir-main/benchexe ./builddir-${branch}/benchexe
37+
if [ -z "$1" ]; then
38+
echo "Comparing all benchmarks .."
39+
$compare benchmarks ./builddir-main/benchexe ./builddir-${branch}/benchexe
40+
else
41+
echo "Comparing benchmark $1 .."
42+
$compare benchmarksfiltered ./builddir-main/benchexe $1 ./builddir-${branch}/benchexe $1
43+
fi

scripts/run-bench.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
import argparse
3+
import subprocess
4+
5+
parser = argparse.ArgumentParser()
6+
parser.add_argument('--branchcompare', help='Compare benchmarks of current branch with main. Provide an optional --filter')
7+
parser.add_argument('--benchcompare', action='store_true', help='Compare across benchmarks. Requires --baseline and --contender')
8+
parser.add_argument("-f", '--filter', type=str, required=False)
9+
parser.add_argument("-b", '--baseline', type=str, required=False)
10+
parser.add_argument("-c", '--contender', type=str, required=False)
11+
args = parser.parse_args()
12+
13+
if len(sys.argv) == 1:
14+
parser.error("requires one of --benchcompare or --branchcompare")
15+
16+
if args.benchcompare:
17+
if (args.baseline is None or args.contender is None):
18+
parser.error("--benchcompare requires --baseline and --contender")
19+
else:
20+
rc = subprocess.check_call("./bench-compare.sh '%s %s'" % (args.baseline, args.contender), shell=True)
21+
22+
if args.branchcompare:
23+
if args.filter is None:
24+
rc = subprocess.call("./branch-compare.sh")
25+
else:
26+
rc = subprocess.check_call("./branch-compare.sh '%s'" % args.filter, shell=True)

0 commit comments

Comments
 (0)