Пример #1
0
    def setUp(self):
        devices = device_utils.DeviceUtils.HealthyDevices()
        self.browser = 'stable'
        self.package_info = profiler.GetSupportedBrowsers()[self.browser]
        self.device = devices[0]

        curr_browser = self.GetChromeProcessID()
        if curr_browser == None:
            self.StartBrowser()
    def setUp(self):
        devices = android_commands.GetAttachedDevices()
        self.browser = 'stable'
        self.package_info = profiler.GetSupportedBrowsers()[self.browser]
        self.device = device_utils.DeviceUtils(devices[0])

        self.device.StartActivity(intent.Intent(
            activity=self.package_info.activity,
            package=self.package_info.package),
                                  blocking=True)
Пример #3
0
    def setUp(self):
        devices = device_utils.DeviceUtils.HealthyDevices()
        self.browser = 'stable'
        self.package_info = profiler.GetSupportedBrowsers()[self.browser]
        self.device = devices[0]

        self.device.ForceStop(self.package_info.package)
        self.device.StartActivity(intent.Intent(
            activity=self.package_info.activity,
            package=self.package_info.package),
                                  blocking=True)
Пример #4
0
    def __init__(self):
        devices = android_commands.GetAttachedDevices()
        self._device = device_utils.DeviceUtils(devices[0])

        # FIXME: Remove a dependency about profiler and support for sbrowser.
        self._package_info = profiler.GetSupportedBrowsers()["chrome_shell"]

        categories = ["benchmark", "input"]
        #categories = ["benchmark", "input", "renderer", "disabled-by-default-gpu.debug*"]

        self._tracer = chrome_controller.ChromeTracingController(
            self._device, self._package_info, categories, None)
def _CreateOptionParser():
    parser = optparse.OptionParser(
        description='Record about://tracing profiles '
        'from Android browsers startup, combined with '
        'Android systrace. See http://dev.chromium.org'
        '/developers/how-tos/trace-event-profiling-'
        'tool for detailed instructions for '
        'profiling.')
    parser.add_option(
        '--url',
        help='URL to visit on startup. Default: '
        'https://www.google.com. An empty URL launches Chrome with'
        ' a MAIN action instead of VIEW.',
        default='https://www.google.com',
        metavar='URL')
    parser.add_option('--cold',
                      help='Flush the OS page cache before starting the'
                      ' browser. Note that this require a device with root '
                      'access.',
                      default=False,
                      action='store_true')
    parser.add_option_group(flags.SystraceOptions(parser))
    parser.add_option_group(flags.OutputOptions(parser))

    browsers = sorted(profiler.GetSupportedBrowsers().keys())
    parser.add_option('-b',
                      '--browser',
                      help='Select among installed browsers. '
                      'One of ' + ', '.join(browsers) +
                      ', "stable" is used by '
                      'default.',
                      type='choice',
                      choices=browsers,
                      default='stable')
    parser.add_option('-v',
                      '--verbose',
                      help='Verbose logging.',
                      action='store_true')
    parser.add_option('-z',
                      '--compress',
                      help='Compress the resulting trace '
                      'with gzip. ',
                      action='store_true')
    parser.add_option('-t',
                      '--time',
                      help='Stops tracing after N seconds, 0 to '
                      'manually stop (startup trace ends after at most 5s).',
                      default=5,
                      metavar='N',
                      type='int')
    return parser
def main():
    parser = _CreateOptionParser()
    options, _ = parser.parse_args()

    if options.verbose:
        logging.getLogger().setLevel(logging.DEBUG)

    devices = device_utils.DeviceUtils.HealthyDevices()
    if len(devices) != 1:
        logging.error('Exactly 1 device must be attached.')
        return 1
    device = devices[0]
    package_info = profiler.GetSupportedBrowsers()[options.browser]

    if options.systrace_categories in ['list', 'help']:
        ui.PrintMessage('\n'.join(
            systrace_controller.SystraceController.GetCategories(device)))
        return 0
    systrace_categories = (options.systrace_categories.split(',')
                           if options.systrace_categories else [])
    enabled_controllers = []
    # Enable the systrace and chrome controller. The systrace controller should go
    # first because otherwise the resulting traces miss early systrace data.
    if systrace_categories:
        enabled_controllers.append(
            systrace_controller.SystraceController(device, systrace_categories,
                                                   False))
    enabled_controllers.append(
        chrome_startup_controller.ChromeStartupTracingController(
            device, package_info, options.cold, options.url))
    if options.output:
        options.output = os.path.expanduser(options.output)
    result = profiler.CaptureProfile(enabled_controllers,
                                     options.time,
                                     output=options.output,
                                     compress=options.compress,
                                     write_json=options.json)
    if options.view:
        if sys.platform == 'darwin':
            os.system('/usr/bin/open %s' % os.path.abspath(result))
        else:
            webbrowser.open(result)
