Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tools/telemetry/telemetry/web_perf/timeline_based_measurement_unittest.py

Issue 1313243003: [Telemetry] Introduce SummarizableValue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/telemetry/telemetry/web_perf/metrics/smoothness.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import unittest 6 import unittest
7 7
8 from telemetry import story 8 from telemetry import story
9 from telemetry.internal.results import page_test_results 9 from telemetry.internal.results import page_test_results
10 from telemetry.page import page as page_module 10 from telemetry.page import page as page_module
11 from telemetry.timeline import async_slice 11 from telemetry.timeline import async_slice
12 from telemetry.timeline import model as model_module 12 from telemetry.timeline import model as model_module
13 from telemetry.value import improvement_direction
13 from telemetry.value import scalar 14 from telemetry.value import scalar
14 from telemetry.web_perf.metrics import timeline_based_metric 15 from telemetry.web_perf.metrics import timeline_based_metric
15 from telemetry.web_perf import timeline_based_measurement as tbm_module 16 from telemetry.web_perf import timeline_based_measurement as tbm_module
16 17
17 18
18 class FakeSmoothMetric(timeline_based_metric.TimelineBasedMetric): 19 class FakeSmoothMetric(timeline_based_metric.TimelineBasedMetric):
19 20
20 def AddResults(self, model, renderer_thread, interaction_records, results): 21 def AddResults(self, model, renderer_thread, interaction_records, results):
21 results.AddValue(scalar.ScalarValue( 22 results.AddValue(scalar.ScalarValue(
22 results.current_page, 'FakeSmoothMetric', 'ms', 1)) 23 results.current_page, 'FakeSmoothMetric', 'ms', 1,
24 improvement_direction=improvement_direction.DOWN))
23 results.AddValue(scalar.ScalarValue( 25 results.AddValue(scalar.ScalarValue(
24 results.current_page, 'SmoothMetricRecords', 'count', 26 results.current_page, 'SmoothMetricRecords', 'count',
25 len(interaction_records))) 27 len(interaction_records),
28 improvement_direction=improvement_direction.DOWN))
26 29
27 30
28 class FakeLoadingMetric(timeline_based_metric.TimelineBasedMetric): 31 class FakeLoadingMetric(timeline_based_metric.TimelineBasedMetric):
29 32
30 def AddResults(self, model, renderer_thread, interaction_records, results): 33 def AddResults(self, model, renderer_thread, interaction_records, results):
31 results.AddValue(scalar.ScalarValue( 34 results.AddValue(scalar.ScalarValue(
32 results.current_page, 'FakeLoadingMetric', 'ms', 2)) 35 results.current_page, 'FakeLoadingMetric', 'ms', 2,
36 improvement_direction=improvement_direction.DOWN))
33 results.AddValue(scalar.ScalarValue( 37 results.AddValue(scalar.ScalarValue(
34 results.current_page, 'LoadingMetricRecords', 'count', 38 results.current_page, 'LoadingMetricRecords', 'count',
35 len(interaction_records))) 39 len(interaction_records),
40 improvement_direction=improvement_direction.DOWN))
36 41
37 42
38 class TimelineBasedMetricTestData(object): 43 class TimelineBasedMetricTestData(object):
39 44
40 def __init__(self, options): 45 def __init__(self, options):
41 self._model = model_module.TimelineModel() 46 self._model = model_module.TimelineModel()
42 renderer_process = self._model.GetOrCreateProcess(1) 47 renderer_process = self._model.GetOrCreateProcess(1)
43 self._renderer_thread = renderer_process.GetOrCreateThread(2) 48 self._renderer_thread = renderer_process.GetOrCreateThread(2)
44 self._renderer_thread.name = 'CrRendererMain' 49 self._renderer_thread.name = 'CrRendererMain'
45 self._foo_thread = renderer_process.GetOrCreateThread(3) 50 self._foo_thread = renderer_process.GetOrCreateThread(3)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 183
179 def testDuplicateRepeatableInteractions(self): 184 def testDuplicateRepeatableInteractions(self):
180 d = TimelineBasedMetricTestData(self._options) 185 d = TimelineBasedMetricTestData(self._options)
181 d.AddInteraction(d.renderer_thread, ts=10, duration=5, 186 d.AddInteraction(d.renderer_thread, ts=10, duration=5,
182 marker='Interaction.LogicalName/repeatable') 187 marker='Interaction.LogicalName/repeatable')
183 d.AddInteraction(d.renderer_thread, ts=20, duration=5, 188 d.AddInteraction(d.renderer_thread, ts=20, duration=5,
184 marker='Interaction.LogicalName/repeatable') 189 marker='Interaction.LogicalName/repeatable')
185 d.FinalizeImport() 190 d.FinalizeImport()
186 d.AddResults() 191 d.AddResults()
187 self.assertEquals(1, len(d.results.pages_that_succeeded)) 192 self.assertEquals(1, len(d.results.pages_that_succeeded))
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/web_perf/metrics/smoothness.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698