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