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

Side by Side Diff: tools/perf/metrics/timeline.py

Issue 23902027: telemetry: Make trace profiler work with trace-based benchmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add subset test for category filters. Created 7 years, 3 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
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 import collections 4 import collections
5 5
6 from metrics import Metric 6 from metrics import Metric
7 7
8 TRACING_MODE = 'tracing-mode' 8 TRACING_MODE = 'tracing-mode'
9 TIMELINE_MODE = 'timeline-mode' 9 TIMELINE_MODE = 'timeline-mode'
10 10
(...skipping 20 matching lines...) Expand all
31 def Stop(self, page, tab): 31 def Stop(self, page, tab):
32 if self._mode == TRACING_MODE: 32 if self._mode == TRACING_MODE:
33 # This creates an async trace event in the render process for tab that 33 # This creates an async trace event in the render process for tab that
34 # will allow us to find that tab during the AddTracingResultsForTab 34 # will allow us to find that tab during the AddTracingResultsForTab
35 # function. 35 # function.
36 tab.ExecuteJavaScript(""" 36 tab.ExecuteJavaScript("""
37 console.time("__loading_measurement_was_here__"); 37 console.time("__loading_measurement_was_here__");
38 console.timeEnd("__loading_measurement_was_here__"); 38 console.timeEnd("__loading_measurement_was_here__");
39 """) 39 """)
40 40
41 tab.browser.StopTracing() 41 trace_result = tab.browser.StopTracing()
42 trace_result = tab.browser.GetTraceResultAndReset()
43 self._model = trace_result.AsTimelineModel() 42 self._model = trace_result.AsTimelineModel()
44 events = [s for 43 events = [s for
45 s in self._model.GetAllEventsOfName( 44 s in self._model.GetAllEventsOfName(
46 '__loading_measurement_was_here__') 45 '__loading_measurement_was_here__')
47 if s.parent_slice == None] 46 if s.parent_slice == None]
48 assert len(events) == 1 47 assert len(events) == 1
49 self._thread_for_tab = events[0].start_thread 48 self._thread_for_tab = events[0].start_thread
50 else: 49 else:
51 tab.StopTimelineRecording() 50 tab.StopTimelineRecording()
52 self._model = tab.timeline_model 51 self._model = tab.timeline_model
53 self._thread_for_tab = self._model.GetAllThreads()[0] 52 self._thread_for_tab = self._model.GetAllThreads()[0]
54 53
55 def AddResults(self, tab, results): 54 def AddResults(self, tab, results):
56 assert self._model 55 assert self._model
57 56
58 events = self._thread_for_tab.all_slices 57 events = self._thread_for_tab.all_slices
59 58
60 events_by_name = collections.defaultdict(list) 59 events_by_name = collections.defaultdict(list)
61 for e in events: 60 for e in events:
62 events_by_name[e.name].append(e) 61 events_by_name[e.name].append(e)
63 62
64 for event_name, event_group in events_by_name.iteritems(): 63 for event_name, event_group in events_by_name.iteritems():
65 times = [event.self_time for event in event_group] 64 times = [event.self_time for event in event_group]
66 total = sum(times) 65 total = sum(times)
67 biggest_jank = max(times) 66 biggest_jank = max(times)
68 results.Add(event_name, 'ms', total) 67 results.Add(event_name, 'ms', total)
69 results.Add(event_name + '_max', 'ms', biggest_jank) 68 results.Add(event_name + '_max', 'ms', biggest_jank)
70 results.Add(event_name + '_avg', 'ms', total / len(times)) 69 results.Add(event_name + '_avg', 'ms', total / len(times))
71
OLDNEW
« no previous file with comments | « tools/perf/measurements/smoothness.py ('k') | tools/telemetry/telemetry/core/backends/browser_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698