Commit 3ed01bb1 authored by Mikhail Khokhlov's avatar Mikhail Khokhlov Committed by Commit Bot

[tools/perf] Aggregate .txt traces along with .json

Tracing agents like atrace produce traces with the '.txt' extension.
We need to aggregate them together with all other TBMv2 traces.

Bug: 1025037
Change-Id: I2d150a338e42f183f086122d3a49335efa085717
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1917373Reviewed-by: default avatarJuan Antonio Navarro Pérez <perezju@chromium.org>
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
Cr-Commit-Position: refs/heads/master@{#715691}
parent 726ec0d4
......@@ -50,6 +50,8 @@ to its format as follows:
|.json.gz | Gzipped json trace
|.pb | Proto trace
|.pb.gz | Gzipped proto trace
|.txt | Other (e.g. atrace)
|.txt.gz | Gzipped other
Note that this convention relates to the artifact name only, the actual file
stored in the host does not have to follow it.
......
......@@ -102,7 +102,7 @@ def ProcessTestResult(test_result, upload_bucket, results_label,
run_identifier, test_suite_start, should_compute_metrics,
max_num_values, test_path_format, trace_processor_path):
ConvertProtoTraces(test_result, trace_processor_path)
AggregateJsonTraces(test_result)
AggregateTBMv2Traces(test_result)
if upload_bucket is not None:
UploadArtifacts(test_result, upload_bucket, run_identifier)
......@@ -162,9 +162,10 @@ def _IsProtoTrace(trace_name):
(trace_name.endswith('.pb') or trace_name.endswith('.pb.gz')))
def _IsJsonTrace(trace_name):
def _IsTBMv2Trace(trace_name):
return (trace_name.startswith('trace/') and
(trace_name.endswith('.json') or trace_name.endswith('.json.gz')))
(trace_name.endswith('.json') or trace_name.endswith('.json.gz') or
trace_name.endswith('.txt') or trace_name.endswith('.txt.gz')))
def _BuildOutputPath(input_files, output_name):
......@@ -200,25 +201,26 @@ def ConvertProtoTraces(test_result, trace_processor_path):
}
def AggregateJsonTraces(test_result):
"""Replace individual json traces with an aggregate HTML trace.
def AggregateTBMv2Traces(test_result):
"""Replace individual non-proto traces with an aggregate HTML trace.
For a test result with json traces, generates an aggregate HTML trace. Removes
all entries for individual traces and adds one entry for aggregate one.
For a test result with non-proto traces, generates an aggregate HTML trace.
Removes all entries for individual traces and adds one entry for
the aggregate one.
"""
artifacts = test_result.get('outputArtifacts', {})
json_traces = [name for name in artifacts if _IsJsonTrace(name)]
if json_traces:
trace_files = [artifacts[name]['filePath'] for name in json_traces]
traces = [name for name in artifacts if _IsTBMv2Trace(name)]
if traces:
trace_files = [artifacts[name]['filePath'] for name in traces]
html_path = _BuildOutputPath(trace_files, compute_metrics.HTML_TRACE_NAME)
logging.info('%s: Aggregating json traces %s.',
logging.info('%s: Aggregating traces %s.',
test_result['testPath'], trace_files)
trace_data.SerializeAsHtml(trace_files, html_path)
artifacts[compute_metrics.HTML_TRACE_NAME] = {
'filePath': html_path,
'contentType': 'text/html',
}
for name in json_traces:
for name in traces:
del artifacts[name]
......
......@@ -90,20 +90,20 @@ class ResultsProcessorUnitTests(unittest.TestCase):
test_suite_start='2019-10-01T12:00:00.123456Z')
self.assertEqual(run_identifier, 'src_abc_123_20191001T120000_54321')
def testAggregateJsonTraces(self):
def testAggregateTBMv2Traces(self):
test_result = testing.TestResult(
'benchmark/story2',
output_artifacts={
'trace/1.json': testing.Artifact(
os.path.join('test_run', 'story2', 'trace', '1.json')),
'trace/2.json': testing.Artifact(
os.path.join('test_run', 'story2', 'trace', '2.json')),
'trace/2.txt': testing.Artifact(
os.path.join('test_run', 'story2', 'trace', '2.txt')),
},
)
serialize_method = 'tracing.trace_data.trace_data.SerializeAsHtml'
with mock.patch(serialize_method) as mock_serialize:
processor.AggregateJsonTraces(test_result)
processor.AggregateTBMv2Traces(test_result)
self.assertEqual(mock_serialize.call_count, 1)
trace_files, file_path = mock_serialize.call_args[0][:2]
......@@ -111,7 +111,7 @@ class ResultsProcessorUnitTests(unittest.TestCase):
set(trace_files),
set([
os.path.join('test_run', 'story2', 'trace', '1.json'),
os.path.join('test_run', 'story2', 'trace', '2.json'),
os.path.join('test_run', 'story2', 'trace', '2.txt'),
]),
)
self.assertEqual(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment