|
3 | 3 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
4 | 4 | BASE_DIR=$(dirname $SCRIPT_DIR)
|
5 | 5 | branch=$(git rev-parse --abbrev-ref HEAD)
|
| 6 | +#br_commit=$(git rev-parse $branch) |
| 7 | +#main_commit=$(git rev-parse main) |
6 | 8 | echo "Comparing main branch with $branch"
|
7 | 9 |
|
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 | +} |
12 | 34 |
|
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 |
17 | 39 | 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) |
18 | 45 |
|
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 .. |
37 | 46 | if [ -z "$1" ]; then
|
38 | 47 | echo "Comparing all benchmarks .."
|
39 |
| - $compare benchmarks ./builddir-main/benchexe ./builddir-${branch}/benchexe |
| 48 | + $compare benchmarks $baseline $contender |
40 | 49 | else
|
41 | 50 | echo "Comparing benchmark $1 .."
|
42 |
| - $compare benchmarksfiltered ./builddir-main/benchexe $1 ./builddir-${branch}/benchexe $1 |
| 51 | + $compare benchmarksfiltered $baseline $1 $contender $1 |
43 | 52 | fi
|
0 commit comments