Commit b229096e authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Fix generic_trace.py on multiple AddMeasurement() calls

generic_trace.py currently makes multiple calls to AddMeasurement()
with the same name if it encounters multiple trace items of the same
name. This is now broken, as patch [*] has forbidden that, and
requires caller to consolidate measurements of the same name into
a list.

This patch fixes generic_trace.py to follow the new requirements.

Change-Id: I44a0fbc1e4260bfbcbfc2558defd25a3f8cc3fb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899903
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarRavi Mistry <rmistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713187}
parent 6b6597ca
......@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from collections import defaultdict
from core import path_util
path_util.AddTracingToPath()
from core import perf_benchmark
......@@ -34,6 +36,7 @@ class _GenericTraceMeasurement(legacy_page_test.LegacyPageTest):
def ValidateAndMeasurePage(self, page, tab, results):
with tab.browser.platform.tracing_controller.StopTracing() as trace_builder:
trace_data = trace_builder.AsData()
measurements = defaultdict(list)
for trace in trace_data.GetTracesFor(trace_data_module.CHROME_TRACE_PART):
for event in trace['traceEvents']:
# We collect data from duration begin, complete, instant and count
......@@ -46,7 +49,9 @@ class _GenericTraceMeasurement(legacy_page_test.LegacyPageTest):
if not isinstance(arg_value, int):
continue
value_name = '/'.join([event['cat'], event['name'], arg_name])
results.AddMeasurement(value_name, 'count', arg_value)
measurements[value_name].append(arg_value)
for name, value in measurements.items():
results.AddMeasurement(name, 'count', value)
class _GenericTraceBenchmark(perf_benchmark.PerfBenchmark):
......
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