Exemple #1
0
 def ValidateAndMeasurePage(self, page, tab, results):
   timeline_data = tab.browser.platform.tracing_controller.StopTracing()
   timeline_model = TimelineModel(timeline_data)
   threads = timeline_model.GetAllThreads()
   for thread in threads:
     if thread.name == _CR_RENDERER_MAIN:
       _AddTracingResults(thread, results)
Exemple #2
0
  def ValidateAndMeasurePage(self, page, tab, results):
    del page  # unused
    trace_data = tab.browser.platform.tracing_controller.StopTracing()[0]
    timeline_model = TimelineModel(trace_data)

    renderer_process = timeline_model.GetFirstRendererProcess(tab.id)
    self._AddV8MetricsToResults(renderer_process, results)
Exemple #3
0
  def Stop(self, tab, results):
    # End the smooth marker for all actions.
    self._interaction.End()
    # Stop tracing.
    timeline_data = tab.browser.platform.tracing_controller.Stop()
    results.AddValue(trace.TraceValue(
        results.current_page, timeline_data))
    self._model = TimelineModel(timeline_data)
    self._renderer_process = self._model.GetRendererProcessFromTabId(tab.id)
    renderer_thread = self.model.GetRendererThreadFromTabId(tab.id)

    run_smooth_actions_record = None
    self._smooth_records = []
    for event in renderer_thread.async_slices:
      if not tir_module.IsTimelineInteractionRecord(event.name):
        continue
      r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
      if r.label == RUN_SMOOTH_ACTIONS:
        assert run_smooth_actions_record is None, (
          'TimelineController cannot issue more than 1 %s record' %
          RUN_SMOOTH_ACTIONS)
        run_smooth_actions_record = r
      else:
        self._smooth_records.append(
          smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
            self.model, r))

    # If there is no other smooth records, we make measurements on time range
    # marked by timeline_controller itself.
    # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
    # page sets are responsible for issueing the markers themselves.
    if len(self._smooth_records) == 0 and run_smooth_actions_record:
      self._smooth_records = [run_smooth_actions_record]
    def DidRunActions(self, page, tab):
        trace_data = tab.browser.platform.tracing_controller.Stop()
        timeline_model = TimelineModel(trace_data)

        self._renderer_process = timeline_model.GetRendererProcessFromTabId(
            tab.id)
        self._browser_process = timeline_model.browser_process
    def ValidateAndMeasurePage(self, page, tab, results):
        trace_data = tab.browser.platform.tracing_controller.StopTracing()
        timeline_model = TimelineModel(trace_data)

        self._renderer_process = timeline_model.GetRendererProcessFromTabId(
            tab.id)
        self._browser_process = timeline_model.browser_process
        self._AddResults(results)
 def Stop(self, tab):
     # End the smooth marker for all smooth actions.
     self._interaction.End()
     # Stop tracing for smoothness metric.
     if tab.browser.platform.IsRawDisplayFrameRateSupported():
         tab.browser.platform.StopRawDisplayFrameRateMeasurement()
     self._tracing_timeline_data = tab.browser.StopTracing()
     self._timeline_model = TimelineModel(
         timeline_data=self._tracing_timeline_data)
    def Stop(self, tab, results):
        # End the smooth marker for all actions.
        if self._enable_auto_issuing_record:
            self._interaction.End()
        # Stop tracing.
        timeline_data = tab.browser.platform.tracing_controller.StopTracing()

        # TODO(charliea): This is part of a three-sided Chromium/Telemetry patch
        # where we're changing the return type of StopTracing from a TraceValue to a
        # (TraceValue, nonfatal_exception_list) tuple. Once the tuple return value
        # lands in Chromium, the non-tuple logic should be deleted.
        if isinstance(timeline_data, tuple):
            timeline_data = timeline_data[0]

        # TODO(#763375): Rely on results.telemetry_info.trace_local_path/etc.
        kwargs = {}
        if hasattr(results.telemetry_info, 'trace_local_path'):
            kwargs['file_path'] = results.telemetry_info.trace_local_path
            kwargs['remote_path'] = results.telemetry_info.trace_remote_path
            kwargs['upload_bucket'] = results.telemetry_info.upload_bucket
            kwargs['cloud_url'] = results.telemetry_info.trace_remote_url
        results.AddValue(
            trace.TraceValue(results.current_page, timeline_data, **kwargs))

        self._model = TimelineModel(timeline_data)
        self._renderer_process = self._model.GetRendererProcessFromTabId(
            tab.id)
        renderer_thread = self.model.GetRendererThreadFromTabId(tab.id)

        run_smooth_actions_record = None
        self._smooth_records = []
        for event in renderer_thread.async_slices:
            if not tir_module.IsTimelineInteractionRecord(event.name):
                continue
            r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
            if r.label == RUN_SMOOTH_ACTIONS:
                assert run_smooth_actions_record is None, (
                    'TimelineController cannot issue more than 1 %s record' %
                    RUN_SMOOTH_ACTIONS)
                run_smooth_actions_record = r
            else:
                self._smooth_records.append(
                    smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
                        self.model, r))

        # If there is no other smooth records, we make measurements on time range
        # marked by timeline_controller itself.
        # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
        # page sets are responsible for issueing the markers themselves.
        if len(self._smooth_records) == 0 and run_smooth_actions_record:
            self._smooth_records = [run_smooth_actions_record]

        if len(self._smooth_records) == 0:
            raise legacy_page_test.Failure(
                'No interaction record was created.')
    def _get_memory_usage(self):
        """Helper function to get the memory usage.

        It returns a tuple of six elements:
            (browser_usage, renderer_usage, gpu_usage, kernel_usage,
             total_usage, graphics_usage)
        All are expected in the unit of KB.

        browser_usage: the RSS of the browser process
        renderer_usage: the total RSS of all renderer processes
        gpu_usage: the total RSS of all gpu processes
        kernel_usage: the memory used in kernel
        total_usage: the sum of the above memory usages. The graphics_usage is
                     not included because the composition of the graphics
                     memory is much more complicated (could be from video card,
                     user space, or kenerl space). It doesn't make so much
                     sense to sum it up with others.
        graphics_usage: the memory usage reported by the graphics driver
        """

        config = tracing_config.TracingConfig()
        config.chrome_trace_config.category_filter.AddExcludedCategory("*")
        config.chrome_trace_config.category_filter.AddDisabledByDefault(
                "disabled-by-default-memory-infra")
        config.chrome_trace_config.SetMemoryDumpConfig(
                chrome_trace_config.MemoryDumpConfig())
        config.enable_chrome_trace = True
        self.browser.platform.tracing_controller.StartTracing(config)

        # Force to collect garbage before measuring memory
        for t in self.browser.tabs:
            t.CollectGarbage()

        self.browser.DumpMemory()

        trace_data = self.browser.platform.tracing_controller.StopTracing()[0]
        model = TimelineModel(trace_data)
        memory_dump = model.IterGlobalMemoryDumps().next()
        process_memory = collections.defaultdict(int)
        for process_memory_dump in memory_dump.IterProcessMemoryDumps():
            process_name = process_memory_dump.process_name
            process_memory[process_name] += sum(
                    process_memory_dump.GetMemoryUsage().values())

        result = (process_memory[KEY_BROWSER] / 1024,
                  process_memory[KEY_RENDERER] / 1024,
                  process_memory[KEY_GPU] / 1024,
                  _get_kernel_memory_usage())

        # total = browser + renderer + gpu + kernal
        result += (sum(result), _get_graphics_memory_usage())
        return result
    def ValidateAndMeasurePage(self, page, tab, results):
        del page  # unused
        trace_data = tab.browser.platform.tracing_controller.StopTracing()

        # TODO(charliea): This is part of a three-sided Chromium/Telemetry patch
        # where we're changing the return type of StopTracing from a TraceValue to a
        # (TraceValue, nonfatal_exception_list) tuple. Once the tuple return value
        # lands in Chromium, the non-tuple logic should be deleted.
        if isinstance(trace_data, tuple):
            trace_data = trace_data[0]

        timeline_model = TimelineModel(trace_data)

        renderer_process = timeline_model.GetRendererProcessFromTabId(tab.id)
        self._AddV8MetricsToResults(renderer_process, results)
