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

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

Issue 1084533005: Support total and per-second task/threadtime timeline metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change interval to seconds Created 5 years, 7 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 5ae1a5d66fdc65e9e141fee500ae54cde962b0d2..2c08816785c851c4ba5a9878eb71ad66735e34ec 100644
--- a/tools/perf/metrics/timeline_unittest.py
+++ b/tools/perf/metrics/timeline_unittest.py
@@ -109,14 +109,16 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase):
# Test that all result thread categories exist
for name in timeline.TimelineThreadCategories.values():
- results.GetPageSpecificValueNamed(timeline.ThreadCpuTimeResultName(name))
+ results.GetPageSpecificValueNamed(
+ timeline.ThreadCpuTimeResultName(name, 'frame'))
def testBasic(self):
model = model_module.TimelineModel()
renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2)
renderer_main.name = 'CrRendererMain'
- # Create two frame swaps (Results times should be divided by two)
+ # Create two frame swaps (Results times should be divided by two) for
+ # an interaction that lasts 20 milliseconds.
cc_main = model.GetOrCreateProcess(1).GetOrCreateThread(3)
cc_main.name = 'Compositor'
cc_main.BeginSlice('cc_cat', timeline.FrameTraceName, 10, 10)
@@ -143,13 +145,36 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase):
# Test for the results we expect.
main_thread = "renderer_main"
cc_thread = 'renderer_compositor'
+ num_frames = 2
+ num_ms = 20
assert_results = [
- (timeline.ThreadCpuTimeResultName(main_thread), 'ms', 9.75),
- (timeline.ThreadTasksResultName(main_thread), 'tasks', 0.5),
(timeline.ThreadMeanFrameTimeResultName(cc_thread), 'ms', 10.0),
- (timeline.ThreadDetailResultName(main_thread,'cat1'), 'ms', 9.5),
- (timeline.ThreadDetailResultName(main_thread,'cat2'), 'ms', 0.5),
- (timeline.ThreadDetailResultName(main_thread,'idle'), 'ms', 0)
+ (timeline.ThreadTasksResultName(main_thread, 'frame'),
+ 'tasks', 1.0 / num_frames),
+ (timeline.ThreadTasksResultName(main_thread, 'second'),
+ 'tasks', 1.0 / num_ms * 1000),
+ (timeline.ThreadTasksResultName(cc_thread, 'frame'),
+ 'tasks', 2.0 / num_frames),
+ (timeline.ThreadTasksResultName(cc_thread, 'second'),
+ 'tasks', 2.0 / num_ms * 1000),
+ (timeline.ThreadCpuTimeResultName(main_thread, 'frame'),
+ 'ms', 19.5 / num_frames),
+ (timeline.ThreadCpuTimeResultName(main_thread, 'second'),
+ '%', 19.5 / num_ms * 100),
+ (timeline.ThreadCpuTimeResultName(cc_thread, 'frame'),
+ 'ms', 2.0 / num_frames),
+ (timeline.ThreadCpuTimeResultName(cc_thread, 'second'),
+ '%', 2.0 / num_ms * 100),
+ (timeline.ThreadDetailResultName(main_thread, 'frame', 'cat1'),
+ 'ms', 19.0 / num_frames),
+ (timeline.ThreadDetailResultName(main_thread, 'second', 'cat1'),
+ '%', 19.0 / num_ms * 100),
+ (timeline.ThreadDetailResultName(main_thread, 'frame', 'cat2'),
+ 'ms', 1.0 / num_frames),
+ (timeline.ThreadDetailResultName(main_thread, 'second', 'cat2'),
+ '%', 1.0 / num_ms * 100),
+ (timeline.ThreadDetailResultName(main_thread, 'frame', 'idle'), 'ms', 0),
+ (timeline.ThreadDetailResultName(main_thread, 'second', 'idle'), '%', 0)
]
nednguyen 2015/05/11 22:56:02 Nits: I would prefer the style of the left where t
jdduke (slow) 2015/05/11 23:44:41 Done.
for name, unit, value in assert_results:
results.AssertHasPageSpecificScalarValue(name, unit, value)
@@ -182,8 +207,9 @@ class ThreadTimesTimelineMetricUnittest(unittest.TestCase):
[_GetInteractionRecord(10, 30)])
# Test a couple specific results.
- assert_results = {
- timeline.ThreadCpuTimeResultName('renderer_main') : 9.0,
- }
- for name, value in assert_results.iteritems():
- results.AssertHasPageSpecificScalarValue(name, 'ms', value)
+ assert_results = [
+ (timeline.ThreadCpuTimeResultName('renderer_main', 'frame') , 'ms', 9.0),
+ (timeline.ThreadCpuTimeResultName('renderer_main', 'second') , '%', 45.0),
+ ]
+ for name, unit, value in assert_results:
+ results.AssertHasPageSpecificScalarValue(name, unit, 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