Merge branch 'ab/perf-installed-fix'
authorJunio C Hamano <gitster@pobox.com>
Sun, 19 May 2019 07:45:28 +0000 (16:45 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 May 2019 07:45:28 +0000 (16:45 +0900)
Performance test framework has been broken and measured the version
of Git that happens to be on $PATH, not the specified one to
measure, for a while, which has been corrected.

* ab/perf-installed-fix:
perf-lib.sh: forbid the use of GIT_TEST_INSTALLED
perf tests: add "bindir" prefix to git tree test results
perf-lib.sh: remove GIT_TEST_INSTALLED from perf-lib.sh
perf-lib.sh: make "./run <revisions>" use the correct gits
perf aggregate: remove GIT_TEST_INSTALLED from --codespeed
perf README: correct docs for 3c8f12c96c regression

t/perf/README
t/perf/aggregate.perl
t/perf/perf-lib.sh
t/perf/run
index be12090c3853b8d64bb903aa92b74001d0fdd19f..c7b70e2d28ba3f8b24a3c4dfe4bb436b1f4acfa5 100644 (file)
@@ -45,7 +45,7 @@ call the aggregation script to summarize the results:
 
     $ ./p0001-rev-list.sh
     [...]
-    $ GIT_BUILD_DIR=/path/to/other/git ./p0001-rev-list.sh
+    $ ./run /path/to/other/git -- ./p0001-rev-list.sh
     [...]
     $ ./aggregate.perl . /path/to/other/git ./p0001-rev-list.sh
 
index 76dd48f8908e4f001152088845423d1e0f631727..66554d216122d26699e425b35166de460fa3821f 100755 (executable)
@@ -5,6 +5,7 @@
 use warnings;
 use Getopt::Long;
 use Git;
+use Cwd qw(realpath);
 
 sub get_times {
        my $name = shift;
@@ -98,18 +99,21 @@ sub format_size {
 while (scalar @ARGV) {
        my $arg = $ARGV[0];
        my $dir;
+       my $prefix = '';
        last if -f $arg or $arg eq "--";
        if (! -d $arg) {
                my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
                $dir = "build/".$rev;
+       } elsif ($arg eq '.') {
+               $dir = '.';
        } else {
-               $arg =~ s{/*$}{};
-               $dir = $arg;
-               $dirabbrevs{$dir} = $dir;
+               $dir = realpath($arg);
+               $dirnames{$dir} = $dir;
+               $prefix .= 'bindir';
        }
        push @dirs, $dir;
-       $dirnames{$dir} = $arg;
-       my $prefix = $dir;
+       $dirnames{$dir} ||= $arg;
+       $prefix .= $dir;
        $prefix =~ tr/^a-zA-Z0-9/_/c;
        $prefixes{$dir} = $prefix . '.';
        shift @ARGV;
@@ -311,9 +315,6 @@ sub print_codespeed_results {
                $environment = $reponame;
        } elsif (exists $ENV{GIT_PERF_REPO_NAME} and $ENV{GIT_PERF_REPO_NAME} ne "") {
                $environment = $ENV{GIT_PERF_REPO_NAME};
-       } elsif (exists $ENV{GIT_TEST_INSTALLED} and $ENV{GIT_TEST_INSTALLED} ne "") {
-               $environment = $ENV{GIT_TEST_INSTALLED};
-               $environment =~ s|/bin-wrappers$||;
        } else {
                $environment = `uname -r`;
                chomp $environment;
index 169f92eae3d419b2d9d4ccdfbde4a394cc9e15dd..b58a43ea4364a8e5a2c5b9af39b41ec9f0b94f5b 100644 (file)
 # because it will change our working directory.
 TEST_DIRECTORY=$(pwd)/..
 TEST_OUTPUT_DIRECTORY=$(pwd)
-ABSOLUTE_GIT_TEST_INSTALLED=$(
-       test -n "$GIT_TEST_INSTALLED" && cd "$GIT_TEST_INSTALLED" && pwd)
 
 TEST_NO_CREATE_REPO=t
 TEST_NO_MALLOC_CHECK=t
 
 . ../test-lib.sh
 
-if test -z "$GIT_TEST_INSTALLED"; then
-       perf_results_prefix=
-else
-       perf_results_prefix=$(printf "%s" "${GIT_TEST_INSTALLED%/bin-wrappers}" | tr -c "[a-zA-Z0-9]" "[_*]")"."
-       GIT_TEST_INSTALLED=$ABSOLUTE_GIT_TEST_INSTALLED
+if test -n "$GIT_TEST_INSTALLED" -a -z "$PERF_SET_GIT_TEST_INSTALLED"
+then
+       error "Do not use GIT_TEST_INSTALLED with the perf tests.
+
+Instead use:
+
+    ./run <path-to-git> -- <tests>
+
+See t/perf/README for details."
 fi
 
 # Variables from test-lib that are normally internal to the tests; we
@@ -179,7 +181,7 @@ test_wrapper_ () {
                base=$(basename "$0" .sh)
                echo "$test_count" >>"$perf_results_dir"/$base.subtests
                echo "$1" >"$perf_results_dir"/$base.$test_count.descr
-               base="$perf_results_dir"/"$perf_results_prefix$(basename "$0" .sh)"."$test_count"
+               base="$perf_results_dir"/"$PERF_RESULTS_PREFIX$(basename "$0" .sh)"."$test_count"
                "$test_wrapper_func_" "$@"
        fi
 
index 9aaa733c770fb97157e273b6c6d1efd38f9a630a..c7b86104e12a6637b1084d6e02743f6c36df9265 100755 (executable)
@@ -70,6 +70,24 @@ build_git_rev () {
        ) || die "failed to build revision '$mydir'"
 }
 
+set_git_test_installed () {
+       mydir=$1
+
+       mydir_abs=$(cd $mydir && pwd)
+       mydir_abs_wrappers="$mydir_abs_wrappers/bin-wrappers"
+       if test -d "$mydir_abs_wrappers"
+       then
+               GIT_TEST_INSTALLED=$mydir_abs_wrappers
+       else
+               # Older versions of git lacked bin-wrappers;
+               # fallback to the files in the root.
+               GIT_TEST_INSTALLED=$mydir_abs
+       fi
+       export GIT_TEST_INSTALLED
+       PERF_SET_GIT_TEST_INSTALLED=true
+       export PERF_SET_GIT_TEST_INSTALLED
+}
+
 run_dirs_helper () {
        mydir=${1%/}
        shift
@@ -79,7 +97,16 @@ run_dirs_helper () {
        if test $# -gt 0 -a "$1" = --; then
                shift
        fi
-       if [ ! -d "$mydir" ]; then
+
+       PERF_RESULTS_PREFIX=
+       if test "$mydir" = "."
+       then
+               unset GIT_TEST_INSTALLED
+       elif test -d "$mydir"
+       then
+               PERF_RESULTS_PREFIX=bindir$(cd $mydir && printf "%s" "$(pwd)" | tr -c "[a-zA-Z0-9]" "_").
+               set_git_test_installed "$mydir"
+       else
                rev=$(git rev-parse --verify "$mydir" 2>/dev/null) ||
                die "'$mydir' is neither a directory nor a valid revision"
                if [ ! -d build/$rev ]; then
@@ -87,16 +114,12 @@ run_dirs_helper () {
                fi
                build_git_rev $rev "$mydir"
                mydir=build/$rev
+
+               PERF_RESULTS_PREFIX=build_$rev.
+               set_git_test_installed "$mydir"
        fi
-       if test "$mydir" = .; then
-               unset GIT_TEST_INSTALLED
-       else
-               GIT_TEST_INSTALLED="$mydir/bin-wrappers"
-               # Older versions of git lacked bin-wrappers; fallback to the
-               # files in the root.
-               test -d "$GIT_TEST_INSTALLED" || GIT_TEST_INSTALLED=$mydir
-               export GIT_TEST_INSTALLED
-       fi
+       export PERF_RESULTS_PREFIX
+
        run_one_dir "$@"
 }