Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 87 lines (64 sloc) 2.323 kB
de0d6f3 add skeleton of a performance regression detector
Txus authored
1 #!/bin/bash
2 #
3 # This script runs a given command over a range of Git revisions. Note that it
4 # will check past revisions out! Exercise caution if there are important
5 # untracked files in your working tree.
6 #
7 # This came from Gary Bernhardt's dotfiles:
8 # https://github.com/garybernhardt/dotfiles
9 #
10 # Example usage:
11 # $ run-command-on-git-revisions origin/master master 'python runtests.py'
12
13 set -e
14
15 start_ref=$1
16 end_ref=$2
17
18 run_benchmarks() {
19 # Get git revsA
20
21 revs=`log_command git rev-list --reverse --abbrev-commit ${start_ref}..${end_ref}`
22
23 # Backup current benchmarks
24
25 if [ -e "../__perf" ]; then
26 rm -fR ../__perf
27 fi
28
29 mkdir -p ../__perf/perf
30 cp -r perf/* ../__perf/perf/
31 cp -r perf.sh ../__perf/perf.sh
32
33 # Remove stats file if they exist
34 if [ -e "../__perf/*.csv" ]; then
35 log_command rm ../__perf/*.csv
36 fi
37
38 for rev in $revs; do
39 echo "Checking out: $(git log --oneline -1 $rev)"
40 log_command git checkout --quiet $rev
41
42 for f in ../__perf/perf/*_bench.rb
43 do
44 name=`echo "$f" | sed -e "s/\// /g" | sed -e 's/_bench\.rb/ /g' | awk '{ print $4 }'`
45 echo "$name benchmarks..."
46
47 # Replace perf directory with our own
48
49 if [ -e "perf" ]; then
50 log_command rm -fR perf
51 fi
52 log_command cp -r ../__perf/perf perf
53
54 stats_filename=${name}_stats.csv
55
56 output=`ruby perf/${name}_bench.rb`
57
58 lexer_time=`echo "$output" | grep '^LEXER' | awk '{print $2}'`
59 parser_time=`echo "$output" | grep '^PARSER' | awk '{print $2}'`
60 runtime=`echo "$output" | grep '^RUNTIME' | awk '{print $2}'`
61 total_time=`echo "$output" | grep '^TOTAL' | awk '{print $2}'`
62
63 timestamp=`git log -1 --pretty="format:%ai" $rev`
64
65 log_command echo $timestamp,$rev,$lexer_time,$parser_time,$runtime,$total_time >> ../__perf/$stats_filename
66 done
67
68 # Cleanup the mess
69 git clean -fd
70 done
71 log_command git checkout $end_ref
72
73 echo "Restoring benchmarks..."
74 log_command cp -r ../__perf/perf perf
75 log_command cp -r ../__perf/perf.sh perf.sh
76
77 echo "OK for all revisions!"
78 echo "Stats are in: `ls ../__perf/*.csv`"
79 }
80
81 log_command() {
82 echo "=> $*" >&2
83 eval $*
84 }
85
86 run_benchmarks
Something went wrong with that request. Please try again.