Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Unified Diff: bench/bench_graph_svg.py

Issue 12381088: Codes for writing bench data to appengine datastore. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/bench_graph_svg.py
===================================================================
--- bench/bench_graph_svg.py (revision 7965)
+++ bench/bench_graph_svg.py (working copy)
@@ -9,6 +9,9 @@
import os
import bench_util
import json
+import httplib
epoger 2013/03/05 18:38:52 Please put imports in alpha order
benchen 2013/03/05 20:52:53 Done. Didn't do so since it conflicted with the pr
+import urllib
+import urllib2
import xml.sax.saxutils
# We throw out any measurement outside this range, and log a warning.
@@ -19,9 +22,15 @@
TITLE_PREAMBLE = 'Bench_Performance_for_Skia_'
TITLE_PREAMBLE_LENGTH = len(TITLE_PREAMBLE)
+# Number of data points to send to appengine at once.
+DATA_POINTS_TO_SEND = 100
epoger 2013/03/05 18:38:52 Maybe DATA_POINT_BATCHSIZE instead, because you're
benchen 2013/03/05 20:52:53 Yeah that's better. Done. On 2013/03/05 18:38:52,
+
def usage():
"""Prints simple usage information."""
-
+
+ print '-a <url> the url to use for adding bench values to app engine app.'
+ print ' Example: "https://skiadash.appspot.com/add_point".'
+ print ' If not set, will skip this step.'
print '-b <bench> the bench to show.'
print '-c <config> the config to show (GPU, 8888, 565, etc).'
print '-d <dir> a directory containing bench_r<revision>_<scalar> files.'
@@ -286,7 +295,7 @@
try:
opts, _ = getopt.getopt(sys.argv[1:]
- , "b:c:d:e:f:i:l:m:o:r:s:t:x:y:"
+ , "a:b:c:d:e:f:i:l:m:o:r:s:t:x:y:"
, "default-setting=")
except getopt.GetoptError, err:
print str(err)
@@ -299,6 +308,7 @@
time_of_interest = None
time_to_ignore = None
bench_expectations = {}
+ appengine_url = None # used for adding data to appengine datastore
rep = None # bench representation algorithm
revision_range = '0:'
regression_range = '0:'
@@ -369,10 +379,43 @@
if exceptions:
raise Exception('Bench values out of range:\n' +
'\n'.join(exceptions))
+ def write_to_appengine(lines, url, newest_revision, platform_and_alg):
epoger 2013/03/05 18:38:52 please add newline before this function
benchen 2013/03/05 20:52:53 Done.
+ """Writes latest bench values to appengine datastore."""
epoger 2013/03/05 18:38:52 please document the parameters
benchen 2013/03/05 20:52:53 Done.
+ data = []
+ for line in lines:
+ bot = platform_and_alg[ : platform_and_alg.rfind('-')]
epoger 2013/03/05 18:38:52 Why are we assembling platform_and_alg in line 470
benchen 2013/03/05 20:52:53 I did not separate platform and alg because there
+ line_str = str(line)[ : str(line).find('_{')]
epoger 2013/03/05 18:38:52 So, is this just trying to extract the portion of
benchen 2013/03/05 20:52:53 create_lines() will make sure there is _{ in the l
epoger 2013/03/06 17:17:22 I don't see any mention of "_{" in create_lines.
benchen 2013/03/06 18:52:37 According to Class Label's __str__ method, there's
+ if line_str.find('.skp') < 0 or not line_str.endswith('_'):
+ # filter out non-picture and non-walltime benches
+ continue
+ bench, config = line_str.split('.skp', 1)
+ config = config.strip('_') # remove leading and trailing '_'
+ rev, val = lines[line][-1]
epoger 2013/03/05 18:38:52 Is line a string or an index?
benchen 2013/03/05 20:52:53 It's an object with Label class. Please see create
+ if rev != newest_revision:
+ continue
+ data.append({'master': 'Skia', 'bot': bot,
+ 'test': config + '/' + bench,
+ 'revision': rev, 'value': val, 'error': 0})
+ while data:
+ curr_data = data[ : DATA_POINTS_TO_SEND]
epoger 2013/03/05 18:38:52 This seems like a really inefficient way to work o
benchen 2013/03/05 20:52:53 Nice suggestion. Done. On 2013/03/05 18:38:52, epo
+ data = data[DATA_POINTS_TO_SEND : ]
+ req = urllib2.Request(
+ appengine_url, urllib.urlencode({'data': json.dumps(curr_data)}))
+ try:
+ urllib2.urlopen(req)
+ except urllib2.HTTPError, e:
+ sys.stderr.write("HTTPError: %d for JSON %s\n" % (e.code, data))
epoger 2013/03/05 18:38:52 Why do you display the details of the exception di
benchen 2013/03/05 20:52:53 I was just copying from https://codereview.chromiu
+ except urllib2.URLError, e:
+ sys.stderr.write("URLError: %s for JSON %s\n" % (
+ str(e.reason), data))
+ except httplib.HTTPException, e:
+ sys.stderr.write("HTTPException for JSON %s\n" % lines)
try:
for option, value in opts:
- if option == "-b":
+ if option == "-a":
+ appengine_url = value
+ elif option == "-b":
bench_of_interest = value
elif option == "-c":
config_of_interest = value
@@ -461,6 +504,10 @@
output_xhtml(lines, oldest_revision, newest_revision, ignored_revision_data_points,
regressions, requested_width, requested_height, title)
+ if appengine_url:
+ write_to_appengine(lines, appengine_url, newest_revision,
+ platform_and_alg)
+
check_expectations(lines, bench_expectations, newest_revision,
platform_and_alg)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698