Пример #1
0
    def __init__(self, script_dir, options, categories):
        """Constructor.

    Args:
        script_dir: Directory containing the trace viewer script
                    (systrace_trace_viewer.html)
        options: List of command line options.
        categories: List of trace categories to capture.
    """
        # Parse command line arguments and create agents.
        self._script_dir = script_dir
        self._out_filename = options.output_file
        agents = CreateAgents(options)

        # Update trace viewer if necessary.
        try:
            from systrace import update_systrace_trace_viewer
        except ImportError:
            pass
        else:
            update_systrace_trace_viewer.update(self._script_dir)

        # Set up tracing controller.
        self._tracing_controller = tracing_controller.TracingController(
            options, categories, agents)
Пример #2
0
def CaptureProfile(options,
                   interval,
                   modules,
                   output=None,
                   compress=False,
                   write_json=False):
    """Records a profiling trace saves the result to a file.

  Args:
    options: Command line options.
    interval: Time interval to capture in seconds. An interval of None (or 0)
        continues tracing until stopped by the user.
    modules: The list of modules to initialize the tracing controller with.
    output: Output file name or None to use an automatically generated name.
    compress: If True, the result will be compressed either with gzip or zip
        depending on the number of captured subtraces.
    write_json: If True, prefer JSON output over HTML.

  Returns:
    Path to saved profile.
  """
    agents_with_config = tracing_controller.CreateAgentsWithConfig(
        options, modules)
    if chrome_startup_tracing_agent in modules:
        controller_config = tracing_controller.GetChromeStartupControllerConfig(
            options)
    else:
        controller_config = tracing_controller.GetControllerConfig(options)
    controller = tracing_controller.TracingController(agents_with_config,
                                                      controller_config)
    try:
        result = controller.StartTracing()
        trace_type = controller.GetTraceType()
        if not result:
            ui.PrintMessage('Trace starting failed.')
        if interval:
            ui.PrintMessage(
                ('Capturing %d-second %s. Press Enter to stop early...' %
                 (interval, trace_type)),
                eol='')
            ui.WaitForEnter(interval)
        else:
            ui.PrintMessage('Capturing %s. Press Enter to stop...' %
                            trace_type,
                            eol='')
            raw_input()

        ui.PrintMessage('Stopping...')
        all_results = controller.StopTracing()
    finally:
        if interval:
            ui.PrintMessage('done')

    return _GetResults(all_results, controller, output, compress, write_json,
                       interval)
Пример #3
0
    def __init__(self, script_dir, options, categories):
        """Constructor.

    Args:
        script_dir: Directory containing the trace viewer script
                    (systrace_trace_viewer.html)
        options: List of command line options.
        categories: List of trace categories to capture.
    """
        # Parse command line arguments and create agents.
        self._script_dir = script_dir
        self._out_filename = options.output_file
        agents = CreateAgents(options)

        # Set up tracing controller.
        self._tracing_controller = tracing_controller.TracingController(
            options, categories, agents)
Пример #4
0
    def __init__(self, script_dir, options):
        """Constructor.

    Args:
        script_dir: Directory containing the trace viewer script
                    (systrace_trace_viewer.html)
        options: Object containing command line options.
    """
        # Parse command line arguments and create agents.
        self._script_dir = script_dir
        self._out_filename = options.output_file
        agents_with_config = tracing_controller.CreateAgentsWithConfig(
            options, AGENT_MODULES)
        controller_config = tracing_controller.GetControllerConfig(options)

        # Set up tracing controller.
        self._tracing_controller = tracing_controller.TracingController(
            agents_with_config, controller_config)