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

Unified Diff: build/android/chrome_profiler/main.py

Issue 293193002: adb_profile_chrome: Add perf profiler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded entrypoint. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/chrome_profiler/perf_controller.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/chrome_profiler/main.py
diff --git a/build/android/chrome_profiler/main.py b/build/android/chrome_profiler/main.py
index 401115fb57d9cc5ffa590758458f1ec149ffbee1..729163f87475c40f88a55e0a3379b8517b2af4d5 100755
--- a/build/android/chrome_profiler/main.py
+++ b/build/android/chrome_profiler/main.py
@@ -11,6 +11,7 @@ import sys
import webbrowser
from chrome_profiler import chrome_controller
+from chrome_profiler import perf_controller
from chrome_profiler import profiler
from chrome_profiler import systrace_controller
from chrome_profiler import ui
@@ -45,6 +46,21 @@ def _ComputeSystraceCategories(options):
return options.systrace_categories.split(',')
+def _ComputePerfCategories(options):
+ if not options.perf_categories:
+ return []
+ return options.perf_categories.split(',')
+
+
+def _OptionalValueCallback(default_value):
+ def callback(option, _, __, parser):
+ value = default_value
+ if parser.rargs and not parser.rargs[0].startswith('-'):
+ value = parser.rargs.pop(0)
+ setattr(parser.values, option.dest, value)
+ return callback
+
+
def _CreateOptionParser():
parser = optparse.OptionParser(description='Record about://tracing profiles '
'from Android browsers. See http://dev.'
@@ -104,6 +120,16 @@ def _CreateOptionParser():
dest='systrace_categories', default='')
parser.add_option_group(systrace_opts)
+ if perf_controller.PerfProfilerController.IsSupported():
+ perf_opts = optparse.OptionGroup(parser, 'Perf profiling options')
+ perf_opts.add_option('-p', '--perf', help='Capture a perf profile with '
+ 'the chosen comma-delimited event categories. '
+ 'Samples CPU cycles by default. Use "list" to see '
+ 'the available sample types.', action='callback',
+ default='', callback=_OptionalValueCallback('cycles'),
+ metavar='PERF_CATEGORIES', dest='perf_categories')
+ parser.add_option_group(perf_opts)
+
output_options = optparse.OptionGroup(parser, 'Output options')
output_options.add_option('-o', '--output', help='Save trace output to file.')
output_options.add_option('--json', help='Save trace as raw JSON instead of '
@@ -169,12 +195,18 @@ When in doubt, just try out --trace-frame-viewer.
systrace_controller.SystraceController.GetCategories(device)))
return 0
+ if options.perf_categories in ['list', 'help']:
+ ui.PrintMessage('\n'.join(
+ 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.')
return 1
chrome_categories = _ComputeChromeCategories(options)
systrace_categories = _ComputeSystraceCategories(options)
+ perf_categories = _ComputePerfCategories(options)
if chrome_categories and 'webview' in systrace_categories:
logging.warning('Using the "webview" category in systrace together with '
@@ -194,6 +226,11 @@ When in doubt, just try out --trace-frame-viewer.
systrace_categories,
options.ring_buffer))
+ if perf_categories:
+ enabled_controllers.append(
+ perf_controller.PerfProfilerController(device,
+ perf_categories))
+
if not enabled_controllers:
ui.PrintMessage('No trace categories enabled.')
return 1
@@ -211,7 +248,3 @@ When in doubt, just try out --trace-frame-viewer.
os.system('/usr/bin/open %s' % os.path.abspath(result))
else:
webbrowser.open(result)
-
-
-if __name__ == '__main__':
- sys.exit(main())
« no previous file with comments | « no previous file | build/android/chrome_profiler/perf_controller.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698