forked from tobami/codespeed
-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtest_performance.py
More file actions
62 lines (54 loc) · 1.67 KB
/
test_performance.py
File metadata and controls
62 lines (54 loc) · 1.67 KB
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
import timeit
import urllib
import sys
SPEEDURL = 'http://localhost:8000/'
benchmarks = ['ai', 'django', 'spambayes', 'grid']
def test_overview():
data = {
"trend": 10,
"baseline": 1,
"revision": 73893,
"executable": "1",
"host": "bigdog",
}
params = urllib.urlencode(data)
page = urllib.urlopen(SPEEDURL + 'overview/table/?' + params)
jsonstring = page.read()
page.close()
if not '<table id="results" class="tablesorter">' in jsonstring:
print "bad overview response"
sys.exit(1)
def test_timeline(bench):
data = {
"executables": "1,2,6",
"baseline": "true",
"benchmark": bench,
"host": "bigdog",
"revisions": 200
}
params = urllib.urlencode(data)
page = urllib.urlopen(SPEEDURL + 'timeline/json/?' + params)
jsonstring = page.read()
#print jsonstring
page.close()
if not '"lessisbetter": " (less is better)", "baseline":' in jsonstring \
or not', "error": "None"}' in jsonstring:
print "bad timeline response"
sys.exit(1)
if __name__ == "__main__":
t = timeit.Timer('test_overview()', 'from __main__ import test_overview')
results = t.repeat(20, 1)
print
print "OVERVIEW RESULTS"
print "min:", min(results)
print "avg:", sum(results) / len(results)
print
print "TIMELINE RESULTS"
for bench in benchmarks:
t = timeit.Timer('test_timeline("' + bench + '")',
'from __main__ import test_timeline')
results = t.repeat(20, 1)
print "benchmark =", bench
print "min:", min(results)
print "avg:", sum(results) / len(results)
print