Exemple #10
0
class _OilpanGCTimesBase(page_test.PageTest):
    def __init__(self, action_name=''):
        super(_OilpanGCTimesBase, self).__init__(action_name)
        self._timeline_model = None

    def WillNavigateToPage(self, page, tab):
        # FIXME: Remove webkit.console when blink.console lands in chromium and
        # the ref builds are updated. crbug.com/386847
        categories = ['webkit.console', 'blink.console', 'blink_gc']
        category_filter = tracing_category_filter.TracingCategoryFilter()
        for c in categories:
            category_filter.AddIncludedCategory(c)
        options = tracing_options.TracingOptions()
        options.enable_chrome_trace = True
        tab.browser.platform.tracing_controller.Start(options,
                                                      category_filter,
                                                      timeout=1000)

    def DidRunActions(self, page, tab):
        timeline_data = tab.browser.platform.tracing_controller.Stop()
        self._timeline_model = TimelineModel(timeline_data)

    def ValidateAndMeasurePage(self, page, tab, results):
        threads = self._timeline_model.GetAllThreads()
        for thread in threads:
            if thread.name == _CR_RENDERER_MAIN:
                _AddTracingResults(thread.all_slices, results)

    def CleanUpAfterPage(self, page, tab):
        if tab.browser.platform.tracing_controller.is_tracing_running:
            tab.browser.platform.tracing_controller.Stop()
 def testBrowserProcess(self):
     ri = tracing_timeline_data.TracingTimelineData(
         map(json.loads, [
             '{"name": "process_name",'
             '"args": {"name": "Browser"},'
             '"pid": 5, "ph": "M"}', '{"name": "thread_name",'
             '"args": {"name": "CrBrowserMain"},'
             '"pid": 5, "tid": 32578, "ph": "M"}'
         ]))
     model = TimelineModel(ri)
     self.assertEquals(model.browser_process.pid, 5)
