| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. | 5 found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 | 7 |
| 8 <link rel="import" href="/tracing/base/assert_utils.html"> | 8 <link rel="import" href="/tracing/base/assert_utils.html"> |
| 9 <link rel="import" href="/tracing/core/test_utils.html"> | 9 <link rel="import" href="/tracing/core/test_utils.html"> |
| 10 <link rel="import" href="/tracing/extras/chrome/estimated_input_latency.html"> | 10 <link rel="import" href="/tracing/extras/chrome/estimated_input_latency.html"> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', | 49 title: 'TaskQueueManager::ProcessTaskFromWorkQueue', |
| 50 start: startTime, | 50 start: startTime, |
| 51 duration | 51 duration |
| 52 }); | 52 }); |
| 53 } | 53 } |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Adds a FrameLoader snapshot to rendererProcess that is used by test FMP | 56 * Adds a FrameLoader snapshot to rendererProcess that is used by test FMP |
| 57 * candidate slices. | 57 * candidate slices. |
| 58 */ | 58 */ |
| 59 function addTestFrame(rendererProcess) { | 59 function addTestFrame(rendererProcess, mainThread) { |
| 60 rendererProcess.objects.addSnapshot( | 60 rendererProcess.objects.addSnapshot( |
| 61 'ptr', 'loading', 'FrameLoader', 300, { | 61 'ptr', 'loading', 'FrameLoader', 300, { |
| 62 isLoadingMainFrame: true, | 62 isLoadingMainFrame: true, |
| 63 frame: {id_ref: '0xdeadbeef'}, | 63 frame: {id_ref: '0xdeadbeef'}, |
| 64 documentLoaderURL: 'http://example.com' | 64 documentLoaderURL: 'http://example.com' |
| 65 }); | 65 }); |
| 66 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| 67 cat: 'loading', |
| 68 title: 'markAsMainFrame', |
| 69 start: 300, |
| 70 duration: 0.0, |
| 71 args: {frame: '0xdeadbeef'} |
| 72 })); |
| 66 } | 73 } |
| 67 | 74 |
| 68 function addNavigationStart(mainThread, startNavTime) { | 75 function addNavigationStart(mainThread, startNavTime) { |
| 69 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ | 76 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({ |
| 70 cat: 'blink.user_timing', | 77 cat: 'blink.user_timing', |
| 71 title: 'navigationStart', | 78 title: 'navigationStart', |
| 72 start: startNavTime, | 79 start: startNavTime, |
| 73 duration: 0.0, | 80 duration: 0.0, |
| 74 args: {frame: '0xdeadbeef'} | 81 args: {frame: '0xdeadbeef'} |
| 75 })); | 82 })); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 assert.deepEqual(navStartTimestamps, [0, 10, 30]); | 123 assert.deepEqual(navStartTimestamps, [0, 10, 30]); |
| 117 }); | 124 }); |
| 118 | 125 |
| 119 /** | 126 /** |
| 120 * Checks getInteractiveTimestamps works as intended. If the definition of | 127 * Checks getInteractiveTimestamps works as intended. If the definition of |
| 121 * TTI metric changes, this test may begin to fail and we may need to adjust | 128 * TTI metric changes, this test may begin to fail and we may need to adjust |
| 122 * our EIL implementation. | 129 * our EIL implementation. |
| 123 */ | 130 */ |
| 124 test('getInteractiveTimestamps', () => { | 131 test('getInteractiveTimestamps', () => { |
| 125 const model = createTestModel(rendererProcess => { | 132 const model = createTestModel(rendererProcess => { |
| 126 addTestFrame(rendererProcess); | |
| 127 | |
| 128 const mainThread = rendererProcess.getOrCreateThread(MAIN_THREAD_ID); | 133 const mainThread = rendererProcess.getOrCreateThread(MAIN_THREAD_ID); |
| 134 addTestFrame(rendererProcess, mainThread); |
| 129 addNavigationStart(mainThread, 0); | 135 addNavigationStart(mainThread, 0); |
| 130 addFMPCandidate(mainThread, 5000); | 136 addFMPCandidate(mainThread, 5000); |
| 131 | 137 |
| 132 addNavigationStart(mainThread, 100000); | 138 addNavigationStart(mainThread, 100000); |
| 133 addFMPCandidate(mainThread, 110000); | 139 addFMPCandidate(mainThread, 110000); |
| 134 | 140 |
| 135 // To detect when a page has become interactive, we need to find a large | 141 // To detect when a page has become interactive, we need to find a large |
| 136 // enough window of no long tasks. Adding a dummy task sufficiently far | 142 // enough window of no long tasks. Adding a dummy task sufficiently far |
| 137 // away extends the bounds of the model so that it can contain this | 143 // away extends the bounds of the model so that it can contain this |
| 138 // window. In a non-test scenario, we always record traces for long enough | 144 // window. In a non-test scenario, we always record traces for long enough |
| 139 // that this is not an issue. | 145 // that this is not an issue. |
| 140 addDummyTask(mainThread, 900000); | 146 addDummyTask(mainThread, 900000); |
| 141 }); | 147 }); |
| 142 | 148 |
| 143 const interactiveTimestampsMap = getInteractiveTimestamps(model); | 149 const interactiveTimestampsMap = getInteractiveTimestamps(model); |
| 144 const interactiveTimestamps = | 150 const interactiveTimestamps = |
| 145 interactiveTimestampsMap.get(RENDERER_PROCESS_ID); | 151 interactiveTimestampsMap.get(RENDERER_PROCESS_ID); |
| 146 assert.deepEqual( | 152 assert.deepEqual( |
| 147 interactiveTimestamps.sort((a, b) => a - b), [5000, 110000]); | 153 interactiveTimestamps.sort((a, b) => a - b), [5000, 110000]); |
| 148 }); | 154 }); |
| 149 | 155 |
| 150 test('getInteractiveTimestampsMultiRenderer', () => { | 156 test('getInteractiveTimestampsMultiRenderer', () => { |
| 151 const model = tr.c.TestUtils.newModel(model => { | 157 const model = tr.c.TestUtils.newModel(model => { |
| 152 const rendererProcesses = []; | 158 const rendererProcesses = []; |
| 153 for (let pid = 1; pid <= 5; pid++) { | 159 for (let pid = 1; pid <= 5; pid++) { |
| 154 const rendererProcess = model.getOrCreateProcess(pid); | 160 const rendererProcess = model.getOrCreateProcess(pid); |
| 155 const mainThread = rendererProcess.getOrCreateThread(pid + 10); | 161 const mainThread = rendererProcess.getOrCreateThread(pid + 10); |
| 156 mainThread.name = 'CrRendererMain'; | 162 mainThread.name = 'CrRendererMain'; |
| 157 | 163 |
| 158 addTestFrame(rendererProcess); | 164 addTestFrame(rendererProcess, mainThread); |
| 159 addNavigationStart(mainThread, pid * 1000); | 165 addNavigationStart(mainThread, pid * 1000); |
| 160 addFMPCandidate(mainThread, pid * 1000 + 2000); | 166 addFMPCandidate(mainThread, pid * 1000 + 2000); |
| 161 addNavigationStart(mainThread, pid * 2000); | 167 addNavigationStart(mainThread, pid * 2000); |
| 162 addFMPCandidate(mainThread, pid * 2000 + 2000); | 168 addFMPCandidate(mainThread, pid * 2000 + 2000); |
| 163 addDummyTask(mainThread, 100000); | 169 addDummyTask(mainThread, 100000); |
| 164 } | 170 } |
| 165 }); | 171 }); |
| 166 | 172 |
| 167 const interactiveTimestampsMap = getInteractiveTimestamps(model); | 173 const interactiveTimestampsMap = getInteractiveTimestamps(model); |
| 168 assert.deepEqual(interactiveTimestampsMap.get(1), [4000]); | 174 assert.deepEqual(interactiveTimestampsMap.get(1), [4000]); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 381 |
| 376 test('maxExpectedQueueingTimeInSlidingWindow_largeOverlapThrows', () => { | 382 test('maxExpectedQueueingTimeInSlidingWindow_largeOverlapThrows', () => { |
| 377 // Overlap larger than 1e-3 should trigger exception. | 383 // Overlap larger than 1e-3 should trigger exception. |
| 378 assert.throws(() => maxExpectedQueueingTimeInSlidingWindow(0, 100, 10, | 384 assert.throws(() => maxExpectedQueueingTimeInSlidingWindow(0, 100, 10, |
| 379 [{start: 0, end: 100.0011}, {start: 100.0, end: 101}]), | 385 [{start: 0, end: 100.0011}, {start: 100.0, end: 101}]), |
| 380 'Tasks must not overlap' | 386 'Tasks must not overlap' |
| 381 ); | 387 ); |
| 382 }); | 388 }); |
| 383 }); | 389 }); |
| 384 </script> | 390 </script> |
| OLD | NEW |