Пример #7
0
def _CreateOptionParser():
    parser = optparse.OptionParser(
        description='Record about://tracing profiles '
        'from Android browsers. See http://dev.'
        'chromium.org/developers/how-tos/trace-event-'
        'profiling-tool for detailed instructions for '
        'profiling.')

    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',
                             type='float')
    parser.add_option_group(timed_options)

    cont_options = optparse.OptionGroup(parser, 'Continuous tracing')
    cont_options.add_option('--continuous',
                            help='Profile continuously until '
                            'stopped.',
                            action='store_true')
    cont_options.add_option('--ring-buffer',
                            help='Use the trace buffer as a '
                            'ring buffer and save its contents when stopping '
                            'instead of appending events into one long trace.',
                            action='store_true')
    parser.add_option_group(cont_options)

    chrome_opts = optparse.OptionGroup(parser, 'Chrome tracing options')
    chrome_opts.add_option(
        '-c',
        '--categories',
        help='Select Chrome tracing '
        'categories with comma-delimited wildcards, '
        'e.g., "*", "cat1*,-cat1a". Omit this option to trace '
        'Chrome\'s default categories. Chrome tracing can be '
        'disabled with "--categories=\'\'". Use "list" to '
        'see the available categories.',
        metavar='CHROME_CATEGORIES',
        dest='chrome_categories',
        default=_DEFAULT_CHROME_CATEGORIES)
    chrome_opts.add_option('--trace-cc',
                           help='Deprecated, use --trace-frame-viewer.',
                           action='store_true')
    chrome_opts.add_option('--trace-frame-viewer',
                           help='Enable enough trace categories for '
                           'compositor frame viewing.',
                           action='store_true')
    chrome_opts.add_option('--trace-ubercompositor',
                           help='Enable enough trace categories for '
                           'ubercompositor frame data.',
                           action='store_true')
    chrome_opts.add_option('--trace-gpu',
                           help='Enable extra trace categories '
                           'for GPU data.',
                           action='store_true')
    chrome_opts.add_option('--trace-flow',
                           help='Enable extra trace categories '
                           'for IPC message flows.',
                           action='store_true')
    chrome_opts.add_option('--trace-memory',
                           help='Enable extra trace categories '
                           'for memory profile. (tcmalloc required)',
                           action='store_true')
    chrome_opts.add_option('--trace-scheduler',
                           help='Enable extra trace '
                           'categories for scheduler state',
                           action='store_true')
    parser.add_option_group(chrome_opts)

    parser.add_option_group(flags.SystraceOptions(parser))

    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)

    ddms_options = optparse.OptionGroup(parser, 'Java tracing')
    ddms_options.add_option('--ddms',
                            help='Trace Java execution using DDMS '
                            'sampling.',
                            action='store_true')
    parser.add_option_group(ddms_options)

    parser.add_option_group(flags.OutputOptions(parser))

    browsers = sorted(profiler.GetSupportedBrowsers().keys())
    parser.add_option('-b',
                      '--browser',
                      help='Select among installed browsers. '
                      'One of ' + ', '.join(browsers) +
                      ', "stable" is used by '
                      'default.',
                      type='choice',
                      choices=browsers,
                      default='stable')
    parser.add_option('-v',
                      '--verbose',
                      help='Verbose logging.',
                      action='store_true')
    parser.add_option('-z',
                      '--compress',
                      help='Compress the resulting trace '
                      'with gzip. ',
                      action='store_true')
    parser.add_option('-d',
                      '--device',
                      help='The Android device ID to use.'
                      'If not specified, only 0 or 1 connected devices are '
                      'supported.',
                      default=None)
    return parser