Exemple #12
0
class SmoothnessController(object):
    def __init__(self):
        self._timeline_model = None
        self._trace_data = None
        self._interaction = None
        self._surface_flinger_trace_data = None

    def Start(self, page, tab):
        # FIXME: Remove webkit.console when blink.console lands in chromium and
        # the ref builds are updated. crbug.com/386847
        custom_categories = ['webkit.console', 'blink.console', 'benchmark']
        custom_categories += page.GetSyntheticDelayCategories()
        category_filter = tracing_category_filter.TracingCategoryFilter()
        for c in custom_categories:
            category_filter.AddIncludedCategory(c)
        options = tracing_options.TracingOptions()
        options.enable_chrome_trace = True
        options.enable_platform_display_trace = True
        tab.browser.platform.tracing_controller.Start(options, category_filter,
                                                      60)

    def Stop(self, tab):
        self._trace_data = tab.browser.platform.tracing_controller.Stop()
        self._timeline_model = TimelineModel(self._trace_data)

    def AddResults(self, tab, results):
        # Add results of smoothness metric. This computes the smoothness metric for
        # the time ranges of gestures, if there is at least one, else the the time
        # ranges from the first action to the last action.
        results.AddValue(
            trace.TraceValue(results.current_page, self._trace_data))
        renderer_thread = self._timeline_model.GetRendererThreadFromTabId(
            tab.id)
        smooth_records = []
        for event in renderer_thread.async_slices:
            if not tir_module.IsTimelineInteractionRecord(event.name):
                continue
            r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
            smooth_records.append(
                smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
                    self._timeline_model, r))

        # If there is no other smooth records, we make measurements on time range
        # marked smoothness_controller itself.
        # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
        # page sets are responsible for issueing the markers themselves.
        if len(smooth_records) == 0:
            raise page_test.Failure('Page failed to issue any markers.')

        # Check to make sure all smooth records have same label and repeatable if
        # there are more than one.
        need_repeatable_flag = len(smooth_records) > 1
        record_label = smooth_records[0].label
        for r in smooth_records:
            if r.label != record_label:
                raise page_test.Failure(
                    'SmoothController does not support multiple interactions with '
                    'different label. Interactions: %s' % repr(smooth_records))
            if need_repeatable_flag and not r.repeatable:
                raise page_test.Failure(
                    'If there are more than one interaction record, each interaction '
                    'must has repeatable flag. Interactions: %s' %
                    repr(smooth_records))

        # Create an interaction_record for this legacy measurement. Since we don't
        # wrap the results that are sent to smoothness metric, the label will
        # not be used.
        smoothness_metric = smoothness.SmoothnessMetric()
        smoothness_metric.AddResults(self._timeline_model, renderer_thread,
                                     smooth_records, results)

    def CleanUp(self, tab):
        if tab.browser.platform.tracing_controller.is_tracing_running:
            tab.browser.platform.tracing_controller.Stop()
