|
| 1 | +import timeit, urllib, sys |
| 2 | + |
| 3 | +SPEEDURL = 'http://localhost:8000/' |
| 4 | + |
| 5 | +benchmarks = ['ai', 'django', 'spambayes', 'grid'] |
| 6 | + |
| 7 | +def test_overview(): |
| 8 | + data = { |
| 9 | + "trend": 10, |
| 10 | + "baseline": 1, |
| 11 | + "revision": 73893, |
| 12 | + "executable": "1", |
| 13 | + "host": "bigdog", |
| 14 | + } |
| 15 | + params = urllib.urlencode(data) |
| 16 | + page= urllib.urlopen(SPEEDURL + 'overview/table/?' + params) |
| 17 | + jsonstring = page.read() |
| 18 | + page.close() |
| 19 | + if not '<table id="results" class="tablesorter">' in jsonstring: |
| 20 | + print "bad overview response" |
| 21 | + sys.exit(1) |
| 22 | + |
| 23 | +def test_timeline(bench): |
| 24 | + data = { |
| 25 | + "executables": "1,2,6", |
| 26 | + "baseline": "true", |
| 27 | + "benchmark": bench, |
| 28 | + "host": "bigdog", |
| 29 | + "revisions": 200 |
| 30 | + } |
| 31 | + params = urllib.urlencode(data) |
| 32 | + page= urllib.urlopen(SPEEDURL + 'timeline/json/?' + params) |
| 33 | + jsonstring = page.read() |
| 34 | + #print jsonstring |
| 35 | + page.close() |
| 36 | + if not '"lessisbetter": " (less is better)", "baseline":' in jsonstring \ |
| 37 | + or not', "error": "None"}' in jsonstring: |
| 38 | + print "bad timeline response" |
| 39 | + sys.exit(1) |
| 40 | + |
| 41 | +if __name__ == "__main__": |
| 42 | + t = timeit.Timer('test_overview()', 'from __main__ import test_overview') |
| 43 | + results = t.repeat(20, 1) |
| 44 | + print |
| 45 | + print "OVERVIEW RESULTS" |
| 46 | + print "min:", min(results) |
| 47 | + print "avg:", sum(results)/len(results) |
| 48 | + print |
| 49 | + print "TIMELINE RESULTS" |
| 50 | + for bench in benchmarks: |
| 51 | + t = timeit.Timer('test_timeline("'+bench+'")', 'from __main__ import test_timeline') |
| 52 | + results = t.repeat(20, 1) |
| 53 | + print "benchmark =", bench |
| 54 | + print "min:", min(results) |
| 55 | + print "avg:", sum(results)/len(results) |
| 56 | + print |
0 commit comments