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

Unified Diff: tools/perf/metrics/timeline_unittest.py

Issue 139743018: Telemetry: Remove 'overhead' time from thread times measurement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TELEMETRY_fix_trace_import_precision
Patch Set: Rebase. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/perf/metrics/timeline.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/metrics/timeline_unittest.py
diff --git a/tools/perf/metrics/timeline_unittest.py b/tools/perf/metrics/timeline_unittest.py
index 6b3c9a00dfd583c408f828462e03e1e7f3cdf52c..ebc72eb1d8da4e2b22b0a38ce4b51badc7d59c89 100644
--- a/tools/perf/metrics/timeline_unittest.py
+++ b/tools/perf/metrics/timeline_unittest.py
@@ -91,6 +91,27 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase):
metric.AddResults(tab, results)
return results
+ def GetActionRange(self, start, end):
+ action_range = bounds.Bounds()
+ action_range.AddValue(start)
+ action_range.AddValue(end)
+ return action_range
+
+ def testResults(self):
+ model = model_module.TimelineModel()
+ renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2)
+ renderer_main.name = 'CrRendererMain'
+
+ metric = timeline.ThreadTimesTimelineMetric()
+ metric._action_ranges = [self.GetActionRange(1, 2)]
+ metric.details_to_report = timeline.ReportMainThreadOnly
+ results = self.GetResultsForModel(metric, model)
+
+ # Test that all result thread categories exist
+ for name in timeline.TimelineThreadCategories.values():
+ results.GetPageSpecificValueNamed(timeline.ThreadTimeResultName(name))
+ results.GetPageSpecificValueNamed(timeline.ThreadCpuTimeResultName(name))
+
def testBasic(self):
model = model_module.TimelineModel()
renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2)
@@ -99,9 +120,9 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase):
# Create two frame swaps (Results times should be divided by two)
cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3)
cc_main.name = 'Compositor'
- cc_main.BeginSlice('cc_cat', timeline.CompositorFrameTraceName, 10, 10)
+ cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 10, 10)
cc_main.EndSlice(11, 11)
- cc_main.BeginSlice('cc_cat', timeline.CompositorFrameTraceName, 12, 12)
+ cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 12, 12)
cc_main.EndSlice(13, 13)
# [ X ] [ Z ]
@@ -114,21 +135,12 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase):
renderer_main.BeginSlice('cat1', 'Z', 33, 21)
model.FinalizeImport()
- # Exclude Z using an action-range.
- action_range = bounds.Bounds()
- action_range.AddValue(10)
- action_range.AddValue(30)
-
+ # Exclude 'Z' using an action-range.
metric = timeline.ThreadTimesTimelineMetric()
- metric._action_ranges = [action_range]
- metric.details_to_report = timeline.MainThread
+ metric._action_ranges = [self.GetActionRange(10, 30)]
+ metric.details_to_report = timeline.ReportMainThreadOnly
results = self.GetResultsForModel(metric, model)
- # Test that all categories exist
- for name in timeline.TimelineThreadCategories.values():
- results.GetPageSpecificValueNamed(timeline.ThreadTimeResultName(name))
- results.GetPageSpecificValueNamed(timeline.ThreadCpuTimeResultName(name))
-
# Test a couple specific results.
assert_results = {
timeline.ThreadTimeResultName('renderer_main') : 10,
@@ -138,3 +150,38 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase):
}
for name, value in assert_results.iteritems():
results.AssertHasPageSpecificScalarValue(name, 'ms', value)
+
+ def testOverheadIsRemoved(self):
+ model = model_module.TimelineModel()
+ renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2)
+ renderer_main.name = 'CrRendererMain'
+
+ # Create one frame swap.
+ cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3)
+ cc_main.name = 'Compositor'
+ cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 10, 10)
+ cc_main.EndSlice(11, 11)
+
+ # [ X ]
+ # [Overhead]
+ overhead_category = timeline.OverheadTraceCategory
+ overhead_name = timeline.OverheadTraceName
+ renderer_main.BeginSlice('cat1', 'X', 10, 0)
+ renderer_main.BeginSlice(overhead_category, overhead_name, 15, 5)
+ renderer_main.EndSlice(16, 6)
+ renderer_main.EndSlice(30, 10)
+ model.FinalizeImport()
+
+ # Include everything in an action-range.
+ metric = timeline.ThreadTimesTimelineMetric()
+ metric._action_ranges = [self.GetActionRange(10, 30)]
+ metric.details_to_report = timeline.ReportMainThreadOnly
+ results = self.GetResultsForModel(metric, model)
+
+ # Test a couple specific results.
+ assert_results = {
+ timeline.ThreadTimeResultName('renderer_main') : 19,
+ timeline.ThreadCpuTimeResultName('renderer_main') : 9.0,
+ }
+ for name, value in assert_results.iteritems():
+ results.AssertHasPageSpecificScalarValue(name, 'ms', value)
« no previous file with comments | « tools/perf/metrics/timeline.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698