コード例 #1
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.',
        conflict_handler='resolve')

    parser = util.get_main_options(parser)

    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(util.get_supported_browsers().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')

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

    return parser
コード例 #2
0
def parse_options(argv):
    """Parses and checks the command-line options.

  Returns:
    A tuple containing the options structure and a list of categories to
    be traced.
  """
    usage = 'Usage: %prog [options] [category1 [category2 ...]]'
    desc = 'Example: %prog -b 32768 -t 15 gfx input view sched freq'
    parser = optparse.OptionParser(usage=usage,
                                   description=desc,
                                   conflict_handler='resolve')
    parser = util.get_main_options(parser)

    parser.add_option('-l',
                      '--list-categories',
                      dest='list_categories',
                      default=False,
                      action='store_true',
                      help='list the available categories and exit')

    # Add the other agent parsing options to the parser. For Systrace on the
    # command line, all agents are added. For Android, only the compatible agents
    # will be added.
    for module in ALL_MODULES:
        option_group = module.add_options(parser)
        if option_group:
            parser.add_option_group(option_group)

    options, categories = parser.parse_args(argv[1:])

    if options.output_file is None:
        base = 'trace'
        if options.from_file is not None:
            base = os.path.splitext(options.from_file)[0]
        suffix = '.json' if options.write_json else '.html'
        options.output_file = base + suffix

    if options.link_assets or options.asset_dir != 'trace-viewer':
        parser.error('--link-assets and --asset-dir are deprecated.')

    if options.trace_time and options.trace_time < 0:
        parser.error('the trace time must be a non-negative number')

    if (options.trace_buf_size is not None) and (options.trace_buf_size <= 0):
        parser.error('the trace buffer size must be a positive number')

    return (options, categories)
コード例 #3
0
ファイル: run_systrace.py プロジェクト: nitra/catapult
def parse_options(argv):
  """Parses and checks the command-line options.

  Returns:
    A tuple containing the options structure and a list of categories to
    be traced.
  """
  usage = 'Usage: %prog [options] [category1 [category2 ...]]'
  desc = 'Example: %prog -b 32768 -t 15 gfx input view sched freq'
  parser = optparse.OptionParser(usage=usage, description=desc,
                                 conflict_handler='resolve')
  parser = util.get_main_options(parser)

  parser.add_option('-l', '--list-categories', dest='list_categories',
                    default=False, action='store_true',
                    help='list the available categories and exit')

  # Add the other agent parsing options to the parser. For Systrace on the
  # command line, all agents are added. For Android, only the compatible agents
  # will be added.
  for module in ALL_MODULES:
    option_group = module.add_options(parser)
    if option_group:
      parser.add_option_group(option_group)

  options, categories = parser.parse_args(argv[1:])

  if options.output_file is None:
    base = 'trace'
    if options.from_file is not None:
      base = os.path.splitext(options.from_file)[0]
    suffix = '.json' if options.write_json else '.html'
    options.output_file = base + suffix

  if options.link_assets or options.asset_dir != 'trace-viewer':
    parser.error('--link-assets and --asset-dir are deprecated.')

  if options.trace_time and options.trace_time < 0:
    parser.error('the trace time must be a non-negative number')

  if (options.trace_buf_size is not None) and (options.trace_buf_size <= 0):
    parser.error('the trace buffer size must be a positive number')

  return (options, categories)
コード例 #4
0
ファイル: main.py プロジェクト: Hzj-jie/android-sdk-linux
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.', conflict_handler='resolve')

  parser = util.get_main_options(parser)

  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(util.get_supported_browsers().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')

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

  return parser