Index: tools/profile_chrome/main.py |
diff --git a/tools/profile_chrome/main.py b/tools/profile_chrome/main.py |
index 1dbf08a60d9e98cf67ca6f21cebc369988aaf689..1e3bd21348df0632f8383d10871ffaa4b102e0a5 100755 |
--- a/tools/profile_chrome/main.py |
+++ b/tools/profile_chrome/main.py |
@@ -74,6 +74,11 @@ def _CreateOptionParser(): |
'profiling-tool for detailed instructions for ' |
'profiling.') |
+ parser.add_option('--startup', help='Trace Chrome Startup. Possible values ' |
+ 'are "warm" and "cold". Cold start is done with the page ' |
pasko
2015/01/27 12:59:00
nit: maybe rephrase:
The "warm" does not perform s
Benoit L
2015/01/27 13:50:26
Done.
|
+ 'cache flushed before, warm without. Note that "cold" ' |
+ 'requires a device with root access.', default=None) |
+ |
timed_options = optparse.OptionGroup(parser, 'Timed tracing') |
timed_options.add_option('-t', '--time', help='Profile for N seconds and ' |
'download the resulting trace.', metavar='N', |
@@ -180,6 +185,10 @@ When in doubt, just try out --trace-frame-viewer. |
device = device_utils.DeviceUtils(devices[0]) |
package_info = profiler.GetSupportedBrowsers()[options.browser] |
+ if options.startup and options.startup not in ['cold', 'warm']: |
Sami
2015/01/27 13:15:47
Could you use optparser's "choices" mechanism to l
Benoit L
2015/01/27 13:50:25
Didn't know about this mechanism. Thank you !
Done
|
+ ui.PrintMessage('Startup mode should be one of ["cold", "warm"]') |
+ return 1 |
+ |
if options.chrome_categories in ['list', 'help']: |
ui.PrintMessage('Collecting record categories list...', eol='') |
record_categories = [] |
@@ -210,8 +219,9 @@ When in doubt, just try out --trace-frame-viewer. |
perf_controller.PerfProfilerController.GetCategories(device))) |
return 0 |
- if not options.time and not options.continuous: |
- ui.PrintMessage('Time interval or continuous tracing should be specified.') |
+ if not options.time and not options.continuous and not options.startup: |
+ ui.PrintMessage('Time interval, continuous or startup tracing should be ' |
+ 'specified.') |
return 1 |
chrome_categories = _ComputeChromeCategories(options) |
@@ -223,19 +233,23 @@ When in doubt, just try out --trace-frame-viewer. |
'Chrome tracing results in duplicate trace events.') |
enabled_controllers = [] |
- if chrome_categories: |
- enabled_controllers.append( |
- chrome_controller.ChromeTracingController(device, |
- package_info, |
- chrome_categories, |
- options.ring_buffer, |
- options.trace_memory)) |
+ # Systrace need to be put first, because when we profile startup, we want to |
pasko
2015/01/27 12:59:00
nit: we usually try to avoid 'we' in the comments.
Benoit L
2015/01/27 13:50:26
Done.
|
+ # see events from the start of execution, which is initiated in the chrome |
+ # controller. |
if systrace_categories: |
enabled_controllers.append( |
systrace_controller.SystraceController(device, |
systrace_categories, |
options.ring_buffer)) |
+ if chrome_categories: |
+ enabled_controllers.append( |
+ chrome_controller.ChromeTracingController(device, |
+ package_info, |
+ chrome_categories, |
+ options.ring_buffer, |
+ options.trace_memory, |
+ options.startup)) |
if perf_categories: |
enabled_controllers.append( |
perf_controller.PerfProfilerController(device, |
@@ -249,7 +263,7 @@ When in doubt, just try out --trace-frame-viewer. |
options.output = os.path.expanduser(options.output) |
result = profiler.CaptureProfile( |
enabled_controllers, |
- options.time if not options.continuous else 0, |
+ options.time if options.time else 0, |
Sami
2015/01/27 13:15:47
Why this change?
Benoit L
2015/01/27 13:50:26
Because options.time is None when options.continuo
|
output=options.output, |
compress=options.compress, |
write_json=options.json) |