Exemple #13
0
class TimelineController(object):
  def __init__(self):
    super(TimelineController, self).__init__()
    self.trace_categories = None
    self._model = None
    self._renderer_process = None
    self._smooth_records = []
    self._interaction = None

  def SetUp(self, page, tab):
    """Starts gathering timeline data.

    """
    # Resets these member variables incase this object is reused.
    self._model = None
    self._renderer_process = None
    if not tab.browser.platform.tracing_controller.IsChromeTracingSupported():
      raise Exception('Not supported')
    category_filter = tracing_category_filter.TracingCategoryFilter(
        filter_string=self.trace_categories)
    for delay in page.GetSyntheticDelayCategories():
      category_filter.AddSyntheticDelay(delay)
    options = tracing_options.TracingOptions()
    options.enable_chrome_trace = True
    tab.browser.platform.tracing_controller.Start(options, category_filter)

  def Start(self, tab):
    # Start the smooth marker for all actions.
    runner = action_runner.ActionRunner(tab)
    self._interaction = runner.CreateInteraction(
        RUN_SMOOTH_ACTIONS)
    self._interaction.Begin()

  def Stop(self, tab, results):
    # End the smooth marker for all actions.
    self._interaction.End()
    # Stop tracing.
    timeline_data = tab.browser.platform.tracing_controller.Stop()
    results.AddValue(trace.TraceValue(
        results.current_page, timeline_data))
    self._model = TimelineModel(timeline_data)
    self._renderer_process = self._model.GetRendererProcessFromTabId(tab.id)
    renderer_thread = self.model.GetRendererThreadFromTabId(tab.id)

    run_smooth_actions_record = None
    self._smooth_records = []
    for event in renderer_thread.async_slices:
      if not tir_module.IsTimelineInteractionRecord(event.name):
        continue
      r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
      if r.label == RUN_SMOOTH_ACTIONS:
        assert run_smooth_actions_record is None, (
          'TimelineController cannot issue more than 1 %s record' %
          RUN_SMOOTH_ACTIONS)
        run_smooth_actions_record = r
      else:
        self._smooth_records.append(
          smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
            self.model, r))

    # If there is no other smooth records, we make measurements on time range
    # marked by timeline_controller itself.
    # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
    # page sets are responsible for issueing the markers themselves.
    if len(self._smooth_records) == 0 and run_smooth_actions_record:
      self._smooth_records = [run_smooth_actions_record]


  def CleanUp(self, tab):
    if tab.browser.platform.tracing_controller.is_tracing_running:
      tab.browser.platform.tracing_controller.Stop()

  @property
  def model(self):
    return self._model

  @property
  def renderer_process(self):
    return self._renderer_process

  @property
  def smooth_records(self):
    return self._smooth_records
class TimelineController(object):
    def __init__(self, enable_auto_issuing_record=True):
        super(TimelineController, self).__init__()
        self.trace_categories = None
        self._model = None
        self._renderer_process = None
        self._smooth_records = []
        self._interaction = None
        self._enable_auto_issuing_record = enable_auto_issuing_record

    def SetUp(self, page, tab):
        """Starts gathering timeline data.

    """
        del page  # unused
        # Resets these member variables incase this object is reused.
        self._model = None
        self._renderer_process = None
        if not tab.browser.platform.tracing_controller.IsChromeTracingSupported(
        ):
            raise Exception('Not supported')
        config = tracing_config.TracingConfig()
        config.chrome_trace_config.category_filter.AddFilterString(
            self.trace_categories)
        config.enable_chrome_trace = True
        tab.browser.platform.tracing_controller.StartTracing(config)

    def Start(self, tab):
        # Start the smooth marker for all actions.
        if self._enable_auto_issuing_record:
            self._interaction = tab.action_runner.CreateInteraction(
                RUN_SMOOTH_ACTIONS)
            self._interaction.Begin()

    def Stop(self, tab, results):
        # End the smooth marker for all actions.
        if self._enable_auto_issuing_record:
            self._interaction.End()
        # Stop tracing.
        timeline_data = tab.browser.platform.tracing_controller.StopTracing()

        # TODO(#763375): Rely on results.telemetry_info.trace_local_path/etc.
        kwargs = {}
        if hasattr(results.telemetry_info, 'trace_local_path'):
            kwargs['file_path'] = results.telemetry_info.trace_local_path
            kwargs['remote_path'] = results.telemetry_info.trace_remote_path
            kwargs['upload_bucket'] = results.telemetry_info.upload_bucket
            kwargs['cloud_url'] = results.telemetry_info.trace_remote_url
        results.AddValue(
            trace.TraceValue(results.current_page, timeline_data, **kwargs))

        self._model = TimelineModel(timeline_data)
        self._renderer_process = self._model.GetRendererProcessFromTabId(
            tab.id)
        renderer_thread = self.model.GetRendererThreadFromTabId(tab.id)

        run_smooth_actions_record = None
        self._smooth_records = []
        for event in renderer_thread.async_slices:
            if not tir_module.IsTimelineInteractionRecord(event.name):
                continue
            r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
            if r.label == RUN_SMOOTH_ACTIONS:
                assert run_smooth_actions_record is None, (
                    'TimelineController cannot issue more than 1 %s record' %
                    RUN_SMOOTH_ACTIONS)
                run_smooth_actions_record = r
            else:
                self._smooth_records.append(
                    smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
                        self.model, r))

        # If there is no other smooth records, we make measurements on time range
        # marked by timeline_controller itself.
        # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
        # page sets are responsible for issueing the markers themselves.
        if len(self._smooth_records) == 0 and run_smooth_actions_record:
            self._smooth_records = [run_smooth_actions_record]

        if len(self._smooth_records) == 0:
            raise legacy_page_test.Failure(
                'No interaction record was created.')

    def CleanUp(self, platform):
        if platform.tracing_controller.is_tracing_running:
            platform.tracing_controller.StopTracing()

    @property
    def model(self):
        return self._model

    @property
    def renderer_process(self):
        return self._renderer_process

    @property
    def smooth_records(self):
        return self._smooth_records
