[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / perf / record_android_profile.py
blob41d99a705eccdfa583037d0e2d9d4ea946663ad7
1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 import os
7 import sys
8 import tempfile
10 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'telemetry'))
12 from telemetry.internal.browser import browser_finder
13 from telemetry.internal.browser import browser_options
16 def _RunPrebuilt(options):
17 browser_to_create = browser_finder.FindBrowser(options)
18 with browser_to_create.Create(options) as browser:
19 output_file = os.path.join(tempfile.mkdtemp(), options.profiler)
20 raw_input('Press enter to start profiling...')
21 print '>> Starting profiler', options.profiler
22 browser.profiling_controller.Start(options.profiler, output_file)
23 try:
24 raw_input('Press enter or CTRL+C to stop')
25 except KeyboardInterrupt:
26 pass
27 finally:
28 print '<< Stopping ...',
29 sys.stdout.flush()
30 browser.profiling_controller.Stop()
31 print 'Stopped profiler ', options.profiler
34 if __name__ == '__main__':
35 browser_finder_options = browser_options.BrowserFinderOptions()
36 parser = browser_finder_options.CreateParser('')
37 profiler_options, _ = parser.parse_args()
38 sys.exit(_RunPrebuilt(profiler_options))