-
Notifications
You must be signed in to change notification settings - Fork 9
/
benchmark-branches.sh
executable file
·94 lines (75 loc) · 2.12 KB
/
benchmark-branches.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
BASEDIR=$( cd $(dirname $0); pwd );
b_base=$1
b_branch=$2
shift
shift
mkdir -p $(dirname $0)/data/
exec 3>$(dirname $0)"/data/${b_base}-${b_branch}.data"
export XHPROF_KIT_COLLECTOR_FILE=$(dirname $0)"/data/${b_base}-${b_branch}.runs"
echo -n > "$XHPROF_KIT_COLLECTOR_FILE"
echo "### BENCHMARKING ..."
echo
for branch in $*
do
$(dirname $0)/benchmark-vs-baseline.sh "$branch" $b_base $b_branch
echo
done
# Now create XHProf aggregate runs
NAMESPACES=$(cat "$XHPROF_KIT_COLLECTOR_FILE" | cut -d'|' -f2 | sort | uniq)
XHPROF_DIR=$(php -r 'print ini_get("xhprof.output_dir");')
LAST_RUN_ID=""
LAST_NS=""
for namespace in $NAMESPACES
do
TMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t "xhprof-kit-tmp-dir")
# bail out if the dir is empty.
[ -z "$TMPDIR" ] && exit 1
$(dirname $0)/copy-runs-to-directory.sh "$XHPROF_KIT_COLLECTOR_FILE" "$TMPDIR" "$namespace"
TMPDIR2=$(mktemp -d 2>/dev/null || mktemp -d -t "agg-tmp-dir")
# bail out if the dir is empty.
[ -z "$TMPDIR2" ] && exit 1
(
cd "$TMPDIR2"
$BASEDIR/XHProfCLI/bin/xhprof agg "$TMPDIR" >&2
for file in *.xhprof
do
run_id=$(echo $file | cut -d'.' -f1)
ns=$(echo $file | cut -d'.' -f2)
echo "$run_id|$ns"
# @todo Remove hardcoded drupal-perf everywhere.
cp "$file" "$XHPROF_DIR/${run_id}.drupal-perf.xhprof"
done
)
rm -rf "$TMPDIR"
rm -rf "$TMPDIR2"
done | while read line
do
run_id=$(echo $line | cut -d'|' -f1)
ns=$(echo $line | cut -d'|' -f2)
# @todo only works for two branches properly.
if [ -n "$LAST_RUN_ID" ]
then
echo "DATA|$LAST_RUN_ID|$run_id|SUM: $LAST_NS..$ns" >&3
fi
LAST_RUN_ID=$run_id
LAST_NS=$ns
done
echo
echo
echo
echo "### FINAL REPORT"
echo
# Now show the report with aggregates included
$(dirname $0)/show-bench.sh "$b_base" "$b_branch"
echo
echo "### XHPROF-LIB REPORT"
echo
# Now show the XHProfCLI report
TMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t "xhprof-kit-tmp-dir")
# bail out if the dir is empty.
[ -z "$TMPDIR" ] && exit 1
$(dirname $0)/copy-runs-to-directory.sh "$XHPROF_KIT_COLLECTOR_FILE" "$TMPDIR"
$(dirname $0)/XHProfCLI/bin/xhprof summary "$TMPDIR"
rm -rf $TMPDIR
unset XHPROF_KIT_COLLECTOR_FILE