Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 os | 5 import os |
| 6 | 6 |
| 7 from measurements import smoothness_controller | 7 from measurements import smoothness_controller |
| 8 from measurements import timeline_controller | 8 from measurements import timeline_controller |
| 9 from telemetry import benchmark | |
| 9 from telemetry.core.platform import tracing_category_filter | 10 from telemetry.core.platform import tracing_category_filter |
| 10 from telemetry.core.platform import tracing_options | 11 from telemetry.core.platform import tracing_options |
| 11 from telemetry.page import page_test | 12 from telemetry.page import page_test |
| 12 from telemetry.page.actions import action_runner | 13 from telemetry.page.actions import action_runner |
| 14 from telemetry.results import results_options | |
| 13 from telemetry.timeline.model import TimelineModel | 15 from telemetry.timeline.model import TimelineModel |
| 14 from telemetry.util import statistics | 16 from telemetry.util import statistics |
| 15 from telemetry.value import list_of_scalar_values | 17 from telemetry.value import list_of_scalar_values |
| 16 from telemetry.value import scalar | 18 from telemetry.value import scalar |
| 17 from telemetry.value import trace | 19 from telemetry.value import trace |
| 18 | 20 |
| 19 | 21 |
| 20 _CR_RENDERER_MAIN = 'CrRendererMain' | 22 _CR_RENDERER_MAIN = 'CrRendererMain' |
| 21 _RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' | 23 _RUN_SMOOTH_ACTIONS = 'RunSmoothAllActions' |
| 22 _NAMES_TO_DUMP = ['oilpan_precise_mark', | 24 _NAMES_TO_DUMP = ['oilpan_precise_mark', |
| 23 'oilpan_precise_lazy_sweep', | 25 'oilpan_precise_lazy_sweep', |
| 24 'oilpan_precise_complete_sweep', | 26 'oilpan_precise_complete_sweep', |
| 25 'oilpan_conservative_mark', | 27 'oilpan_conservative_mark', |
| 26 'oilpan_conservative_lazy_sweep', | 28 'oilpan_conservative_lazy_sweep', |
| 27 'oilpan_conservative_complete_sweep', | 29 'oilpan_conservative_complete_sweep', |
| 28 'oilpan_coalesce'] | 30 'oilpan_coalesce'] |
| 29 | 31 |
| 30 def _AddTracingResults(events, results): | 32 def _AddTracingResults(events, include_forced_gc, results): |
| 31 # Prepare | 33 # Prepare |
| 32 values = {} | 34 values = {} |
| 33 for name in _NAMES_TO_DUMP: | 35 for name in _NAMES_TO_DUMP: |
| 34 values[name] = [] | 36 values[name] = [] |
| 35 | 37 |
| 36 # Parse in time line | 38 # Parse in time line |
| 37 gc_type = None | 39 gc_type = None |
| 38 forced = False | 40 forced = False |
| 39 mark_time = 0 | 41 mark_time = 0 |
| 40 lazy_sweep_time = 0 | 42 lazy_sweep_time = 0 |
| 41 complete_sweep_time = 0 | 43 complete_sweep_time = 0 |
| 42 for event in events: | 44 for event in events: |
| 43 duration = event.thread_duration or event.duration | 45 duration = event.thread_duration or event.duration |
| 44 if event.name == 'ThreadHeap::coalesce': | 46 if event.name == 'ThreadHeap::coalesce': |
| 45 values['oilpan_coalesce'].append(duration) | 47 values['oilpan_coalesce'].append(duration) |
| 46 continue | 48 continue |
| 47 if event.name == 'Heap::collectGarbage': | 49 if event.name == 'Heap::collectGarbage': |
| 48 if not gc_type is None and not forced: | 50 if not gc_type is None and (not forced or include_forced_gc): |
| 49 values['oilpan_%s_mark' % gc_type].append(mark_time) | 51 values['oilpan_%s_mark' % gc_type].append(mark_time) |
| 50 values['oilpan_%s_lazy_sweep' % gc_type].append(lazy_sweep_time) | 52 values['oilpan_%s_lazy_sweep' % gc_type].append(lazy_sweep_time) |
| 51 values['oilpan_%s_complete_sweep' % gc_type].append(complete_sweep_time) | 53 values['oilpan_%s_complete_sweep' % gc_type].append(complete_sweep_time) |
| 52 | 54 |
| 53 gc_type = 'precise' if event.args['precise'] else 'conservative' | 55 gc_type = 'precise' if event.args['precise'] else 'conservative' |
| 54 forced = event.args['forced'] | 56 forced = event.args['forced'] |
| 55 mark_time = duration | 57 mark_time = duration |
| 56 lazy_sweep_time = 0 | 58 lazy_sweep_time = 0 |
| 57 complete_sweep_time = 0 | 59 complete_sweep_time = 0 |
| 58 continue | 60 continue |
| 59 if event.name == 'ThreadHeap::lazySweepPages': | 61 if event.name == 'ThreadHeap::lazySweepPages': |
| 60 lazy_sweep_time += duration | 62 lazy_sweep_time += duration |
| 61 continue | 63 continue |
| 62 if event.name == 'ThreadState::completeSweep': | 64 if event.name == 'ThreadState::completeSweep': |
| 63 complete_sweep_time += duration | 65 complete_sweep_time += duration |
| 64 continue | 66 continue |
| 65 | 67 |
| 66 if not gc_type is None and not forced: | 68 if not gc_type is None and (not forced or include_forced_gc): |
| 67 values['oilpan_%s_mark' % gc_type].append(mark_time) | 69 values['oilpan_%s_mark' % gc_type].append(mark_time) |
| 68 values['oilpan_%s_lazy_sweep' % gc_type].append(lazy_sweep_time) | 70 values['oilpan_%s_lazy_sweep' % gc_type].append(lazy_sweep_time) |
| 69 values['oilpan_%s_complete_sweep' % gc_type].append(complete_sweep_time) | 71 values['oilpan_%s_complete_sweep' % gc_type].append(complete_sweep_time) |
| 70 | 72 |
| 71 # Dump | 73 # Dump |
| 72 page = results.current_page | 74 page = results.current_page |
| 73 unit = 'ms' | 75 unit = 'ms' |
| 74 for name in _NAMES_TO_DUMP: | 76 for name in _NAMES_TO_DUMP: |
| 75 if values[name]: | 77 if values[name]: |
| 76 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 78 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 99 results.AddValue( | 101 results.AddValue( |
| 100 scalar.ScalarValue(page, 'oilpan_sweep', unit, total_sweep_time)) | 102 scalar.ScalarValue(page, 'oilpan_sweep', unit, total_sweep_time)) |
| 101 | 103 |
| 102 gc_time = 0 | 104 gc_time = 0 |
| 103 for key in values: | 105 for key in values: |
| 104 gc_time += sum(values[key]) | 106 gc_time += sum(values[key]) |
| 105 results.AddValue(scalar.ScalarValue(page, 'oilpan_gc', unit, gc_time)) | 107 results.AddValue(scalar.ScalarValue(page, 'oilpan_gc', unit, gc_time)) |
| 106 | 108 |
| 107 | 109 |
| 108 class _OilpanGCTimesBase(page_test.PageTest): | 110 class _OilpanGCTimesBase(page_test.PageTest): |
| 109 def __init__(self, action_name = ''): | 111 def __init__(self, action_name='', include_forced_gc=False): |
| 110 super(_OilpanGCTimesBase, self).__init__(action_name) | 112 super(_OilpanGCTimesBase, self).__init__(action_name) |
| 111 self._timeline_model = None | 113 self._timeline_model = None |
| 114 self._include_forced_gc = include_forced_gc | |
| 112 | 115 |
| 113 def WillNavigateToPage(self, page, tab): | 116 def WillNavigateToPage(self, page, tab): |
| 114 # FIXME: Remove webkit.console when blink.console lands in chromium and | 117 # FIXME: Remove webkit.console when blink.console lands in chromium and |
| 115 # the ref builds are updated. crbug.com/386847 | 118 # the ref builds are updated. crbug.com/386847 |
| 116 categories = ['webkit.console', 'blink.console', 'blink_gc'] | 119 categories = ['webkit.console', 'blink.console', 'blink_gc'] |
| 117 category_filter = tracing_category_filter.TracingCategoryFilter() | 120 category_filter = tracing_category_filter.TracingCategoryFilter() |
| 118 for c in categories: | 121 for c in categories: |
| 119 category_filter.AddIncludedCategory(c) | 122 category_filter.AddIncludedCategory(c) |
| 120 options = tracing_options.TracingOptions() | 123 options = tracing_options.TracingOptions() |
| 121 options.enable_chrome_trace = True | 124 options.enable_chrome_trace = True |
| 122 tab.browser.platform.tracing_controller.Start(options, category_filter, | 125 tab.browser.platform.tracing_controller.Start(options, category_filter, |
| 123 timeout=1000) | 126 timeout=1000) |
| 124 | 127 |
| 125 def DidRunActions(self, page, tab): | 128 def DidRunActions(self, page, tab): |
| 126 timeline_data = tab.browser.platform.tracing_controller.Stop() | 129 timeline_data = tab.browser.platform.tracing_controller.Stop() |
| 127 self._timeline_model = TimelineModel(timeline_data) | 130 self._timeline_model = TimelineModel(timeline_data) |
| 128 | 131 |
| 129 def ValidateAndMeasurePage(self, page, tab, results): | 132 def ValidateAndMeasurePage(self, page, tab, results): |
| 130 threads = self._timeline_model.GetAllThreads() | 133 threads = self._timeline_model.GetAllThreads() |
| 131 for thread in threads: | 134 for thread in threads: |
| 132 if thread.name == _CR_RENDERER_MAIN: | 135 if thread.name == _CR_RENDERER_MAIN: |
| 133 _AddTracingResults(thread.all_slices, results) | 136 _AddTracingResults(thread.all_slices, self._include_forced_gc, results) |
| 134 | 137 |
| 135 def CleanUpAfterPage(self, page, tab): | 138 def CleanUpAfterPage(self, page, tab): |
| 136 if tab.browser.platform.tracing_controller.is_tracing_running: | 139 if tab.browser.platform.tracing_controller.is_tracing_running: |
| 137 tab.browser.platform.tracing_controller.Stop() | 140 tab.browser.platform.tracing_controller.Stop() |
| 138 | 141 |
| 142 def _ParseEventsForTest(self, events, include_forced_gc, options): | |
|
Sami
2015/03/09 16:29:52
Instead of adding this helper here, could we follo
peria
2015/04/02 08:26:01
Done.
| |
| 143 options.output_dir = None | |
| 144 options.output_formats = ['none'] | |
| 145 options.suppress_gtest_report = True | |
| 146 options.output_trace_tag = None | |
| 147 results = results_options.CreateResults( | |
| 148 benchmark.BenchmarkMetadata(''), options) | |
| 149 # No pages are running in this test. | |
| 150 results.WillRunPage(None) | |
| 151 _AddTracingResults(events, include_forced_gc, results) | |
| 152 return results | |
| 153 | |
| 139 | 154 |
| 140 class OilpanGCTimesForSmoothness(_OilpanGCTimesBase): | 155 class OilpanGCTimesForSmoothness(_OilpanGCTimesBase): |
| 141 def __init__(self): | 156 def __init__(self): |
| 142 super(OilpanGCTimesForSmoothness, self).__init__('RunPageInteractions') | 157 super(OilpanGCTimesForSmoothness, self).__init__('RunPageInteractions') |
| 143 self._interaction = None | 158 self._interaction = None |
| 144 | 159 |
| 145 def WillRunActions(self, page, tab): | 160 def WillRunActions(self, page, tab): |
| 146 runner = action_runner.ActionRunner(tab) | 161 runner = action_runner.ActionRunner(tab) |
| 147 self._interaction = runner.BeginInteraction(_RUN_SMOOTH_ACTIONS, | 162 self._interaction = runner.BeginInteraction(_RUN_SMOOTH_ACTIONS, |
| 148 is_smooth=True) | 163 is_smooth=True) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 163 page.script_to_evaluate_on_commit = self._blink_perf_js | 178 page.script_to_evaluate_on_commit = self._blink_perf_js |
| 164 super(OilpanGCTimesForBlinkPerf, self).WillNavigateToPage(page, tab) | 179 super(OilpanGCTimesForBlinkPerf, self).WillNavigateToPage(page, tab) |
| 165 | 180 |
| 166 def DidRunActions(self, page, tab): | 181 def DidRunActions(self, page, tab): |
| 167 tab.WaitForJavaScriptExpression('testRunner.isDone', 600) | 182 tab.WaitForJavaScriptExpression('testRunner.isDone', 600) |
| 168 super(OilpanGCTimesForBlinkPerf, self).DidRunActions(page, tab) | 183 super(OilpanGCTimesForBlinkPerf, self).DidRunActions(page, tab) |
| 169 | 184 |
| 170 | 185 |
| 171 class OilpanGCTimesForInternals(_OilpanGCTimesBase): | 186 class OilpanGCTimesForInternals(_OilpanGCTimesBase): |
| 172 def __init__(self): | 187 def __init__(self): |
| 173 super(OilpanGCTimesForInternals, self).__init__() | 188 super(OilpanGCTimesForInternals, self).__init__(include_forced_gc=True) |
| 174 | 189 |
| 175 @classmethod | 190 @classmethod |
| 176 def CustomizeBrowserOptions(cls, options): | 191 def CustomizeBrowserOptions(cls, options): |
| 177 # 'expose-internals-for-testing' can be enabled on content shell. | 192 # 'expose-internals-for-testing' can be enabled on content shell. |
| 178 assert 'content-shell' in options.browser_type | 193 assert 'content-shell' in options.browser_type |
| 179 options.AppendExtraBrowserArgs(['--expose-internals-for-testing', | 194 options.AppendExtraBrowserArgs(['--expose-internals-for-testing', |
| 180 '--js-flags=--expose-gc']) | 195 '--js-flags=--expose-gc']) |
| OLD | NEW |