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

Unified Diff: scripts/slave/telemetry_utils.py

Issue 545803002: Update buildbots to parse new telemetry JSON format. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Added unit tests and removed debugging code Created 6 years, 3 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: scripts/slave/telemetry_utils.py
diff --git a/scripts/slave/telemetry_utils.py b/scripts/slave/telemetry_utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..bd5a72de544dff2fdbd56afe01f1559fd4f851fe
--- /dev/null
+++ b/scripts/slave/telemetry_utils.py
@@ -0,0 +1,71 @@
+# pylint: disable=R0201
ghost stip (do not use) 2014/09/12 18:17:25 nit: move pylint declaration below copyright
sullivan 2014/09/12 19:14:21 Done.
+#! /usr/bin/env python
+# Copyright (c) 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Log parsing for telemetry tests."""
+
+import json
+import logging
+import os
+import tempfile
+
+
+class TelemetryResultsTracker(object):
+
+ def __init__(self):
+ self._chart_filename = None
+ self._ref_chart_filename = None
+
+ def GetArguments(self):
+ if not self._chart_filename:
+ (handle, self._chart_filename) = tempfile.mkstemp()
+ os.close(handle)
+ if not self._ref_chart_filename:
+ (handle, self._ref_chart_filename) = tempfile.mkstemp()
+ os.close(handle)
+ return (['--chart-output-filename', self._chart_filename,
+ '--ref-output-filename', self._ref_chart_filename])
+
+ def _GetFileJson(self, filename):
+ try:
+ return json.loads(open(filename).read())
+ except (IOError, ValueError):
+ logging.error('Error reading telemetry results from %s', filename)
+ return None
+
+ def ChartJson(self):
+ return self._GetFileJson(self._chart_filename)
+
+ def RefJson(self):
+ return self._GetFileJson(self._ref_chart_filename)
+
+ def Cleanup(self):
+ try:
+ os.remove(self._chart_filename)
+ except OSError:
+ pass
+ try:
+ os.remove(self._ref_chart_filename)
+ except OSError:
+ pass
+
+ def IsChartJson(self):
+ """This is the new telemetry --chartjson output format."""
+ return True
+
+ def ProcessLine(self, line):
+ pass
+
+ def FailedTests(self):
+ return []
+
+ def SuppressionHashes(self): # pylint: disable=R0201
+ return []
+
+ def ParsingErrors(self): # pylint: disable=R0201
+ return []
+
+ def PerformanceSummary(self):
+ return ''

Powered by Google App Engine
This is Rietveld 408576698