Skip to content

Commit 7102541

Browse files
committed
Merge branch 'cc/perf-run-config'
* cc/perf-run-config: perf: store subsection results in "test-results/$GIT_PERF_SUBSECTION/" perf/run: show name of rev being built perf/run: add run_subsection() perf/run: update get_var_from_env_or_config() for subsections perf/run: add get_subsections() perf/run: add calls to get_var_from_env_or_config() perf/run: add GIT_PERF_DIRS_OR_REVS perf/run: add get_var_from_env_or_config() perf/run: add '--config' option to the 'run' script
2 parents 0b75572 + 5d445f3 commit 7102541

File tree

3 files changed

+89
-15
lines changed

3 files changed

+89
-15
lines changed

t/perf/aggregate.perl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,17 @@ sub format_times {
6969
@tests = glob "p????-*.sh";
7070
}
7171

72+
my $resultsdir = "test-results";
73+
if ($ENV{GIT_PERF_SUBSECTION} ne "") {
74+
$resultsdir .= "/" . $ENV{GIT_PERF_SUBSECTION};
75+
}
76+
7277
my @subtests;
7378
my %shorttests;
7479
for my $t (@tests) {
7580
$t =~ s{(?:.*/)?(p(\d+)-[^/]+)\.sh$}{$1} or die "bad test name: $t";
7681
my $n = $2;
77-
my $fname = "test-results/$t.subtests";
82+
my $fname = "$resultsdir/$t.subtests";
7883
open my $fp, "<", $fname or die "cannot open $fname: $!";
7984
for (<$fp>) {
8085
chomp;
@@ -98,7 +103,7 @@ sub read_descr {
98103
my %descrs;
99104
my $descrlen = 4; # "Test"
100105
for my $t (@subtests) {
101-
$descrs{$t} = $shorttests{$t}.": ".read_descr("test-results/$t.descr");
106+
$descrs{$t} = $shorttests{$t}.": ".read_descr("$resultsdir/$t.descr");
102107
$descrlen = length $descrs{$t} if length $descrs{$t}>$descrlen;
103108
}
104109

@@ -138,7 +143,7 @@ sub have_slash {
138143
my $firstr;
139144
for my $i (0..$#dirs) {
140145
my $d = $dirs[$i];
141-
$times{$prefixes{$d}.$t} = [get_times("test-results/$prefixes{$d}$t.times")];
146+
$times{$prefixes{$d}.$t} = [get_times("$resultsdir/$prefixes{$d}$t.times")];
142147
my ($r,$u,$s) = @{$times{$prefixes{$d}.$t}};
143148
my $w = length format_times($r,$u,$s,$firstr);
144149
$colwidth[$i] = $w if $w > $colwidth[$i];

t/perf/perf-lib.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ MODERN_GIT=$GIT_BUILD_DIR/bin-wrappers/git
5656
export MODERN_GIT
5757

5858
perf_results_dir=$TEST_OUTPUT_DIRECTORY/test-results
59+
test -n "$GIT_PERF_SUBSECTION" && perf_results_dir="$perf_results_dir/$GIT_PERF_SUBSECTION"
5960
mkdir -p "$perf_results_dir"
6061
rm -f "$perf_results_dir"/$(basename "$0" .sh).subtests
6162

62-
if test -z "$GIT_PERF_REPEAT_COUNT"; then
63-
GIT_PERF_REPEAT_COUNT=3
64-
fi
6563
die_if_build_dir_not_repo () {
6664
if ! ( cd "$TEST_DIRECTORY/.." &&
6765
git rev-parse --build-dir >/dev/null 2>&1 ); then

t/perf/run

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
case "$1" in
44
--help)
5-
echo "usage: $0 [other_git_tree...] [--] [test_scripts]"
5+
echo "usage: $0 [--config file] [other_git_tree...] [--] [test_scripts]"
66
exit 0
77
;;
8+
--config)
9+
shift
10+
GIT_PERF_CONFIG_FILE=$(cd "$(dirname "$1")"; pwd)/$(basename "$1")
11+
export GIT_PERF_CONFIG_FILE
12+
shift ;;
813
esac
914

1015
die () {
@@ -29,16 +34,18 @@ unpack_git_rev () {
2934
(cd "$(git rev-parse --show-cdup)" && git archive --format=tar $rev) |
3035
(cd build/$rev && tar x)
3136
}
37+
3238
build_git_rev () {
3339
rev=$1
40+
name="$2"
3441
for config in config.mak config.mak.autogen config.status
3542
do
3643
if test -e "../../$config"
3744
then
3845
cp "../../$config" "build/$rev/"
3946
fi
4047
done
41-
echo "=== Building $rev ==="
48+
echo "=== Building $rev ($name) ==="
4249
(
4350
cd build/$rev &&
4451
if test -n "$GIT_PERF_MAKE_COMMAND"
@@ -65,7 +72,7 @@ run_dirs_helper () {
6572
if [ ! -d build/$rev ]; then
6673
unpack_git_rev $rev
6774
fi
68-
build_git_rev $rev
75+
build_git_rev $rev "$mydir"
6976
mydir=build/$rev
7077
fi
7178
if test "$mydir" = .; then
@@ -87,14 +94,78 @@ run_dirs () {
8794
done
8895
}
8996

90-
GIT_PERF_AGGREGATING_LATER=t
91-
export GIT_PERF_AGGREGATING_LATER
97+
get_subsections () {
98+
section="$1"
99+
test -z "$GIT_PERF_CONFIG_FILE" && return
100+
git config -f "$GIT_PERF_CONFIG_FILE" --name-only --get-regex "$section\..*\.[^.]+" |
101+
sed -e "s/$section\.\(.*\)\..*/\1/" | sort | uniq
102+
}
103+
104+
get_var_from_env_or_config () {
105+
env_var="$1"
106+
conf_sec="$2"
107+
conf_var="$3"
108+
# $4 can be set to a default value
109+
110+
# Do nothing if the env variable is already set
111+
eval "test -z \"\${$env_var+x}\"" || return
112+
113+
test -z "$GIT_PERF_CONFIG_FILE" && return
114+
115+
# Check if the variable is in the config file
116+
if test -n "$GIT_PERF_SUBSECTION"
117+
then
118+
var="$conf_sec.$GIT_PERF_SUBSECTION.$conf_var"
119+
conf_value=$(git config -f "$GIT_PERF_CONFIG_FILE" "$var") &&
120+
eval "$env_var=\"$conf_value\"" && return
121+
fi
122+
var="$conf_sec.$conf_var"
123+
conf_value=$(git config -f "$GIT_PERF_CONFIG_FILE" "$var") &&
124+
eval "$env_var=\"$conf_value\"" && return
125+
126+
test -n "${4+x}" && eval "$env_var=\"$4\""
127+
}
128+
129+
run_subsection () {
130+
get_var_from_env_or_config "GIT_PERF_REPEAT_COUNT" "perf" "repeatCount" 3
131+
export GIT_PERF_REPEAT_COUNT
132+
133+
get_var_from_env_or_config "GIT_PERF_DIRS_OR_REVS" "perf" "dirsOrRevs"
134+
set -- $GIT_PERF_DIRS_OR_REVS "$@"
135+
136+
get_var_from_env_or_config "GIT_PERF_MAKE_COMMAND" "perf" "makeCommand"
137+
get_var_from_env_or_config "GIT_PERF_MAKE_OPTS" "perf" "makeOpts"
138+
139+
GIT_PERF_AGGREGATING_LATER=t
140+
export GIT_PERF_AGGREGATING_LATER
141+
142+
if test $# = 0 -o "$1" = -- -o -f "$1"; then
143+
set -- . "$@"
144+
fi
145+
146+
run_dirs "$@"
147+
./aggregate.perl "$@"
148+
}
92149

93150
cd "$(dirname $0)"
94151
. ../../GIT-BUILD-OPTIONS
95152

96-
if test $# = 0 -o "$1" = -- -o -f "$1"; then
97-
set -- . "$@"
153+
mkdir -p test-results
154+
get_subsections "perf" >test-results/run_subsections.names
155+
156+
if test $(wc -l <test-results/run_subsections.names) -eq 0
157+
then
158+
(
159+
run_subsection "$@"
160+
)
161+
else
162+
while read -r subsec
163+
do
164+
(
165+
GIT_PERF_SUBSECTION="$subsec"
166+
export GIT_PERF_SUBSECTION
167+
echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========"
168+
run_subsection "$@"
169+
)
170+
done <test-results/run_subsections.names
98171
fi
99-
run_dirs "$@"
100-
./aggregate.perl "$@"

0 commit comments

Comments
 (0)