2 # Copyright (C) 2011, 2012 Purdue University
3 # Written by Gregor Richards
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
9 # 1. Redistributions of source code must retain the above copyright notice,
10 # this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright notice,
12 # this list of conditions and the following disclaimer in the documentation
13 # and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
32 benchmarks = ["amazon/chrome", "amazon/firefox", "amazon/safari",
33 "facebook/chrome", "facebook/firefox", "facebook/safari",
34 "google/chrome", "google/firefox", "google/safari",
35 "twitter/chrome", "twitter/firefox", "twitter/safari",
36 "yahoo/chrome", "yahoo/firefox", "yahoo/safari"]
39 "amazon/firefox": ["urm"],
40 "google/firefox": ["uem"]
45 keepfrom = runcount - keepruns
47 if len(sys.argv) != 2:
48 print "Use: python harness.py <JS executable>"
52 # standard t-distribution for normally distributed samples
53 tDistribution = [0, 0, 12.71, 4.30, 3.18, 2.78, 2.57, 2.45, 2.36, 2.31, 2.26,
54 2.23, 2.20, 2.18, 2.16, 2.14, 2.13, 2.12, 2.11, 2.10, 2.09, 2.09, 2.08, 2.07,
55 2.07, 2.06, 2.06, 2.06, 2.05, 2.05, 2.05, 2.04, 2.04, 2.04, 2.03, 2.03, 2.03,
56 2.03, 2.03, 2.02, 2.02, 2.02, 2.02, 2.02, 2.02, 2.02, 2.01, 2.01, 2.01, 2.01,
57 2.01, 2.01, 2.01, 2.01, 2.01, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00,
58 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 2.00, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99,
59 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99,
60 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.99, 1.98, 1.98, 1.98, 1.98, 1.98,
61 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98,
62 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98,
63 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98,
64 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.98,
65 1.98, 1.98, 1.98, 1.98, 1.98, 1.98, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
66 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
67 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
68 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
69 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
70 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
71 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
72 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
73 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
74 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
75 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
76 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
77 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
78 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
79 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
80 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
81 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
82 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
83 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
84 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
85 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
86 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
87 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
88 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97,
89 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.97, 1.96]
92 if (n >= len(tDistribution)):
93 return tDistribution[-1]
94 return tDistribution[n]
98 for benchmark in benchmarks:
99 results[benchmark] = {}
102 if benchmark in modes:
103 bmodes = modes[benchmark]
106 results[benchmark][mode] = []
108 for runno in range(runcount):
109 # Now run it and get the results
110 print(benchmark + " " + mode + " " + str(runno))
111 res = os.popen(js + " " + benchmark + "/" + mode + ".js").read()
112 time = float(re.match("Time: ([0-9]*)ms", res).group(1))
114 if runno >= keepfrom:
115 results[benchmark][mode].append(time)
127 for benchmark in benchmarks:
128 sresults[benchmark] = {}
134 if benchmark in modes:
135 bmodes = modes[benchmark]
138 sresults[benchmark][mode] = sresult = {}
139 result = results[benchmark][mode]
140 totals["runs"] = totals["runs"] + 1
142 sresult["mode"] = mode
144 mean = sresult["mean"] = sum(result) / len(result)
145 stddev = sresult["stddev"] = math.sqrt(
147 map(lambda e: math.pow(e - mean, 2), result)
148 ) / (len(result) - 1)
151 sm = sresult["sm"] = stddev / mean
152 sem = sresult["sem"] = stddev / math.sqrt(len(result))
153 semm = sresult["semm"] = sem / mean
154 ci = sresult["ci"] = tDist(len(result)) * sem
155 cim = sresult["cim"] = ci / mean
157 totals["mean"] *= mean
158 totals["stddev"] *= stddev
162 power = 1 / totals["runs"]
163 totals["mean"] = math.pow(totals["mean"], power)
164 totals["stddev"] = math.pow(totals["stddev"], power)
165 totals["sm"] = totals["stddev"] / totals["mean"]
166 totals["sem"] = math.pow(totals["sem"], power)
167 totals["semm"] = totals["sem"] / totals["mean"]
168 totals["ci"] = math.pow(totals["ci"], power)
169 totals["cim"] = totals["ci"] / totals["mean"]
172 totals["semm"] *= 100
175 print "Final results:"
176 print u" %(mean)fms \u00b1 %(cim)f%% (lower is better)" % totals
177 print " Standard deviation = %(sm)f%% of mean" % totals
178 print " Standard error = %(semm)f%% of mean" % totals
179 print " %(runs)d runs" % {"runs": runcount}
182 print "Result breakdown:"
183 for benchmark in benchmarks:
184 print " %(benchmark)s:" % {"benchmark": benchmark}
187 if benchmark in modes:
188 bmodes = modes[benchmark]
191 print u" %(mode)s: %(mean)fms \u00b1 %(cim)f%% (stddev=%(sm)f%%, stderr=%(semm)f%%)" % sresults[benchmark][mode]
195 for benchmark in benchmarks:
196 print " %(benchmark)s:" % {"benchmark": benchmark}
199 if benchmark in modes:
200 bmodes = modes[benchmark]
203 print " %(mode)s: %(results)s" % {
205 "results": results[benchmark][mode]