aboutsummaryrefslogtreecommitdiff
path: root/crosperf/results_cache.py
diff options
context:
space:
mode:
authorJian Cai <jiancai@google.com>2019-07-06 11:49:37 -0700
committerJian Cai <jiancai@google.com>2019-07-09 23:24:06 +0000
commit214078cfe75c610c6823cda46a2c5705b1bbd607 (patch)
tree7dfb62c9503993f9cd51a15665ee79538df8d378 /crosperf/results_cache.py
parent38f3c42a535f0ec2d845c6e299738a4a1996f646 (diff)
downloadtoolchain-utils-214078cfe75c610c6823cda46a2c5705b1bbd607.tar.gz
toolchain-utils: migrate Telemetry tests results from chartjson to histograms
Shift to histograms as charjson format is being deprected for Telemtry tests BUG=chromium:967868 TEST=Local tests. Change-Id: I0645c6f10a93a454cc50090d2b790c9f386d9358 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1691318 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: Jian Cai <jiancai@google.com>
Diffstat (limited to 'crosperf/results_cache.py')
-rw-r--r--crosperf/results_cache.py59
1 files changed, 51 insertions, 8 deletions
diff --git a/crosperf/results_cache.py b/crosperf/results_cache.py
index bef78cb4..54569808 100644
--- a/crosperf/results_cache.py
+++ b/crosperf/results_cache.py
@@ -251,6 +251,8 @@ class Result(object):
return out
def GetResultsFile(self):
+ if self.suite == 'telemetry_Crosperf':
+ return self.FindFilesInResultsDir('-name histograms.json').splitlines()
return self.FindFilesInResultsDir('-name results-chart.json').splitlines()
def GetPerfDataFiles(self):
@@ -262,8 +264,12 @@ class Result(object):
def GetDataMeasurementsFiles(self):
result = self.FindFilesInResultsDir('-name perf_measurements').splitlines()
if not result:
- result = \
- self.FindFilesInResultsDir('-name results-chart.json').splitlines()
+ if self.suite == 'telemetry_Crosperf':
+ result = \
+ self.FindFilesInResultsDir('-name histograms.json').splitlines()
+ else:
+ result = \
+ self.FindFilesInResultsDir('-name results-chart.json').splitlines()
return result
def _CheckDebugPath(self, option, path):
@@ -367,16 +373,15 @@ class Result(object):
# Grab keyvals from the directory.
self.ProcessResults()
- def ProcessJsonResults(self):
+ def ProcessChartResults(self):
# Open and parse the json results file generated by telemetry/test_that.
if not self.results_file:
raise IOError('No results file found.')
filename = self.results_file[0]
if not filename.endswith('.json'):
raise IOError('Attempt to call json on non-json file: %s' % filename)
-
if not os.path.exists(filename):
- return {}
+ raise IOError('%s does not exist' % filename)
keyvals = {}
with open(filename, 'r') as f:
@@ -406,13 +411,51 @@ class Result(object):
keyvals[keyname] = new_value
return keyvals
+ def ProcessHistogramsResults(self):
+ # Open and parse the json results file generated by telemetry/test_that.
+ if not self.results_file:
+ raise IOError('No results file found.')
+ filename = self.results_file[0]
+ if not filename.endswith('.json'):
+ raise IOError('Attempt to call json on non-json file: %s' % filename)
+ if not os.path.exists(filename):
+ raise IOError('%s does not exist' % filename)
+
+ keyvals = {}
+ with open(filename) as f:
+ histograms = json.loads(f)
+ for obj in histograms:
+ if 'name' not in obj or 'sampleValues' not in obj:
+ continue
+ metric_name = obj['name']
+ vals = obj['sampleValues']
+ if isinstance(vals, list):
+ result = float(sum(vals)) / len(vals)
+ else:
+ result = vals
+ unit = obj['unit']
+ if metric_name not in keyvals:
+ keyvals[metric_name] = [[result], unit]
+ else:
+ # in case the benchmark has multiple stories
+ keyvals[metric_name][0].append(result)
+ for metric_name in keyvals:
+ vals = keyvals[metric_name][0]
+ unit = keyvals[metric_name][1]
+ result = float(sum(vals)) / len(vals)
+ keyvals[metric_name] = [result, unit]
+ return keyvals
+
def ProcessResults(self, use_cache=False):
# Note that this function doesn't know anything about whether there is a
# cache hit or miss. It should process results agnostic of the cache hit
# state.
- if self.results_file and self.results_file[0].find(
- 'results-chart.json') != -1:
- self.keyvals = self.ProcessJsonResults()
+ if self.results_file and self.suite == 'telemetry_Crosperf' and \
+ 'histograms.json' in self.results_file[0]:
+ self.keyvals = self.ProcessHistogramsResults()
+ elif self.results_file and self.suite != 'telemetry_Crosperf' and \
+ 'results-chart.json' in self.results_file[0]:
+ self.keyvals = self.ProcessChartResults()
else:
if not use_cache:
print('\n ** WARNING **: Had to use deprecated output-method to '