t / perf / bisect_run_scripton commit config: work around bug with includeif:onbranch and early config (85fe0e8)
   1#!/bin/sh
   2
   3script="$1"
   4test_number="$2"
   5info_dir="$3"
   6
   7# This aborts the bisection immediately
   8die () {
   9        echo >&2 "error: $*"
  10        exit 255
  11}
  12
  13bisect_head=$(git rev-parse --verify BISECT_HEAD) || die "Failed to find BISECT_HEAD ref"
  14
  15script_number=$(echo "$script" | sed -e "s/^p\([0-9]*\).*\$/\1/") || die "Failed to get script number for '$script'"
  16
  17oldtime=$(cat "$info_dir/oldtime") || die "Failed to access '$info_dir/oldtime'"
  18newtime=$(cat "$info_dir/newtime") || die "Failed to access '$info_dir/newtime'"
  19
  20cd t/perf || die "Failed to cd into 't/perf'"
  21
  22result_file="$info_dir/perf_${script_number}_${bisect_head}_results.txt"
  23
  24GIT_PERF_DIRS_OR_REVS="$bisect_head"
  25export GIT_PERF_DIRS_OR_REVS
  26
  27# Don't use codespeed
  28GIT_PERF_CODESPEED_OUTPUT=
  29GIT_PERF_SEND_TO_CODESPEED=
  30export GIT_PERF_CODESPEED_OUTPUT
  31export GIT_PERF_SEND_TO_CODESPEED
  32
  33./run "$script" >"$result_file" 2>&1 || die "Failed to run perf test '$script'"
  34
  35rtime=$(sed -n "s/^$script_number\.$test_number:.*\([0-9]\+\.[0-9]\+\)(.*).*\$/\1/p" "$result_file")
  36
  37echo "newtime: $newtime"
  38echo "rtime: $rtime"
  39echo "oldtime: $oldtime"
  40
  41# Compare ($newtime - $rtime) with ($rtime - $oldtime)
  42# Times are decimal number, not integers
  43
  44if test $(echo "$newtime" "$rtime" "$oldtime" | awk '{ print ($1 - $2 > $2 - $3) }') = 1
  45then
  46        # Current commit is considered "good/old"
  47        echo "$rtime" >"$info_dir/oldtime"
  48        exit 0
  49else
  50        # Current commit is considered "bad/new"
  51        echo "$rtime" >"$info_dir/newtime"
  52        exit 1
  53fi