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

Unified Diff: tools/telemetry/examples/benchmarks/v8_metric.py

Issue 1368533002: [Telemetry] Add an example for adding an end to end Telemetry benchmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Kari's comments Created 5 years, 1 month 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
« no previous file with comments | « tools/telemetry/examples/benchmarks/v8_benchmark.py ('k') | tools/telemetry/examples/run_benchmark » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/examples/benchmarks/v8_metric.py
diff --git a/tools/telemetry/examples/benchmarks/v8_metric.py b/tools/telemetry/examples/benchmarks/v8_metric.py
new file mode 100644
index 0000000000000000000000000000000000000000..91efdadbd6fff96977469c936ba6a5c6cfdb768c
--- /dev/null
+++ b/tools/telemetry/examples/benchmarks/v8_metric.py
@@ -0,0 +1,42 @@
+# Copyright 2015 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.
+
+from telemetry.value import improvement_direction
+from telemetry.value import scalar
+from telemetry.web_perf.metrics import timeline_based_metric
+
+def _IsMessageLoopEvent(event):
+ return event.name.startswith('v8')
+
+
+class _AverageMessageLoopLatency(scalar.ScalarValue):
+ def __init__(self, value, page, tir_label, none_value_reason=None):
+ super(_AverageMessageLoopLatency, self).__init__(
+ page=page, name='avg_v8_events_latency', value=value,
+ tir_label=tir_label,
+ units='ms', improvement_direction=improvement_direction.DOWN,
+ description=('Average wall-time latency of message loop events during '
+ 'any of the interaction records\' time ranges'),
+ none_value_reason=none_value_reason)
+
+
+class MessageLoopLatencyMetric(timeline_based_metric.TimelineBasedMetric):
+
+ def AddResults(self, model, renderer_thread, interactions, results):
+ v8_events = []
+ for event in model.IterAllEvents(event_predicate=_IsMessageLoopEvent):
+ if timeline_based_metric.IsEventInInteractions(event, interactions):
+ v8_events.append(event)
+
+ if v8_events:
+ avg = (
+ sum(e.duration for e in v8_events)/len(v8_events))
+ results.AddValue(_AverageMessageLoopLatency(
+ value=avg, page=results.current_page,
+ tir_label=interactions[0].label))
+ else:
+ results.AddValue(_AverageMessageLoopLatency(
+ None, page=results.current_page,
+ tir_label=interactions[0].label,
+ none_value_reason='No v8 events found.'))
« no previous file with comments | « tools/telemetry/examples/benchmarks/v8_benchmark.py ('k') | tools/telemetry/examples/run_benchmark » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698