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

Side by Side Diff: tools/telemetry/telemetry/web_perf/metrics/fast_metric.py

Issue 395893002: Convert results.Add to results.AddValue for files in web_perf/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix styling nit Created 6 years, 5 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
« no previous file with comments | « no previous file | tools/telemetry/telemetry/web_perf/metrics/responsiveness_metric.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 from telemetry.timeline import bounds 7 from telemetry.timeline import bounds
8 from telemetry.value import scalar
8 from telemetry.web_perf import timeline_interaction_record as tir_module 9 from telemetry.web_perf import timeline_interaction_record as tir_module
9 from telemetry.web_perf.metrics import timeline_based_metric 10 from telemetry.web_perf.metrics import timeline_based_metric
10 11
11 12
12 class FastMetric(timeline_based_metric.TimelineBasedMetric): 13 class FastMetric(timeline_based_metric.TimelineBasedMetric):
13 def __init__(self): 14 def __init__(self):
14 super(FastMetric, self).__init__() 15 super(FastMetric, self).__init__()
15 16
16 def AddResults(self, model, renderer_thread, interaction_records, results): 17 def AddResults(self, model, renderer_thread, interaction_records, results):
17 """Add three results: duration, cpu_time, and idle_time. 18 """Add three results: duration, cpu_time, and idle_time.
18 19
19 duration is the total wall time for |interaction_records|. 20 duration is the total wall time for |interaction_records|.
20 cpu_time is the renderer thread time that intersects |interaction_records|. 21 cpu_time is the renderer thread time that intersects |interaction_records|.
21 idle time is wall time for |interaction_records| for which renderer slices 22 idle time is wall time for |interaction_records| for which renderer slices
22 do not overlap. Note that unscheduled renderer thread time is not 23 do not overlap. Note that unscheduled renderer thread time is not
23 counted. Idle time is time for which there was nothing to do. 24 counted. Idle time is time for which there was nothing to do.
24 25
25 Args: 26 Args:
26 model: a TimelineModule instance 27 model: a TimelineModule instance
27 renderer_thread: a telemetry.timeline.thread.Thread() instance 28 renderer_thread: a telemetry.timeline.thread.Thread() instance
28 interaction_records: an iterable of TimelineInteractionRecord instances 29 interaction_records: an iterable of TimelineInteractionRecord instances
29 results: an instance of page.PageTestResults 30 results: an instance of page.PageTestResults
30 """ 31 """
31 self.VerifyNonOverlappedRecords(interaction_records) 32 self.VerifyNonOverlappedRecords(interaction_records)
32 33
33 duration = sum(r.end - r.start for r in interaction_records) 34 duration = sum(r.end - r.start for r in interaction_records)
34 results.Add('fast-duration', 'ms', duration) 35 results.AddValue(scalar.ScalarValue(
36 results.current_page, 'fast-duration', 'ms', duration))
35 37
36 try: 38 try:
37 cpu_time = sum( 39 cpu_time = sum(
38 r.GetOverlappedThreadTimeForSlice(s) 40 r.GetOverlappedThreadTimeForSlice(s)
39 for r in interaction_records 41 for r in interaction_records
40 for s in renderer_thread.toplevel_slices) 42 for s in renderer_thread.toplevel_slices)
41 except tir_module.NoThreadTimeDataException: 43 except tir_module.NoThreadTimeDataException:
42 logging.warning( 44 logging.warning(
43 'Main thread cpu_time cannot be computed for records %s since ' 45 'Main thread cpu_time cannot be computed for records %s since '
44 'trace does not contain thread time data.', 46 'trace does not contain thread time data.',
45 repr(interaction_records)) 47 repr(interaction_records))
46 else: 48 else:
47 results.Add('fast-cpu_time', 'ms', cpu_time) 49 results.AddValue(scalar.ScalarValue(
50 results.current_page, 'fast-cpu_time', 'ms', cpu_time))
48 51
49 idle_time = duration - sum( 52 idle_time = duration - sum(
50 bounds.Bounds.GetOverlap(r.start, r.end, s.start, s.end) 53 bounds.Bounds.GetOverlap(r.start, r.end, s.start, s.end)
51 for r in interaction_records 54 for r in interaction_records
52 for s in renderer_thread.toplevel_slices) 55 for s in renderer_thread.toplevel_slices)
53 results.Add('fast-idle_time', 'ms', idle_time) 56 results.AddValue(scalar.ScalarValue(
57 results.current_page, 'fast-idle_time', 'ms', idle_time))
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/web_perf/metrics/responsiveness_metric.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698