class SmoothnessController(object):
    def __init__(self):
        self._timeline_model = None
        self._tracing_timeline_data = None
        self._interaction = None

    def SetUp(self, page, tab):
        # FIXME: Remove webkit.console when blink.console lands in chromium and
        # the ref builds are updated. crbug.com/386847
        custom_categories = ['webkit.console', 'blink.console', 'benchmark']
        custom_categories += page.GetSyntheticDelayCategories()
        category_filter = tracing_category_filter.TracingCategoryFilter()
        for c in custom_categories:
            category_filter.AddIncludedCategory(c)
        options = tracing_options.TracingOptions()
        options.enable_chrome_trace = True
        tab.browser.platform.tracing_controller.Start(options, category_filter,
                                                      60)
        if tab.browser.platform.IsRawDisplayFrameRateSupported():
            tab.browser.platform.StartRawDisplayFrameRateMeasurement()

    def Start(self, tab):
        # Start the smooth marker for all smooth actions.
        runner = action_runner.ActionRunner(tab)
        self._interaction = runner.BeginInteraction(RUN_SMOOTH_ACTIONS,
                                                    is_smooth=True)

    def Stop(self, tab):
        # End the smooth marker for all smooth actions.
        self._interaction.End()
        # Stop tracing for smoothness metric.
        if tab.browser.platform.IsRawDisplayFrameRateSupported():
            tab.browser.platform.StopRawDisplayFrameRateMeasurement()
        self._tracing_timeline_data = tab.browser.platform.tracing_controller.Stop(
        )
        self._timeline_model = TimelineModel(
            timeline_data=self._tracing_timeline_data)

    def AddResults(self, tab, results):
        # Add results of smoothness metric. This computes the smoothness metric for
        # the time ranges of gestures, if there is at least one, else the the time
        # ranges from the first action to the last action.

        renderer_thread = self._timeline_model.GetRendererThreadFromTabId(
            tab.id)
        run_smooth_actions_record = None
        smooth_records = []
        for event in renderer_thread.async_slices:
            if not tir_module.IsTimelineInteractionRecord(event.name):
                continue
            r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
            if r.label == RUN_SMOOTH_ACTIONS:
                assert run_smooth_actions_record is None, (
                    'SmoothnessController cannot issue more than 1 %s record' %
                    RUN_SMOOTH_ACTIONS)
                run_smooth_actions_record = r
            elif r.is_smooth:
                smooth_records.append(
                    smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
                        self._timeline_model, r))

        # If there is no other smooth records, we make measurements on time range
        # marked smoothness_controller itself.
        # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
        # page sets are responsible for issueing the markers themselves.
        if len(smooth_records) == 0:
            if run_smooth_actions_record is None:
                sys.stderr.write('Raw tracing data:\n')
                sys.stderr.write(repr(self._tracing_timeline_data.EventData()))
                sys.stderr.write('\n')
                raise Exception(
                    'SmoothnessController failed to issue markers for the '
                    'whole interaction.')
            else:
                smooth_records = [run_smooth_actions_record]

        # Create an interaction_record for this legacy measurement. Since we don't
        # wrap the results that are sent to smoothness metric, the label will
        # not be used.
        smoothness_metric = smoothness.SmoothnessMetric()
        smoothness_metric.AddResults(self._timeline_model, renderer_thread,
                                     smooth_records, results)
        if tab.browser.platform.IsRawDisplayFrameRateSupported():
            for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements():
                if r.value is None:
                    raise MissingDisplayFrameRateError(r.name)
                if isinstance(r.value, list):
                    results.AddValue(
                        list_of_scalar_values.ListOfScalarValues(
                            results.current_page,
                            r.name,
                            r.unit,
                            r.value,
                            description=DESCRIPTIONS.get(r.name)))
                else:
                    results.AddValue(
                        scalar.ScalarValue(results.current_page,
                                           r.name,
                                           r.unit,
                                           r.value,
                                           description=DESCRIPTIONS.get(
                                               r.name)))

    def CleanUp(self, tab):
        if tab.browser.platform.IsRawDisplayFrameRateSupported():
            tab.browser.platform.StopRawDisplayFrameRateMeasurement()
        if tab.browser.platform.tracing_controller.is_tracing_running:
            tab.browser.platform.tracing_controller.Stop()
