Example #1
0
 def FinalizeImport(self):
   self._model.FinalizeImport()
   self._metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
       self._model, self._renderer_thread, GetMetricFromMetricType)
   self._ps = page_set.PageSet(file_path=os.path.dirname(__file__))
   self._ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
   self._results.WillRunPage(self._ps.pages[0])
 def AddResults(self):
   for thread, records in self._threads_to_records_map.iteritems():
     metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
         self._model, thread, records, self._results_wrapper,
         self._tbm_options.GetTimelineBasedMetrics())
     metric.AddResults(self._results)
   self._results.DidRunPage(self._story_set.stories[0])
Example #3
0
 def FinalizeImport(self):
     self._model.FinalizeImport()
     self._metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
         self._model, self._renderer_thread, GetMetricFromMetricType)
     self._ps = page_set.PageSet(file_path=os.path.dirname(__file__))
     self._ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')
     self._results.WillRunPage(self._ps.pages[0])
Example #4
0
    def testFindTimelineInteractionRecords(self):
        metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
            self.model, self.renderer_thread, lambda _: [])
        interactions = metric.FindTimelineInteractionRecords()
        self.assertEquals(2, len(interactions))
        self.assertTrue(interactions[0].is_smooth)
        self.assertEquals(0, interactions[0].start)
        self.assertEquals(20, interactions[0].end)

        self.assertTrue(interactions[1].is_responsive)
        self.assertEquals(25, interactions[1].start)
        self.assertEquals(30, interactions[1].end)
Example #5
0
  def testFindTimelineInteractionRecords(self):
    metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
      self.model, self.renderer_thread, lambda _: [])
    interactions = metric.FindTimelineInteractionRecords()
    self.assertEquals(2, len(interactions))
    self.assertTrue(interactions[0].is_smooth)
    self.assertEquals(0, interactions[0].start)
    self.assertEquals(20, interactions[0].end)

    self.assertTrue(interactions[1].is_responsive)
    self.assertEquals(25, interactions[1].start)
    self.assertEquals(30, interactions[1].end)
    def AddResults(self):
        all_metrics = self._tbm_options.GetLegacyTimelineBasedMetrics()

        for thread, records in self._threads_to_records_map.iteritems():
            # pylint: disable=protected-access
            metric = tbm_module._TimelineBasedMetrics(self._model, thread, records, self._results_wrapper, all_metrics)
            metric.AddResults(self._results)

        for metric in all_metrics:
            metric.AddWholeTraceResults(self._model, self._results)

        self._results.DidRunPage(self._story_set.stories[0])
  def AddResults(self):
    all_metrics = self._tbm_options.GetTimelineBasedMetrics()

    for thread, records in self._threads_to_records_map.iteritems():
      metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
          self._model, thread, records, self._results_wrapper, all_metrics)
      metric.AddResults(self._results)

    for metric in all_metrics:
      metric.AddWholeTraceResults(self._model, self._results)

    self._results.DidRunPage(self._story_set.stories[0])
Example #8
0
    def testAddResults(self):
        results = page_measurement_results.PageMeasurementResults()

        class FakeSmoothMetric(timeline_based_metric.TimelineBasedMetric):
            def AddResults(self, model, renderer_thread, interaction_records,
                           results):
                results.Add('FakeSmoothMetric', 'ms', 1)

        class FakeLoadingMetric(timeline_based_metric.TimelineBasedMetric):
            def AddResults(self, model, renderer_thread, interaction_records,
                           results):
                for r in interaction_records:
                    assert r.logical_name == 'LogicalName2'
                results.Add('FakeLoadingMetric', 'ms', 2)

        def CreateMetricsForTimelineInteractionRecord(interaction):
            res = []
            if interaction.is_smooth:
                res.append(FakeSmoothMetric())
            if interaction.is_responsive:
                res.append(FakeLoadingMetric())
            return res

        metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
            self.model, self.renderer_thread,
            CreateMetricsForTimelineInteractionRecord)
        ps = page_set.PageSet(file_path=os.path.dirname(__file__))
        ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')

        results.WillMeasurePage(ps.pages[0])
        metric.AddResults(results)
        results.DidMeasurePage()

        v = results.FindAllPageSpecificValuesNamed(
            'LogicalName1-FakeSmoothMetric')
        self.assertEquals(len(v), 1)
        v = results.FindAllPageSpecificValuesNamed(
            'LogicalName2-FakeLoadingMetric')
        self.assertEquals(len(v), 1)
Example #9
0
  def testAddResults(self):
    results = page_measurement_results.PageMeasurementResults()

    class FakeSmoothMetric(timeline_based_metric.TimelineBasedMetric):

      def AddResults(self, model, renderer_thread,
                     interaction_records, results):
        results.Add('FakeSmoothMetric', 'ms', 1)

    class FakeLoadingMetric(timeline_based_metric.TimelineBasedMetric):

      def AddResults(self, model, renderer_thread,
                     interaction_records, results):
        for r in interaction_records:
          assert r.logical_name == 'LogicalName2'
        results.Add('FakeLoadingMetric', 'ms', 2)

    def CreateMetricsForTimelineInteractionRecord(interaction):
      res = []
      if interaction.is_smooth:
        res.append(FakeSmoothMetric())
      if interaction.is_responsive:
        res.append(FakeLoadingMetric())
      return res

    metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
        self.model, self.renderer_thread,
        CreateMetricsForTimelineInteractionRecord)
    ps = page_set.PageSet(file_path=os.path.dirname(__file__))
    ps.AddPageWithDefaultRunNavigate('http://www.bar.com/')

    results.WillMeasurePage(ps.pages[0])
    metric.AddResults(results)
    results.DidMeasurePage()

    v = results.FindAllPageSpecificValuesNamed('LogicalName1-FakeSmoothMetric')
    self.assertEquals(len(v), 1)
    v = results.FindAllPageSpecificValuesNamed('LogicalName2-FakeLoadingMetric')
    self.assertEquals(len(v), 1)
 def AddResults(self):
   for thread, records in self._threads_to_records_map.iteritems():
     metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
       self._model, thread, records, GetMetricFromMetricType)
     metric.AddResults(self._results)
   self._results.DidRunPage(self._ps.pages[0])
 def AddResults(self):
     for thread, records in self._threads_to_records_map.iteritems():
         metric = tbm_module._TimelineBasedMetrics(  # pylint: disable=W0212
             self._model, thread, records)
         metric.AddResults(self._results)
     self._results.DidRunPage(self._ps.pages[0])