Chromium Code Reviews| 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..8dc34f2da1f0f6b6eb86c34f30db616d5938e7de 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), |
|
nednguyen
2015/05/08 21:13:19
Why do these get removed?
jdduke (slow)
2015/05/08 21:58:56
Ah, they're still there but I moved them below the
|
| (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, 'ms'), |
| + 'tasks', 1.0 / num_ms), |
| + (timeline.ThreadTasksResultName(cc_thread, 'frame'), |
| + 'tasks', 2.0 / num_frames), |
| + (timeline.ThreadTasksResultName(cc_thread, 'ms'), |
| + 'tasks', 2.0 / num_ms), |
| + (timeline.ThreadCpuTimeResultName(main_thread, 'frame'), |
| + 'ms', 19.5 / num_frames), |
| + (timeline.ThreadCpuTimeResultName(main_thread, 'ms'), |
| + '%', 19.5 / num_ms * 100), |
| + (timeline.ThreadCpuTimeResultName(cc_thread, 'frame'), |
| + 'ms', 2.0 / num_frames), |
| + (timeline.ThreadCpuTimeResultName(cc_thread, 'ms'), |
| + '%', 2.0 / num_ms * 100), |
| + (timeline.ThreadDetailResultName(main_thread, 'frame', 'cat1'), |
| + 'ms', 19.0 / num_frames), |
| + (timeline.ThreadDetailResultName(main_thread, 'ms', 'cat1'), |
| + '%', 19.0 / num_ms * 100), |
| + (timeline.ThreadDetailResultName(main_thread, 'frame', 'cat2'), |
| + 'ms', 1.0 / num_frames), |
| + (timeline.ThreadDetailResultName(main_thread, 'ms', 'cat2'), |
| + '%', 1.0 / num_ms * 100), |
| + (timeline.ThreadDetailResultName(main_thread, 'frame', 'idle'), 'ms', 0), |
| + (timeline.ThreadDetailResultName(main_thread, 'ms', 'idle'), '%', 0) |
| ] |
| 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', 'ms') , '%', 45.0), |
| + ] |
| + for name, unit, value in assert_results: |
| + results.AssertHasPageSpecificScalarValue(name, unit, value) |