Exemple #16
0
class TimelineController(object):
    def __init__(self):
        super(TimelineController, self).__init__()
        self.trace_categories = tracing_backend.DEFAULT_TRACE_CATEGORIES
        self._model = None
        self._renderer_process = None
        self._smooth_records = []
        self._interaction = None

    def Start(self, page, tab):
        """Starts gathering timeline data.

    """
        # Resets these member variables incase this object is reused.
        self._model = None
        self._renderer_process = None
        if not tab.browser.supports_tracing:
            raise Exception('Not supported')
        if self.trace_categories:
            categories = [self.trace_categories] + \
                page.GetSyntheticDelayCategories()
        else:
            categories = page.GetSyntheticDelayCategories()
        tab.browser.StartTracing(','.join(categories))
        # Start the smooth marker for all actions.
        runner = action_runner.ActionRunner(tab)
        self._interaction = runner.BeginInteraction(RUN_SMOOTH_ACTIONS,
                                                    is_smooth=True)

    def Stop(self, tab):
        # End the smooth marker for all actions.
        self._interaction.End()
        # Stop tracing.
        timeline_data = tab.browser.StopTracing()
        self._model = TimelineModel(timeline_data)
        self._renderer_process = self._model.GetRendererProcessFromTabId(
            tab.id)
        renderer_thread = self.model.GetRendererThreadFromTabId(tab.id)

        run_smooth_actions_record = None
        self._smooth_records = []
        for event in renderer_thread.async_slices:
            if not tir_module.IsTimelineInteractionRecord(event.name):
                continue
            r = tir_module.TimelineInteractionRecord.FromAsyncEvent(event)
            if r.logical_name == RUN_SMOOTH_ACTIONS:
                assert run_smooth_actions_record is None, (
                    'TimelineController cannot issue more than 1 %s record' %
                    RUN_SMOOTH_ACTIONS)
                run_smooth_actions_record = r
            elif r.is_smooth:
                self._smooth_records.append(
                    smooth_gesture_util.GetAdjustedInteractionIfContainGesture(
                        self.model, r))

        # If there is no other smooth records, we make measurements on time range
        # marked by timeline_controller itself.
        # TODO(nednguyen): when crbug.com/239179 is marked fixed, makes sure that
        # page sets are responsible for issueing the markers themselves.
        if len(self._smooth_records) == 0 and run_smooth_actions_record:
            self._smooth_records = [run_smooth_actions_record]

    def CleanUp(self, tab):
        if tab.browser.is_tracing_running:
            tab.browser.StopTracing()

    @property
    def model(self):
        return self._model

    @property
    def renderer_process(self):
        return self._renderer_process

    @property
    def smooth_records(self):
        return self._smooth_records
 def Stop(self, tab):
   # End the smooth marker for  all smooth actions.
   self._interaction.End()
   self._trace_data = tab.browser.platform.tracing_controller.Stop()
   self._timeline_model = TimelineModel(self._trace_data)
Exemple #18
0
 def Stop(self, tab):
     self._trace_data = tab.browser.platform.tracing_controller.Stop()
     self._timeline_model = TimelineModel(self._trace_data)
Exemple #19
0
 def DidRunActions(self, page, tab):
     timeline_data = tab.browser.platform.tracing_controller.Stop()
     self._timeline_model = TimelineModel(timeline_data)