Пример #8
0
def main():
    parser = _CreateOptionParser()
    options, _args = parser.parse_args()
    if options.trace_cc:
        parser.parse_error("""--trace-cc is deprecated.

For basic jank busting uses, use  --trace-frame-viewer
For detailed study of ubercompositor, pass --trace-ubercompositor.

When in doubt, just try out --trace-frame-viewer.
""")

    if options.verbose:
        logging.getLogger().setLevel(logging.DEBUG)

    devices = device_utils.DeviceUtils.HealthyDevices()
    device = None
    if options.device:
        device = next((d for d in devices if d == options.device), None)
    elif len(devices) == 1:
        device = devices[0]

    if not device:
        parser.error('Use -d/--device to select a device:\n' +
                     '\n'.join(devices))
    package_info = profiler.GetSupportedBrowsers()[options.browser]

    if options.chrome_categories in ['list', 'help']:
        ui.PrintMessage('Collecting record categories list...', eol='')
        record_categories = []
        disabled_by_default_categories = []
        record_categories, disabled_by_default_categories = \
            chrome_controller.ChromeTracingController.GetCategories(
                device, package_info)

        ui.PrintMessage('done')
        ui.PrintMessage('Record Categories:')
        ui.PrintMessage('\n'.join('\t%s' % item \
            for item in sorted(record_categories)))

        ui.PrintMessage('\nDisabled by Default Categories:')
        ui.PrintMessage('\n'.join('\t%s' % item \
            for item in sorted(disabled_by_default_categories)))

        return 0

    if options.systrace_categories in ['list', 'help']:
        ui.PrintMessage('\n'.join(
            systrace_controller.SystraceController.GetCategories(device)))
        return 0

    if (perf_controller.PerfProfilerController.IsSupported()
            and 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 '
            '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))
    if systrace_categories:
        enabled_controllers.append(
            systrace_controller.SystraceController(device, systrace_categories,
                                                   options.ring_buffer))

    if perf_categories:
        enabled_controllers.append(
            perf_controller.PerfProfilerController(device, perf_categories))

    if options.ddms:
        enabled_controllers.append(
            ddms_controller.DdmsController(device, package_info))

    if not enabled_controllers:
        ui.PrintMessage('No trace categories enabled.')
        return 1

    if options.output:
        options.output = os.path.expanduser(options.output)
    result = profiler.CaptureProfile(
        enabled_controllers,
        options.time if not options.continuous else 0,
        output=options.output,
        compress=options.compress,
        write_json=options.json)
    if options.view:
        if sys.platform == 'darwin':
            os.system('/usr/bin/open %s' % os.path.abspath(result))
        else:
            webbrowser.open(result)
def main():
    parser = _CreateOptionParser()
    options, _args = parser.parse_args()  # pylint: disable=unused-variable
    if options.trace_cc:
        parser.error("""--trace-cc is deprecated.

For basic jank busting uses, use  --trace-frame-viewer
For detailed study of ubercompositor, pass --trace-ubercompositor.

When in doubt, just try out --trace-frame-viewer.
""")

    if options.verbose:
        logging.getLogger().setLevel(logging.DEBUG)

    device = device_utils.DeviceUtils.HealthyDevices(
        device_arg=options.device_serial_number)[0]
    package_info = profiler.GetSupportedBrowsers()[options.browser]

    options.device = device
    options.package_info = package_info

    # Add options that are present in Systrace but not in profile_chrome (since
    # they both use the same tracing controller).
    # TODO(washingtonp): Once Systrace uses all of the profile_chrome agents,
    # manually setting these options will no longer be necessary and should be
    # removed.
    options.list_categories = None
    options.link_assets = None
    options.asset_dir = None
    options.timeout = None
    options.collection_timeout = None
    options.target = None

    if options.chrome_categories in ['list', 'help']:
        ui.PrintMessage('Collecting record categories list...', eol='')
        record_categories = []
        disabled_by_default_categories = []
        record_categories, disabled_by_default_categories = \
            chrome_tracing_agent.ChromeTracingAgent.GetCategories(
                device, package_info)

        ui.PrintMessage('done')
        ui.PrintMessage('Record Categories:')
        ui.PrintMessage('\n'.join('\t%s' % item \
            for item in sorted(record_categories)))

        ui.PrintMessage('\nDisabled by Default Categories:')
        ui.PrintMessage('\n'.join('\t%s' % item \
            for item in sorted(disabled_by_default_categories)))

        return 0

    if options.atrace_categories in ['list', 'help']:
        ui.PrintMessage('\n'.join(
            atrace_tracing_agent.AtraceAgent.GetCategories(device)))
        return 0

    if (perf_tracing_agent.PerfProfilerAgent.IsSupported()
            and options.perf_categories in ['list', 'help']):
        ui.PrintMessage('\n'.join(
            perf_tracing_agent.PerfProfilerAgent.GetCategories(device)))
        return 0

    if not options.trace_time and not options.continuous:
        ui.PrintMessage(
            'Time interval or continuous tracing should be specified.')
        return 1

    if options.chrome_categories and 'webview' in options.atrace_categories:
        logging.warning('Using the "webview" category in atrace together with '
                        'Chrome tracing results in duplicate trace events.')

    if options.output_file:
        options.output_file = os.path.expanduser(options.output_file)
    result = profiler.CaptureProfile(
        options,
        options.trace_time if not options.continuous else 0,
        _PROFILE_CHROME_AGENT_MODULES,
        output=options.output_file,
        compress=options.compress,
        write_json=options.write_json)
    if options.view:
        if sys.platform == 'darwin':
            os.system('/usr/bin/open %s' % os.path.abspath(result))
        else:
            webbrowser.open(result)
def _CreateOptionParser():
    parser = optparse.OptionParser(
        description='Record about://tracing profiles '
        'from Android browsers. See http://dev.'
        'chromium.org/developers/how-tos/trace-event-'
        'profiling-tool for detailed instructions for '
        'profiling.')

    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',
                             type='float',
                             dest='trace_time')
    parser.add_option_group(timed_options)

    cont_options = optparse.OptionGroup(parser, 'Continuous tracing')
    cont_options.add_option('--continuous',
                            help='Profile continuously until '
                            'stopped.',
                            action='store_true')
    cont_options.add_option('--ring-buffer',
                            help='Use the trace buffer as a '
                            'ring buffer and save its contents when stopping '
                            'instead of appending events into one long trace.',
                            action='store_true')
    parser.add_option_group(cont_options)

    parser.add_option_group(flags.OutputOptions(parser))

    browsers = sorted(profiler.GetSupportedBrowsers().keys())
    parser.add_option('-b',
                      '--browser',
                      help='Select among installed browsers. '
                      'One of ' + ', '.join(browsers) +
                      ', "stable" is used by '
                      'default.',
                      type='choice',
                      choices=browsers,
                      default='stable')
    parser.add_option('-v',
                      '--verbose',
                      help='Verbose logging.',
                      action='store_true')
    parser.add_option('-z',
                      '--compress',
                      help='Compress the resulting trace '
                      'with gzip. ',
                      action='store_true')
    parser.add_option('-d',
                      '--device',
                      help='The Android device ID to use, '
                      'defaults to the value of ANDROID_SERIAL environment '
                      'variable. If not specified, only 0 or 1 connected '
                      'devices are supported.',
                      dest='device_serial_number')

    # Add options from profile_chrome agents.
    for module in _PROFILE_CHROME_AGENT_MODULES:
        parser.add_option_group(module.add_options(parser))

    return parser
