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

Unified Diff: slave/skia_slave_scripts/upload_bench_results.py

Issue 304393002: Adds uploading picture benchmark JSON data (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: Created 6 years, 7 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
Index: slave/skia_slave_scripts/upload_bench_results.py
diff --git a/slave/skia_slave_scripts/upload_bench_results.py b/slave/skia_slave_scripts/upload_bench_results.py
index 94d52058a4aeda7207bb2ca8ef23d8c2f241a5c8..548c22930c8a5c87c082cc0b8d80060a1f595ca0 100755
--- a/slave/skia_slave_scripts/upload_bench_results.py
+++ b/slave/skia_slave_scripts/upload_bench_results.py
@@ -8,6 +8,8 @@
from build_step import BuildStep
from utils import sync_bucket_subdir
+import builder_name_schema
+
import json
import os
import os.path
@@ -17,6 +19,34 @@ import sys
from datetime import datetime
+# Modified from Skia repo code
benchen 2014/05/29 22:20:09 Please add the original file name/location to the
kelvinly 2014/05/30 00:44:51 Done.
kelvinly 2014/05/30 00:44:51 Done.
+def ReadExpectations(filename):
+ """Reads expectations data from file."""
+ expectations = {}
+ unstripped_keys = []
+ for expectation in open(filename).readlines():
+ elements = expectation.strip().split(',')
+ if not elements[0] or elements[0].startswith('#'):
+ continue
+ if len(elements) != 5:
+ raise Exception("Invalid expectation line format: %s" %
+ expectation)
+ bench_entry = elements[0] + ',' + elements[1]
+ if bench_entry in unstripped_keys:
+ raise Exception("Dup entries for bench expectation %s" %
+ bench_entry)
+ # bench_entry: [<Bench_BmpConfig_TimeType>,<Platform-Alg>]
benchen 2014/05/29 22:20:09 This and the comment below were legacy codes with
kelvinly 2014/05/30 00:44:51 I find the last comment fairly helpful though, wha
benchen 2014/05/30 00:57:23 Just that it's not recommended style.. the format
kelvinly 2014/05/30 02:15:31 Done.
+ unstripped_keys.append(bench_entry) # Using this in case multiple lines
+ # share everything except for the
+ # algorithm and/or platform
+ entry = elements[0]
+ # [<Bench_BmpConfig_TimeType>] -> (LB, UB, EXPECTED)
+ expectations[entry] = (float(elements[-2]),
+ float(elements[-1]),
+ float(elements[-3]))
+ return expectations
+
+
class UploadBenchResults(BuildStep):
def __init__(self, attempts=5, **kwargs):
@@ -44,9 +74,87 @@ class UploadBenchResults(BuildStep):
do_upload=True,
do_download=False)
+ file_list = os.listdir(self._GetPerfDataDir())
+ expectations = {}
+
+ path_to_bench_expectations = os.path.join(
+ 'expectations',
+ 'bench',
+ 'bench_expectations_%s.txt' % builder_name_schema.GetWaterfallBot(
+ self._builder_name))
+ try:
+ expectations = ReadExpectations(path_to_bench_expectations)
+ except IOError:
+ print "Unable to open expectations file"
+
+ re_file_extract = re.compile(r'(^.*)\.skp.*$')
+ json_total = {}
+ pictures_timestamp = ''
+ for file_name in file_list:
+ # Find bench picture files, splice in expectation data
+ if not re.search('^bench_{}_data_skp_(.*)_([0-9]*)\.json$'.format(
+ self._got_revision), file_name):
+ continue
+ json_pictures_data = {}
+ if not pictures_timestamp:
+ pictures_timestamp = file_name.split('_')[-1].split('.json')[0]
+ full_file_name = os.path.join(self._GetPerfDataDir(), file_name)
+ with open(full_file_name) as json_pictures:
+ print 'Loading file {}'.format(file_name)
+ json_pictures_data = json.load(json_pictures)
+
+ if json_total:
+ json_total['benches'].extend(json_pictures_data['benches'])
+ else:
+ json_total = json_pictures_data
+
+ # Now add expectations to all keys
+ for bench in json_total['benches']:
+ for tileSet in bench['tileSets']:
+ search_for_name = re_file_extract.search(bench['name'])
+ if not search_for_name:
+ print 'Invalid bench name: {}'.format(bench['name'])
+ continue
+ key = '_'.join([
+ search_for_name.group(1)+'.skp',
+ tileSet['name'],
+ ''])
+ if key in expectations.keys():
+ (lower, upper, expected) = expectations[key]
+ tileSet['lower'] = lower
+ tileSet['upper'] = upper
+ tileSet['expected'] = expected
+ else:
+ print "Unable to find key: {}".format(key)
+
+ json_total['commitHash'] = self._got_revision
+ json_total['machine'] = self._builder_name
+
+ json_write_name = 'pictures_{}_{}.json'.format(self._got_revision,
benchen 2014/05/29 22:20:09 To be consistent, please use file name skpbench_*.
kelvinly 2014/05/30 00:44:51 Done.
+ pictures_timestamp)
+ full_json_write_name = os.path.join(self._GetPerfDataDir(), json_write_name)
+ with open(full_json_write_name, 'w') as json_picture_write:
+ json.dump(json_total, json_picture_write)
+
+ now = datetime.utcnow()
+ gs_json_path = '/'.join((str(now.year).zfill(4), str(now.month).zfill(2),
+ str(now.day).zfill(2), str(now.hour).zfill(2)))
+ gs_dir = 'pics-json/{}/{}'.format(gs_json_path, self._builder_name)
+ sync_bucket_subdir.SyncBucketSubdir(
+ directory=self._GetPerfDataDir(),
+ dest_gsbase=dest_gsbase,
+ subdir=gs_dir,
+ # TODO(kelvinly): Set up some way to configure this,
+ # rather than hard coding it
+ do_upload=True,
+ do_download=False,
+ exclude_json=False,
+ filenames_filter=
+ 'pictures_({})_[0-9]+\.json'.format(self._got_revision))
+
# Find and open JSON file to add in additional fields, then upload.
benchen 2014/05/29 22:20:09 This part is now microbench only. Should update th
kelvinly 2014/05/30 00:44:51 Done.
json_file_name = None
- file_list = os.listdir(self._GetPerfDataDir())
+
for file_name in file_list:
if re.search('microbench_({})_[0-9]+\.json'.format(self._got_revision),
file_name):
@@ -65,7 +173,6 @@ class UploadBenchResults(BuildStep):
with open(json_file_name, 'w') as json_file:
json.dump(json_data, json_file)
- now = datetime.utcnow()
gs_json_path = '/'.join((str(now.year).zfill(4), str(now.month).zfill(2),
str(now.day).zfill(2), str(now.hour).zfill(2)))
gs_dir = 'stats-json/{}/{}'.format(gs_json_path, self._builder_name)
@@ -77,6 +184,7 @@ class UploadBenchResults(BuildStep):
# rather than hard coding it
do_upload=True,
do_download=False,
+ exclude_json=False,
filenames_filter=
'microbench_({})_[0-9]+\.json'.format(self._got_revision))

Powered by Google App Engine
This is Rietveld 408576698