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

Side by Side Diff: tools/telemetry/examples/benchmarks/v8_metric.py

Issue 1647513002: Delete tools/telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from telemetry.value import improvement_direction
6 from telemetry.value import scalar
7 from telemetry.web_perf.metrics import timeline_based_metric
8
9 def _IsMessageLoopEvent(event):
10 return event.name.startswith('v8')
11
12
13 class _AverageMessageLoopLatency(scalar.ScalarValue):
14 def __init__(self, value, page, tir_label, none_value_reason=None):
15 super(_AverageMessageLoopLatency, self).__init__(
16 page=page, name='avg_v8_events_latency', value=value,
17 tir_label=tir_label,
18 units='ms', improvement_direction=improvement_direction.DOWN,
19 description=('Average wall-time latency of message loop events during '
20 'any of the interaction records\' time ranges'),
21 none_value_reason=none_value_reason)
22
23
24 class MessageLoopLatencyMetric(timeline_based_metric.TimelineBasedMetric):
25
26 def AddResults(self, model, renderer_thread, interactions, results):
27 v8_events = []
28 for event in model.IterAllEvents(event_predicate=_IsMessageLoopEvent):
29 if timeline_based_metric.IsEventInInteractions(event, interactions):
30 v8_events.append(event)
31
32 if v8_events:
33 avg = (
34 sum(e.duration for e in v8_events)/len(v8_events))
35 results.AddValue(_AverageMessageLoopLatency(
36 value=avg, page=results.current_page,
37 tir_label=interactions[0].label))
38 else:
39 results.AddValue(_AverageMessageLoopLatency(
40 None, page=results.current_page,
41 tir_label=interactions[0].label,
42 none_value_reason='No v8 events found.'))
OLDNEW
« no previous file with comments | « tools/telemetry/examples/benchmarks/v8_benchmark.py ('k') | tools/telemetry/examples/credentials_example.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698