Пример #11
0
def _CreateOptionParser():
    parser = optparse.OptionParser(
        description='Record about://tracing profiles '
        'from Android browsers. See http://dev.'
        'chromium.org/developers/how-tos/trace-event-'
        'profiling-tool for detailed instructions for '
        'profiling.')

    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',
                             type='float')
    parser.add_option_group(timed_options)

    cont_options = optparse.OptionGroup(parser, 'Continuous tracing')
    cont_options.add_option('--continuous',
                            help='Profile continuously until '
                            'stopped.',
                            action='store_true')
    cont_options.add_option('--ring-buffer',
                            help='Use the trace buffer as a '
                            'ring buffer and save its contents when stopping '
                            'instead of appending events into one long trace.',
                            action='store_true')
    parser.add_option_group(cont_options)

    chrome_opts = optparse.OptionGroup(parser, 'Chrome tracing options')
    chrome_opts.add_option(
        '-c',
        '--categories',
        help='Select Chrome tracing '
        'categories with comma-delimited wildcards, '
        'e.g., "*", "cat1*,-cat1a". Omit this option to trace '
        'Chrome\'s default categories. Chrome tracing can be '
        'disabled with "--categories=\'\'". Use "list" to '
        'see the available categories.',
        metavar='CHROME_CATEGORIES',
        dest='chrome_categories',
        default=_DEFAULT_CHROME_CATEGORIES)
    chrome_opts.add_option('--trace-cc',
                           help='Deprecated, use --trace-frame-viewer.',
                           action='store_true')
    chrome_opts.add_option('--trace-frame-viewer',
                           help='Enable enough trace categories for '
                           'compositor frame viewing.',
                           action='store_true')
    chrome_opts.add_option('--trace-ubercompositor',
                           help='Enable enough trace categories for '
                           'ubercompositor frame data.',
                           action='store_true')
    chrome_opts.add_option('--trace-gpu',
                           help='Enable extra trace categories '
                           'for GPU data.',
                           action='store_true')
    chrome_opts.add_option('--trace-flow',
                           help='Enable extra trace categories '
                           'for IPC message flows.',
                           action='store_true')
    chrome_opts.add_option('--trace-memory',
                           help='Enable extra trace categories '
                           'for memory profile. (tcmalloc required)',
                           action='store_true')
    parser.add_option_group(chrome_opts)

    systrace_opts = optparse.OptionGroup(parser, 'Systrace tracing options')
    systrace_opts.add_option(
        '-s',
        '--systrace',
        help='Capture a systrace with '
        'the chosen comma-delimited systrace categories. You '
        'can also capture a combined Chrome + systrace by '
        'enable both types of categories. Use "list" to see '
        'the available categories. Systrace is disabled by '
        'default.',
        metavar='SYS_CATEGORIES',
        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 '
                              'HTML.',
                              action='store_true')
    output_options.add_option('--view',
                              help='Open resulting trace file in a '
                              'browser.',
                              action='store_true')
    output_options.add_option('--view-canary',
                              help='Open resulting trace file in '
                              'Canary.',
                              action='store_true')
    output_options.add_option('--view-tve',
                              dest='run_tev',
                              action='store_true',
                              default=False,
                              help='Run trace-event-viewer upon '
                              'completion.')
    parser.add_option_group(output_options)

    browsers = sorted(profiler.GetSupportedBrowsers().keys())
    parser.add_option('-b',
                      '--browser',
                      help='Select among installed browsers. '
                      'One of ' + ', '.join(browsers) +
                      ', "stable" is used by '
                      'default.',
                      type='choice',
                      choices=browsers,
                      default='stable')
    parser.add_option('-v',
                      '--verbose',
                      help='Verbose logging.',
                      action='store_true')
    parser.add_option('-z',
                      '--compress',
                      help='Compress the resulting trace '
                      'with gzip. ',
                      action='store_true')
    return parser
