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

Side by Side Diff: tools/perf/measurements/task_execution_time.py

Issue 636203002: Task Execution Duration metrics added as a new benchmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Individual page data no longer removed Created 6 years, 2 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 2014 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.core.platform import tracing_category_filter
6 from telemetry.core.platform import tracing_options
7 from telemetry.timeline.model import TimelineModel
8 from telemetry.page import page_test
9 from telemetry.util import statistics
10 from telemetry.value import scalar
11
12 _CATEGORIES = ['webkit.console',
13 'blink.console',
14 'benchmark',
15 'toplevel',
16 'blink',
17 'cc',
18 'v8']
19
20 _TIME_OUT_IN_SECONDS = 60
21 _NUMBER_OF_RESULTS_TO_DISPLAY = 10
22
23 class TaskExecutionTime(page_test.PageTest):
24 def __init__(self):
25 super(TaskExecutionTime, self).__init__('RunTaskExecutionTime')
26 self._renderer_thread = None
jdduke (slow) 2014/10/09 23:20:07 It's kind of a shame to expose only renderer threa
picksi1 2014/10/10 13:20:25 Let's look at expanding the scope later.
27
28 def WillNavigateToPage(self, page, tab):
29 category_filter = tracing_category_filter.TracingCategoryFilter()
30
31 for category in _CATEGORIES:
32 category_filter.AddIncludedCategory(category)
33
34 options = tracing_options.TracingOptions()
35 options.enable_chrome_trace = True
36
37 tab.browser.platform.tracing_controller.Start(
38 options, category_filter, _TIME_OUT_IN_SECONDS)
39
40 def DidRunActions(self, page, tab):
41 timeline_data = tab.browser.platform.tracing_controller.Stop()
42 timeline_model = TimelineModel(timeline_data=timeline_data)
43 self._renderer_thread = timeline_model.GetRendererThreadFromTabId(tab.id)
44
45 def ValidateAndMeasurePage(self, page, tab, results):
46 tasks = TaskExecutionTime.GetTasks(self._renderer_thread.parent)
47
48 sorted_tasks = sorted(tasks,
49 key = lambda slice: slice.median_self_duration, reverse = True)
Sami 2014/10/09 13:14:47 No spaces around '=' here.
picksi1 2014/10/10 13:20:25 Done.
50
51 for task in sorted_tasks[:_NUMBER_OF_RESULTS_TO_DISPLAY]:
52 results.AddValue(scalar.ScalarValue(
53 results.current_page,
54 task.key,
55 'ms',
56 task.median_self_duration,
57 description = 'Slowest tasks'))
58
59 @staticmethod
60 def GetTasks(process):
61 task_dictionary = {}
62 depth = 1
63 for parent, task_slice in enumerate(
64 process.IterAllSlicesOfName('MessageLoop::RunTask')):
65 ProcessTasksForSlice(task_dictionary, task_slice, depth, parent)
66 # Return dictionary flattened into a list
67 return task_dictionary.values()
68
Sami 2014/10/09 13:14:46 ditto
picksi1 2014/10/10 13:20:25 Done.
69 class SliceData:
70 def __init__(self, key, self_duration, total_duration, depth, parent):
71 self.key = key
72 self.count = 1
73
74 self.self_durations = [self_duration]
75 self.min_self_duration = self_duration
76 self.max_self_duration = self_duration
77
78 self.total_durations = [total_duration]
79 self.min_total_duration = total_duration
80 self.max_total_duration = total_duration
81
82 self.tree_location = [(depth, parent)]
83
84 def Update(self, self_duration, total_duration, depth, parent):
85 self.count += 1
86
87 self.self_durations.append(self_duration)
88 self.min_self_duration = min(self.min_self_duration, self_duration)
89 self.max_self_duration = max(self.max_self_duration, self_duration)
90
91 self.total_durations.append(total_duration)
92 self.min_total_duration = min(self.min_total_duration, total_duration)
93 self.max_total_duration = max(self.max_total_duration, total_duration)
94
95 self.tree_location.append((depth, parent))
96
97 @property
98 def median_self_duration(self):
99 return statistics.Median(self.self_durations)
100
Sami 2014/10/09 13:14:46 ditto
picksi1 2014/10/10 13:20:24 Done.
101 def ProcessTasksForSlice(dictionary, task_slice, depth, parent):
102 # Deal with TRACE_EVENT_INSTANTs that have no duration
103 self_duration = task_slice.self_thread_time or 0.0
104 total_duration = task_slice.thread_duration or 0.0
105
106 # There is at least one task that is tracked as both uppercase and lowercase,
107 # forcing the name to lowercase coalesces both.
108 key = task_slice.name.lower()
109 if key in dictionary:
110 dictionary[key].Update(
111 self_duration, total_duration, depth, parent)
112 else:
113 dictionary[key] = SliceData(
114 key, self_duration, total_duration, depth, parent)
115
116 # Process sub slices recursively
117 for sub_slice in task_slice.sub_slices:
118 ProcessTasksForSlice(dictionary, sub_slice, depth + 1, parent)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698