def testFiltering(self):
    # These should be recorded.
    self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 10, 8, 10, 5)
    self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 14, 2, 14, 2)
    self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 20, 6, 20, 1)

    # These should be filtered.
    self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 15, 1, 15, 1)
    self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY2, EVENT_NAME1, 11, 4, 11, 4)
    self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME2, 11, 3, 11, 3)
    self.AddEvent(OTHER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 11, 2, 11, 2)

    interactions = [TestInteraction(9, 14), TestInteraction(20, 21)]

    aggregator = TraceEventStats()
    # Test that we default to 'Renderer'
    aggregator.AddInput(TraceEventStatsInput(
      EVENT_CATEGORY1,
      EVENT_NAME1,
      'metric-name',
      'metric-description',
      'units'))

    results = self.RunAggregator(aggregator, interactions)
    results.AssertHasPageSpecificScalarValue('metric-name-count', 'count', 3)
    results.AssertHasPageSpecificListOfScalarValues(
      'metric-name', 'units', [5, 2, 1])
示例#2
0
    def testNoEvents(self):
        interactions = [TestInteraction(9, 14)]

        aggregator = TraceEventStats()
        aggregator.AddInput(
            TraceEventStatsInput(EVENT_CATEGORY1, EVENT_NAME1, 'metric-name',
                                 'metric-description', 'units'))

        results = self.RunAggregator(aggregator, interactions)
        self.assertEquals([], results.all_page_specific_values)
示例#3
0
    def testNoInputs(self):
        # These should be recorded.
        self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 10, 8,
                      10, 5)
        self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 14, 2,
                      14, 2)
        self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 20, 6,
                      20, 1)

        # These should be filtered.
        self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 15, 1,
                      15, 1)
        self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY2, EVENT_NAME1, 11, 4,
                      11, 4)
        self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME2, 11, 3,
                      11, 3)
        self.AddEvent(OTHER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 11, 2, 11,
                      2)

        interactions = [TestInteraction(9, 14), TestInteraction(20, 21)]

        aggregator = TraceEventStats()

        results = self.RunAggregator(aggregator, interactions)
        self.assertEquals([], results.all_page_specific_values)
示例#4
0
    def testBasicUsage(self):
        self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 10, 8,
                      10, 5)
        self.AddEvent(RENDERER_PROCESS, EVENT_CATEGORY1, EVENT_NAME1, 14, 2,
                      14, 2)
        interactions = [TestInteraction(9, 14)]

        aggregator = TraceEventStats()
        aggregator.AddInput(
            TraceEventStatsInput(EVENT_CATEGORY1, EVENT_NAME1, 'metric-name',
                                 'metric-description', 'units', 'Renderer'))

        results = self.RunAggregator(aggregator, interactions)
        results.AssertHasPageSpecificScalarValue('metric-name-count', 'count',
                                                 2)
        results.AssertHasPageSpecificListOfScalarValues(
            'metric-name', 'units', [5, 2])
示例#5
0
class IndexedDBTimelineMetric(timeline_based_metric.TimelineBasedMetric):
    """Metrics for IndexedDB operations.
  """
    def __init__(self):
        super(IndexedDBTimelineMetric, self).__init__()
        self._stats = TraceEventStats()

        self._stats.AddInput(
            TraceEventStatsInput(
                event_category='IndexedDB',
                event_name='IndexedDBDatabase::GetOperation',
                metric_name='idb-gets',
                metric_description='The duration of all "get" ops in IndexedDB',
                units='ms',
                process_name='Browser'))

        self._stats.AddInput(
            TraceEventStatsInput(
                event_category='IndexedDB',
                event_name='IndexedDBDatabase::PutOperation',
                metric_name='idb-puts',
                metric_description='The duration of all "put" ops in IndexedDB',
                units='ms',
                process_name='Browser'))

        self._stats.AddInput(
            TraceEventStatsInput(event_category='IndexedDB',
                                 event_name='IndexedDBFactoryImpl::Open',
                                 metric_name='idb-opens',
                                 metric_description=
                                 'The duration of all "open" ops in IndexedDB',
                                 units='ms',
                                 process_name='Browser'))

        self._stats.AddInput(
            TraceEventStatsInput(
                event_category='IndexedDB',
                event_name='IndexedDBTransaction::Commit',
                metric_name='idb-transaction-commits',
                metric_description=('The duration of all "commit" ops of ' +
                                    'transactions in IndexedDB.'),
                units='ms',
                process_name='Browser'))

        self._stats.AddInput(
            TraceEventStatsInput(
                event_category='IndexedDB',
                event_name='IndexedDBFactoryImpl::DeleteDatabase',
                metric_name='idb-database-deletes',
                metric_description=('The duration of all "delete" ops of ' +
                                    'IndexedDB databases.'),
                units='ms',
                process_name='Browser'))

        self._stats.AddInput(
            TraceEventStatsInput(
                event_category='IndexedDB',
                event_name='IndexedDBDatabase::OpenCursorOperation',
                metric_name='idb-cursor-opens',
                metric_description=('The duration of all "open" ops of ' +
                                    'IndexedDB cursors.'),
                units='ms',
                process_name='Browser'))

        self._stats.AddInput(
            TraceEventStatsInput(
                event_category='IndexedDB',
                event_name='IndexedDBCursor::CursorIterationOperation',
                metric_name='idb-cursor-iterations',
                metric_description=('The duration of all "iteration" ops of ' +
                                    'IndexedDB cursors.'),
                units='ms',
                process_name='Browser'))

    def AddResults(self, model, renderer_process, interactions, results):
        self._stats.AddResults(model, renderer_process, interactions, results)