| OLD | NEW |
| 1 ''' | 1 ''' |
| 2 Created on May 16, 2011 | 2 Created on May 16, 2011 |
| 3 | 3 |
| 4 @author: bungeman | 4 @author: bungeman |
| 5 ''' | 5 ''' |
| 6 import bench_util | 6 import bench_util |
| 7 import getopt | 7 import getopt |
| 8 import httplib | 8 import httplib |
| 9 import itertools | 9 import itertools |
| 10 import json | 10 import json |
| 11 import os | 11 import os |
| 12 import re | 12 import re |
| 13 import sys | 13 import sys |
| 14 import urllib | 14 import urllib |
| 15 import urllib2 | 15 import urllib2 |
| 16 import xml.sax.saxutils | 16 import xml.sax.saxutils |
| 17 | 17 |
| 18 # We throw out any measurement outside this range, and log a warning. | 18 # We throw out any measurement outside this range, and log a warning. |
| 19 MIN_REASONABLE_TIME = 0 | 19 MIN_REASONABLE_TIME = 0 |
| 20 MAX_REASONABLE_TIME = 99999 | 20 MAX_REASONABLE_TIME = 99999 |
| 21 | 21 |
| 22 # Constants for prefixes in output title used in buildbot. | 22 # Constants for prefixes in output title used in buildbot. |
| 23 TITLE_PREAMBLE = 'Bench_Performance_for_Skia_' | 23 TITLE_PREAMBLE = 'Bench_Performance_for_Skia_' |
| 24 TITLE_PREAMBLE_LENGTH = len(TITLE_PREAMBLE) | 24 TITLE_PREAMBLE_LENGTH = len(TITLE_PREAMBLE) |
| 25 | 25 |
| 26 # Number of data points to send to appengine at once. | |
| 27 DATA_POINT_BATCHSIZE = 66 | |
| 28 | |
| 29 def grouper(n, iterable): | |
| 30 """Groups list into list of lists for a given size. See itertools doc: | |
| 31 http://docs.python.org/2/library/itertools.html#module-itertools | |
| 32 """ | |
| 33 args = [iter(iterable)] * n | |
| 34 return [[n for n in t if n] for t in itertools.izip_longest(*args)] | |
| 35 | |
| 36 | |
| 37 def usage(): | 26 def usage(): |
| 38 """Prints simple usage information.""" | 27 """Prints simple usage information.""" |
| 39 | 28 |
| 40 print '-a <url> the url to use for adding bench values to app engine app.' | 29 print '-a <url> the url to use for adding bench values to app engine app.' |
| 41 print ' Example: "https://skiadash.appspot.com/add_point".' | 30 print ' Example: "https://skiadash.appspot.com/add_point".' |
| 42 print ' If not set, will skip this step.' | 31 print ' If not set, will skip this step.' |
| 43 print '-b <bench> the bench to show.' | 32 print '-b <bench> the bench to show.' |
| 44 print '-c <config> the config to show (GPU, 8888, 565, etc).' | 33 print '-c <config> the config to show (GPU, 8888, 565, etc).' |
| 45 print '-d <dir> a directory containing bench_r<revision>_<scalar> files.' | 34 print '-d <dir> a directory containing bench_r<revision>_<scalar> files.' |
| 46 print '-e <file> file containing expected bench values/ranges.' | 35 print '-e <file> file containing expected bench values/ranges.' |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 raise Exception('Bench values out of range:\n' + | 395 raise Exception('Bench values out of range:\n' + |
| 407 '\n'.join(exceptions)) | 396 '\n'.join(exceptions)) |
| 408 | 397 |
| 409 def write_to_appengine(line_data_dict, url, newest_revision, bot): | 398 def write_to_appengine(line_data_dict, url, newest_revision, bot): |
| 410 """Writes latest bench values to appengine datastore. | 399 """Writes latest bench values to appengine datastore. |
| 411 line_data_dict: dictionary from create_lines. | 400 line_data_dict: dictionary from create_lines. |
| 412 url: the appengine url used to send bench values to write | 401 url: the appengine url used to send bench values to write |
| 413 newest_revision: the latest revision that this script reads | 402 newest_revision: the latest revision that this script reads |
| 414 bot: the bot platform the bench is run on | 403 bot: the bot platform the bench is run on |
| 415 """ | 404 """ |
| 416 data = [] | 405 config_data_dic = {} |
| 417 for label in line_data_dict.iterkeys(): | 406 for label in line_data_dict.iterkeys(): |
| 418 if not label.bench.endswith('.skp') or label.time_type: | 407 if not label.bench.endswith('.skp') or label.time_type: |
| 419 # filter out non-picture and non-walltime benches | 408 # filter out non-picture and non-walltime benches |
| 420 continue | 409 continue |
| 421 config = label.config | 410 config = label.config |
| 422 rev, val = line_data_dict[label][-1] | 411 rev, val = line_data_dict[label][-1] |
| 423 # This assumes that newest_revision is >= the revision of the last | 412 # This assumes that newest_revision is >= the revision of the last |
| 424 # data point we have for each line. | 413 # data point we have for each line. |
| 425 if rev != newest_revision: | 414 if rev != newest_revision: |
| 426 continue | 415 continue |
| 427 data.append({'master': 'Skia', 'bot': bot, | 416 if config not in config_data_dic: |
| 428 'test': config + '/' + label.bench.replace('.skp', ''), | 417 config_data_dic[config] = [] |
| 429 'revision': rev, 'value': val, 'error': 0}) | 418 config_data_dic[config].append(label.bench.replace('.skp', '') + |
| 430 for curr_data in grouper(DATA_POINT_BATCHSIZE, data): | 419 ':%.2f' % val) |
| 431 req = urllib2.Request(appengine_url, | 420 for config in config_data_dic: |
| 432 urllib.urlencode({'data': json.dumps(curr_data)})) | 421 if config_data_dic[config]: |
| 433 try: | 422 data = {'master': 'Skia', 'bot': bot, 'test': config, |
| 434 urllib2.urlopen(req) | 423 'revision': newest_revision, |
| 435 except urllib2.HTTPError, e: | 424 'benches': ','.join(config_data_dic[config])} |
| 436 sys.stderr.write("HTTPError for JSON data %s: %s\n" % ( | 425 req = urllib2.Request(appengine_url, |
| 437 data, e)) | 426 urllib.urlencode({'data': json.dumps(data)})) |
| 438 except urllib2.URLError, e: | 427 try: |
| 439 sys.stderr.write("URLError for JSON data %s: %s\n" % ( | 428 urllib2.urlopen(req) |
| 440 data, e)) | 429 except urllib2.HTTPError, e: |
| 441 except httplib.HTTPException, e: | 430 sys.stderr.write("HTTPError for JSON data %s: %s\n" % ( |
| 442 sys.stderr.write("HTTPException for JSON data %s: %s\n" % ( | 431 data, e)) |
| 443 data, e)) | 432 except urllib2.URLError, e: |
| 433 sys.stderr.write("URLError for JSON data %s: %s\n" % ( |
| 434 data, e)) |
| 435 except httplib.HTTPException, e: |
| 436 sys.stderr.write("HTTPException for JSON data %s: %s\n" % ( |
| 437 data, e)) |
| 444 | 438 |
| 445 try: | 439 try: |
| 446 for option, value in opts: | 440 for option, value in opts: |
| 447 if option == "-a": | 441 if option == "-a": |
| 448 appengine_url = value | 442 appengine_url = value |
| 449 elif option == "-b": | 443 elif option == "-b": |
| 450 bench_of_interest = value | 444 bench_of_interest = value |
| 451 elif option == "-c": | 445 elif option == "-c": |
| 452 config_of_interest = value | 446 config_of_interest = value |
| 453 elif option == "-d": | 447 elif option == "-d": |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 print '<a id="rev_link" xlink:href="" target="_top">' | 1034 print '<a id="rev_link" xlink:href="" target="_top">' |
| 1041 print '<text id="revision" x="0" y=%s style="' % qa(font_size*2) | 1035 print '<text id="revision" x="0" y=%s style="' % qa(font_size*2) |
| 1042 print 'font-size: %s; ' % qe(font_size) | 1036 print 'font-size: %s; ' % qe(font_size) |
| 1043 print 'stroke: #0000dd; text-decoration: underline; ' | 1037 print 'stroke: #0000dd; text-decoration: underline; ' |
| 1044 print '"> </text></a>' | 1038 print '"> </text></a>' |
| 1045 | 1039 |
| 1046 print '</svg>' | 1040 print '</svg>' |
| 1047 | 1041 |
| 1048 if __name__ == "__main__": | 1042 if __name__ == "__main__": |
| 1049 main() | 1043 main() |
| OLD | NEW |