Skip to content

Commit 4cbd181

Browse files
author
Raghuveer Devulapalli
authored
Merge pull request #66 from r-devulap/bench
Improvement to benchmarking scripts
2 parents 0890de5 + b9dc54e commit 4cbd181

File tree

3 files changed

+43
-36
lines changed

3 files changed

+43
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# bench-compare
22
.bench-compare
3+
.bench
34
# Prerequisites
45
*.d
56

scripts/bench-compare.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ set -e
33
branch=$(git rev-parse --abbrev-ref HEAD)
44
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
55
cd $SCRIPT_DIR/..
6-
if [[ -z "${GBENCH}" ]]; then
7-
echo "Please set env variable GBENCH and re run"
8-
exit 1
9-
fi
106

11-
compare=$GBENCH/tools/compare.py
12-
if [ ! -f $compare ]; then
13-
echo "Unable to locate $GBENCH/tools/compare.py"
14-
exit 1
7+
## Get google-benchmark
8+
mkdir -p .bench
9+
if [ ! -d .bench/google-benchmark ]; then
10+
git clone https://github.com/google/benchmark .bench/google-benchmark
1511
fi
12+
compare=$(realpath .bench/google-benchmark/tools/compare.py)
1613

1714
meson setup --warnlevel 0 --buildtype plain builddir-${branch}
1815
cd builddir-${branch}

scripts/branch-compare.sh

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,50 @@ set -e
33
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
44
BASE_DIR=$(dirname $SCRIPT_DIR)
55
branch=$(git rev-parse --abbrev-ref HEAD)
6+
#br_commit=$(git rev-parse $branch)
7+
#main_commit=$(git rev-parse main)
68
echo "Comparing main branch with $branch"
79

8-
if [[ -z "${GBENCH}" ]]; then
9-
echo "Please set env variable GBENCH and re run"
10-
exit 1
11-
fi
10+
build_branch() {
11+
dir_name=$1
12+
if [ ! -d $dir_name ]; then
13+
git clone -b $branch ${BASE_DIR} $dir_name
14+
else
15+
# if it exists, just update it
16+
cd $dir_name
17+
git fetch origin
18+
git rebase origin/$branch
19+
# rebase fails with conflict, delete and start over
20+
if [ "$?" != 0 ]; then
21+
cd ..
22+
rm -rf $branch
23+
git clone -b $branch ${BASE_DIR} $dir_name
24+
else
25+
cd ..
26+
fi
27+
fi
28+
cd $dir_name
29+
meson setup --warnlevel 0 --buildtype plain builddir
30+
cd builddir
31+
ninja
32+
cd ../../
33+
}
1234

13-
compare=$GBENCH/tools/compare.py
14-
if [ ! -f $compare ]; then
15-
echo "Unable to locate $GBENCH/tools/compare.py"
16-
exit 1
35+
mkdir -p .bench
36+
cd .bench
37+
if [ ! -d google-benchmark ]; then
38+
git clone https://github.com/google/benchmark google-benchmark
1739
fi
40+
compare=$(realpath google-benchmark/tools/compare.py)
41+
build_branch $branch
42+
build_branch "main"
43+
baseline=$(realpath ${branch}/builddir/benchexe)
44+
contender=$(realpath main/builddir/benchexe)
1845

19-
rm -rf .bench-compare
20-
mkdir .bench-compare
21-
cd .bench-compare
22-
echo "Fetching and build $branch .."
23-
git clone ${BASE_DIR} -b $branch .
24-
git fetch origin
25-
meson setup --warnlevel 0 --buildtype plain builddir-${branch}
26-
cd builddir-${branch}
27-
ninja
28-
echo "Fetching and build main .."
29-
cd ..
30-
git remote add upstream https://github.com/intel/x86-simd-sort.git
31-
git fetch upstream
32-
git checkout upstream/main
33-
meson setup --warnlevel 0 --buildtype plain builddir-main
34-
cd builddir-main
35-
ninja
36-
cd ..
3746
if [ -z "$1" ]; then
3847
echo "Comparing all benchmarks .."
39-
$compare benchmarks ./builddir-main/benchexe ./builddir-${branch}/benchexe
48+
$compare benchmarks $baseline $contender
4049
else
4150
echo "Comparing benchmark $1 .."
42-
$compare benchmarksfiltered ./builddir-main/benchexe $1 ./builddir-${branch}/benchexe $1
51+
$compare benchmarksfiltered $baseline $1 $contender $1
4352
fi

0 commit comments

Comments
 (0)