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

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: White space fix + removal of debug code 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 class TaskExecutionTime(page_test.PageTest):
21
22 _TIME_OUT_IN_SECONDS = 60
23 _NUMBER_OF_RESULTS_TO_DISPLAY = 10
24
25 def __init__(self):
26 super(TaskExecutionTime, self).__init__('RunTaskExecutionTime')
27 self._renderer_thread = None
28
29 def WillNavigateToPage(self, page, tab):
30 category_filter = tracing_category_filter.TracingCategoryFilter()
31
32 for category in _CATEGORIES:
33 category_filter.AddIncludedCategory(category)
34
35 options = tracing_options.TracingOptions()
36 options.enable_chrome_trace = True
37
38 tab.browser.platform.tracing_controller.Start(
39 options, category_filter, self._TIME_OUT_IN_SECONDS)
40
41 def DidRunActions(self, page, tab):
42 timeline_data = tab.browser.platform.tracing_controller.Stop()
43 timeline_model = TimelineModel(timeline_data=timeline_data)
44 self._renderer_thread = timeline_model.GetRendererThreadFromTabId(tab.id)
45
46 def ValidateAndMeasurePage(self, page, tab, results):
47 tasks = TaskExecutionTime.GetTasks(self._renderer_thread.parent)
48
49 sorted_tasks = sorted(tasks,
50 key=lambda slice: slice.median_self_duration, reverse=True)
51
52 for task in sorted_tasks[:self.GetExpectedResultCount()]:
53 results.AddValue(scalar.ScalarValue(
54 results.current_page,
55 task.key,
56 'ms',
57 task.median_self_duration,
58 description = 'Slowest tasks'))
59
60 @staticmethod
61 def GetTasks(process):
62 task_dictionary = {}
63 depth = 1
64 for parent, task_slice in enumerate(
65 process.IterAllSlicesOfName('MessageLoop::RunTask')):
66 ProcessTasksForSlice(task_dictionary, task_slice, depth, parent)
67 # Return dictionary flattened into a list
68 return task_dictionary.values()
69
70 @staticmethod
71 def GetExpectedResultCount():
72 return TaskExecutionTime._NUMBER_OF_RESULTS_TO_DISPLAY
73
74
75 class SliceData:
76 def __init__(self, key, self_duration, total_duration, depth, parent):
77 self.key = key
78 self.count = 1
79
80 self.self_durations = [self_duration]
81 self.min_self_duration = self_duration
82 self.max_self_duration = self_duration
83
84 self.total_durations = [total_duration]
85 self.min_total_duration = total_duration
86 self.max_total_duration = total_duration
87
88 self.tree_location = [(depth, parent)]
89
90 def Update(self, self_duration, total_duration, depth, parent):
91 self.count += 1
92
93 self.self_durations.append(self_duration)
94 self.min_self_duration = min(self.min_self_duration, self_duration)
95 self.max_self_duration = max(self.max_self_duration, self_duration)
96
97 self.total_durations.append(total_duration)
98 self.min_total_duration = min(self.min_total_duration, total_duration)
99 self.max_total_duration = max(self.max_total_duration, total_duration)
100
101 self.tree_location.append((depth, parent))
102
103 @property
104 def median_self_duration(self):
105 return statistics.Median(self.self_durations)
106
107
108 def ProcessTasksForSlice(dictionary, task_slice, depth, parent):
109 # Deal with TRACE_EVENT_INSTANTs that have no duration
110 self_duration = task_slice.self_thread_time or 0.0
111 total_duration = task_slice.thread_duration or 0.0
112
113 # There is at least one task that is tracked as both uppercase and lowercase,
114 # forcing the name to lowercase coalesces both.
115 key = task_slice.name.lower()
116 if key in dictionary:
117 dictionary[key].Update(
118 self_duration, total_duration, depth, parent)
119 else:
120 dictionary[key] = SliceData(
121 key, self_duration, total_duration, depth, parent)
122
123 # Process sub slices recursively
124 for sub_slice in task_slice.sub_slices:
125 ProcessTasksForSlice(dictionary, sub_slice, depth + 1, parent)
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/task_execution_time.py ('k') | tools/perf/measurements/task_execution_time_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698