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

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

Issue 511653002: Add profiling_controller that manages profilers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/profilers_controller/profiling_controller Created 6 years, 3 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
« no previous file with comments | « no previous file | tools/perf/measurements/memory.py » ('j') | tools/perf/measurements/memory.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 import tempfile 6 import tempfile
7 7
8 from metrics import loading 8 from metrics import loading
9 from telemetry.core.platform.profiler import perf_profiler 9 from telemetry.core.platform.profiler import perf_profiler
10 from telemetry.page import page_test 10 from telemetry.page import page_test
11 from telemetry.value import scalar 11 from telemetry.value import scalar
12 12
13 13
14 class LoadingProfile(page_test.PageTest): 14 class LoadingProfile(page_test.PageTest):
15 options = {'page_repeat': 2} 15 options = {'page_repeat': 2}
16 16
17 def __init__(self): 17 def __init__(self):
18 super(LoadingProfile, self).__init__(discard_first_result=True) 18 super(LoadingProfile, self).__init__(discard_first_result=True)
19 19
20 def CustomizeBrowserOptions(self, options): 20 def CustomizeBrowserOptions(self, options):
21 if not perf_profiler.PerfProfiler.is_supported(browser_type='any'): 21 if not perf_profiler.PerfProfiler.is_supported(browser_type='any'):
22 raise Exception('This measurement is not supported on this platform') 22 raise Exception('This measurement is not supported on this platform')
23 23
24 perf_profiler.PerfProfiler.CustomizeBrowserOptions( 24 perf_profiler.PerfProfiler.CustomizeBrowserOptions(
25 browser_type='any', options=options) 25 browser_type='any', options=options)
26 26
27 def WillNavigateToPage(self, page, tab): 27 def WillNavigateToPage(self, page, tab):
28 tab.browser.StartProfiling(perf_profiler.PerfProfiler.name(), 28 tab.browser.platform.profiling_controller.StartProfiling(
29 os.path.join(tempfile.mkdtemp(), 29 perf_profiler.PerfProfiler.name(),
30 page.file_safe_name)) 30 os.path.join(tempfile.mkdtemp(), page.file_safe_name))
31 31
32 def ValidateAndMeasurePage(self, page, tab, results): 32 def ValidateAndMeasurePage(self, page, tab, results):
33 # In current telemetry tests, all tests wait for DocumentComplete state, 33 # In current telemetry tests, all tests wait for DocumentComplete state,
34 # but we need to wait for the load event. 34 # but we need to wait for the load event.
35 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) 35 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
36 36
37 profile_files = tab.browser.StopProfiling() 37 profile_files = tab.browser.StopProfiling()
tonyg 2014/09/04 17:10:19 How does this work? Note that we could simply rem
nednguyen 2014/09/04 17:31:46 Removing patch in https://codereview.chromium.org/
38 38
39 loading.LoadingMetric().AddResults(tab, results) 39 loading.LoadingMetric().AddResults(tab, results)
40 40
41 profile_file = None 41 profile_file = None
42 for profile_file in profile_files: 42 for profile_file in profile_files:
43 if 'renderer' in profile_file: 43 if 'renderer' in profile_file:
44 break 44 break
45 45
46 for function, period in perf_profiler.PerfProfiler.GetTopSamples( 46 for function, period in perf_profiler.PerfProfiler.GetTopSamples(
47 profile_file, 10).iteritems(): 47 profile_file, 10).iteritems():
48 results.AddValue(scalar.ScalarValue( 48 results.AddValue(scalar.ScalarValue(
49 results.current_page, function.replace('.', '_'), 'period', period)) 49 results.current_page, function.replace('.', '_'), 'period', period))
OLDNEW
« no previous file with comments | « no previous file | tools/perf/measurements/memory.py » ('j') | tools/perf/measurements/memory.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698