Chromium Code Reviews| 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..f1ba52c1e28a77200aad2bcc38d0431951eea6de |
| --- /dev/null |
| +++ b/scripts/slave/telemetry_utils.py |
| @@ -0,0 +1,65 @@ |
| +#! /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: |
| + (_, self._chart_filename) = tempfile.mkstemp() |
|
ghost stip (do not use)
2014/09/09 02:20:06
you may need to close the file handle here, I'm no
sullivan
2014/09/11 00:25:56
Done.
|
| + if not self._ref_chart_filename: |
| + (_, self._ref_chart_filename) = tempfile.mkstemp() |
| + return (['--chart-output-filename', self._chart_filename, |
| + '--ref-output-filename', self._ref_chart_filename]) |
|
ghost stip (do not use)
2014/09/09 02:20:06
I'm a bit confused about the ref output filename -
sullivan
2014/09/11 00:25:56
No, only if there is a ref build in telemery._Gene
|
| + |
| + 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): |
|
ghost stip (do not use)
2014/09/09 02:24:16
I don't think cleanup is called by runtest.py in t
sullivan
2014/09/11 00:25:56
Done.
|
| + try: |
| + os.remove(self._chart_filename) |
| + os.remove(self._ref_chart_filename) |
|
ghost stip (do not use)
2014/09/09 02:20:06
if the first one fails, we'll never get to the sec
sullivan
2014/09/11 00:25:56
Done.
|
| + 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 'TODO' |