Пример #12
0
def main():
    parser = _CreateOptionParser()
    options, _args = parser.parse_args()
    if options.trace_cc:
        parser.parse_error("""--trace-cc is deprecated.

For basic jank busting uses, use  --trace-frame-viewer
For detailed study of ubercompositor, pass --trace-ubercompositor.

When in doubt, just try out --trace-frame-viewer.
""")

    if options.verbose:
        logging.getLogger().setLevel(logging.DEBUG)

    devices = android_commands.GetAttachedDevices()
    if len(devices) != 1:
        parser.error('Exactly 1 device must be attached.')
    device = device_utils.DeviceUtils(devices[0])
    package_info = profiler.GetSupportedBrowsers()[options.browser]

    if options.chrome_categories in ['list', 'help']:
        ui.PrintMessage('Collecting record categories list...', eol='')
        record_categories = []
        disabled_by_default_categories = []
        record_categories, disabled_by_default_categories = \
            chrome_controller.ChromeTracingController.GetCategories(
                device, package_info)

        ui.PrintMessage('done')
        ui.PrintMessage('Record Categories:')
        ui.PrintMessage('\n'.join('\t%s' % item \
            for item in sorted(record_categories)))

        ui.PrintMessage('\nDisabled by Default Categories:')
        ui.PrintMessage('\n'.join('\t%s' % item \
            for item in sorted(disabled_by_default_categories)))

        return 0

    if options.systrace_categories in ['list', 'help']:
        ui.PrintMessage('\n'.join(
            systrace_controller.SystraceController.GetCategories(device)))
        return 0

    if (perf_controller.PerfProfilerController.IsSupported()
            and 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 '
            '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))
    if systrace_categories:
        enabled_controllers.append(
            systrace_controller.SystraceController(device, 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

    if options.output:
        options.output = os.path.expanduser(options.output)
    result = profiler.CaptureProfile(
        enabled_controllers,
        options.time if not options.continuous else 0,
        output=options.output,
        compress=options.compress,
        write_json=options.json)
    if options.view_canary:
        if sys.platform == 'darwin':
            os.system((
                '/usr/bin/open -a /Applications/Google\ Chrome\ Canary.app %s '
                '--args --enable-impl-side-painting --enable-skia-benchmarking '
                '--allow-webui-compositing') % os.path.abspath(result))
        else:
            _PrintMessage(
                'No Chrome Canary on this platform to open trace in, try a different view method'
            )
    elif options.view:
        if sys.platform == 'darwin':
            os.system('/usr/bin/open %s' % os.path.abspath(result))
        else:
            webbrowser.open(result)
    elif options.run_tev and result:
        os.system('trace-event-viewer %s' % result)