OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 from telemetry.core.platform import tracing_category_filter | 5 from telemetry.core.platform import tracing_category_filter |
6 from telemetry.core.platform import tracing_options | 6 from telemetry.core.platform import tracing_options |
7 from telemetry.page import page_test | 7 from telemetry.page import page_test |
8 from telemetry.timeline.model import TimelineModel | 8 from telemetry.timeline.model import TimelineModel |
9 from telemetry.util import statistics | 9 from telemetry.util import statistics |
10 from telemetry.value import scalar | 10 from telemetry.value import scalar |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 # percentage of time. | 89 # percentage of time. |
90 inside_idle = event.thread_duration * statistics.DivideIfPossibleOrZero( | 90 inside_idle = event.thread_duration * statistics.DivideIfPossibleOrZero( |
91 event.duration - idle_task_wall_overrun, event.duration) | 91 event.duration - idle_task_wall_overrun, event.duration) |
92 event_stat.thread_duration_inside_idle += inside_idle | 92 event_stat.thread_duration_inside_idle += inside_idle |
93 event_stat.idle_task_overrun_duration += idle_task_wall_overrun | 93 event_stat.idle_task_overrun_duration += idle_task_wall_overrun |
94 | 94 |
95 for v8_event_stat in self._v8_event_stats: | 95 for v8_event_stat in self._v8_event_stats: |
96 results.AddValue(scalar.ScalarValue( | 96 results.AddValue(scalar.ScalarValue( |
97 results.current_page, v8_event_stat.result_name, 'ms', | 97 results.current_page, v8_event_stat.result_name, 'ms', |
98 v8_event_stat.thread_duration, | 98 v8_event_stat.thread_duration, |
99 ('Total thread duration spent in %s' % | 99 description=('Total thread duration spent in %s' % |
100 v8_event_stat.result_description))) | 100 v8_event_stat.result_description))) |
101 results.AddValue(scalar.ScalarValue(results.current_page, | 101 results.AddValue(scalar.ScalarValue(results.current_page, |
102 '%s_outside_idle' % v8_event_stat.result_name, 'ms', | 102 '%s_outside_idle' % v8_event_stat.result_name, 'ms', |
103 v8_event_stat.thread_duration_outside_idle, | 103 v8_event_stat.thread_duration_outside_idle, |
104 ('Total thread duration spent in %s outside of idle tasks' % | 104 description=( |
105 v8_event_stat.result_description))) | 105 'Total thread duration spent in %s outside of idle tasks' % |
| 106 v8_event_stat.result_description))) |
106 results.AddValue(scalar.ScalarValue(results.current_page, | 107 results.AddValue(scalar.ScalarValue(results.current_page, |
107 '%s_idle_deadline_overrun' % v8_event_stat.result_name, 'ms', | 108 '%s_idle_deadline_overrun' % v8_event_stat.result_name, 'ms', |
108 v8_event_stat.idle_task_overrun_duration, | 109 v8_event_stat.idle_task_overrun_duration, |
109 ('Total idle task deadline overrun for %s idle tasks' | 110 description=('Total idle task deadline overrun for %s idle tasks' |
110 % v8_event_stat.result_description))) | 111 % v8_event_stat.result_description))) |
111 results.AddValue(scalar.ScalarValue(results.current_page, | 112 results.AddValue(scalar.ScalarValue(results.current_page, |
112 '%s_percentage_idle' % v8_event_stat.result_name, 'idle%', | 113 '%s_percentage_idle' % v8_event_stat.result_name, 'idle%', |
113 v8_event_stat.percentage_thread_duration_during_idle, | 114 v8_event_stat.percentage_thread_duration_during_idle, |
114 ('Percentage of %s spent in idle time' % | 115 description=('Percentage of %s spent in idle time' % |
115 v8_event_stat.result_description))) | 116 v8_event_stat.result_description))) |
116 | 117 |
117 # Add total metrics. | 118 # Add total metrics. |
118 gc_total = sum(x.thread_duration for x in self._v8_event_stats) | 119 gc_total = sum(x.thread_duration for x in self._v8_event_stats) |
119 gc_total_outside_idle = sum( | 120 gc_total_outside_idle = sum( |
120 x.thread_duration_outside_idle for x in self._v8_event_stats) | 121 x.thread_duration_outside_idle for x in self._v8_event_stats) |
121 gc_total_idle_deadline_overrun = sum( | 122 gc_total_idle_deadline_overrun = sum( |
122 x.idle_task_overrun_duration for x in self._v8_event_stats) | 123 x.idle_task_overrun_duration for x in self._v8_event_stats) |
123 gc_total_percentage_idle = statistics.DivideIfPossibleOrZero( | 124 gc_total_percentage_idle = statistics.DivideIfPossibleOrZero( |
124 100 * (gc_total - gc_total_outside_idle), gc_total) | 125 100 * (gc_total - gc_total_outside_idle), gc_total) |
125 | 126 |
126 results.AddValue(scalar.ScalarValue(results.current_page, | 127 results.AddValue(scalar.ScalarValue(results.current_page, |
127 'v8_gc_total', 'ms', gc_total, | 128 'v8_gc_total', 'ms', gc_total, |
128 'Total thread duration of all garbage collection events')) | 129 description='Total thread duration of all garbage collection events')) |
129 results.AddValue(scalar.ScalarValue(results.current_page, | 130 results.AddValue(scalar.ScalarValue(results.current_page, |
130 'v8_gc_total_outside_idle', 'ms', gc_total_outside_idle, | 131 'v8_gc_total_outside_idle', 'ms', gc_total_outside_idle, |
131 'Total thread duration of all garbage collection events outside of ' | 132 description=( |
132 'idle tasks')) | 133 'Total thread duration of all garbage collection events outside of ' |
| 134 'idle tasks'))) |
133 results.AddValue(scalar.ScalarValue(results.current_page, | 135 results.AddValue(scalar.ScalarValue(results.current_page, |
134 'v8_gc_total_idle_deadline_overrun', 'ms', | 136 'v8_gc_total_idle_deadline_overrun', 'ms', |
135 gc_total_idle_deadline_overrun, | 137 gc_total_idle_deadline_overrun, |
136 'Total idle task deadline overrun for all idle tasks garbage ' | 138 description=( |
137 'collection events')) | 139 'Total idle task deadline overrun for all idle tasks garbage ' |
| 140 'collection events'))) |
138 results.AddValue(scalar.ScalarValue(results.current_page, | 141 results.AddValue(scalar.ScalarValue(results.current_page, |
139 'v8_gc_total_percentage_idle', 'idle%', gc_total_percentage_idle, | 142 'v8_gc_total_percentage_idle', 'idle%', gc_total_percentage_idle, |
140 'Percentage of the thread duration of all garbage collection events ' | 143 description=( |
141 'spent inside of idle tasks')) | 144 'Percentage of the thread duration of all garbage collection ' |
| 145 'events spent inside of idle tasks'))) |
142 | 146 |
143 def _AddCpuTimeStatsToResults(self, thread, results): | 147 def _AddCpuTimeStatsToResults(self, thread, results): |
144 if thread.toplevel_slices: | 148 if thread.toplevel_slices: |
145 start_time = min(s.start for s in thread.toplevel_slices) | 149 start_time = min(s.start for s in thread.toplevel_slices) |
146 end_time = max(s.end for s in thread.toplevel_slices) | 150 end_time = max(s.end for s in thread.toplevel_slices) |
147 duration = end_time - start_time | 151 duration = end_time - start_time |
148 cpu_time = sum(s.thread_duration for s in thread.toplevel_slices) | 152 cpu_time = sum(s.thread_duration for s in thread.toplevel_slices) |
149 else: | 153 else: |
150 duration = cpu_time = 0 | 154 duration = cpu_time = 0 |
151 | 155 |
(...skipping 30 matching lines...) Expand all Loading... |
182 self.idle_task_overrun_duration = 0.0 | 186 self.idle_task_overrun_duration = 0.0 |
183 | 187 |
184 @property | 188 @property |
185 def thread_duration_outside_idle(self): | 189 def thread_duration_outside_idle(self): |
186 return self.thread_duration - self.thread_duration_inside_idle | 190 return self.thread_duration - self.thread_duration_inside_idle |
187 | 191 |
188 @property | 192 @property |
189 def percentage_thread_duration_during_idle(self): | 193 def percentage_thread_duration_during_idle(self): |
190 return statistics.DivideIfPossibleOrZero( | 194 return statistics.DivideIfPossibleOrZero( |
191 100 * self.thread_duration_inside_idle, self.thread_duration) | 195 100 * self.thread_duration_inside_idle, self.thread_duration) |
OLD | NEW |