Merge branch 'js/rebase-i-root-fix'
[alt-git.git] / t / perf / bisect_run_script
blob3ebaf1552148da2c81635a8d7380a8417885c1d9
1 #!/bin/sh
3 script="$1"
4 test_number="$2"
5 info_dir="$3"
7 # This aborts the bisection immediately
8 die () {
9 echo >&2 "error: $*"
10 exit 255
13 bisect_head=$(git rev-parse --verify BISECT_HEAD) || die "Failed to find BISECT_HEAD ref"
15 script_number=$(echo "$script" | sed -e "s/^p\([0-9]*\).*\$/\1/") || die "Failed to get script number for '$script'"
17 oldtime=$(cat "$info_dir/oldtime") || die "Failed to access '$info_dir/oldtime'"
18 newtime=$(cat "$info_dir/newtime") || die "Failed to access '$info_dir/newtime'"
20 cd t/perf || die "Failed to cd into 't/perf'"
22 result_file="$info_dir/perf_${script_number}_${bisect_head}_results.txt"
24 GIT_PERF_DIRS_OR_REVS="$bisect_head"
25 export GIT_PERF_DIRS_OR_REVS
27 # Don't use codespeed
28 GIT_PERF_CODESPEED_OUTPUT=
29 GIT_PERF_SEND_TO_CODESPEED=
30 export GIT_PERF_CODESPEED_OUTPUT
31 export GIT_PERF_SEND_TO_CODESPEED
33 ./run "$script" >"$result_file" 2>&1 || die "Failed to run perf test '$script'"
35 rtime=$(sed -n "s/^$script_number\.$test_number:.*\([0-9]\+\.[0-9]\+\)(.*).*\$/\1/p" "$result_file")
37 echo "newtime: $newtime"
38 echo "rtime: $rtime"
39 echo "oldtime: $oldtime"
41 # Compare ($newtime - $rtime) with ($rtime - $oldtime)
42 # Times are decimal number, not integers
44 if test $(echo "$newtime" "$rtime" "$oldtime" | awk '{ print ($1 - $2 > $2 - $3) }') = 1
45 then
46 # Current commit is considered "good/old"
47 echo "$rtime" >"$info_dir/oldtime"
48 exit 0
49 else
50 # Current commit is considered "bad/new"
51 echo "$rtime" >"$info_dir/newtime"
52 exit 1