| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <!-- | |
| 3 Copyright 2015 The Chromium Authors. All rights reserved. | |
| 4 Use of this source code is governed by a BSD-style license that can be | |
| 5 found in the LICENSE file. | |
| 6 --> | |
| 7 | |
| 8 <link rel="import" href="/perf_insights/mappers/scheduling/map_rendering_cost.ht
ml"> | |
| 9 <link rel="import" href="/perf_insights/mre/mre_result.html"> | |
| 10 <link rel="import" href="/tracing/core/test_utils.html"> | |
| 11 <link rel="import" href="/tracing/extras/chrome/chrome_test_utils.html"> | |
| 12 | |
| 13 <script> | |
| 14 'use strict'; | |
| 15 | |
| 16 tr.b.unittest.testSuite(function() { | |
| 17 var TestUtils = tr.c.TestUtils; | |
| 18 var ThreadSlice = tr.model.ThreadSlice; | |
| 19 | |
| 20 test('mapperTest', function() { | |
| 21 var m = tr.e.chrome.ChromeTestUtils.newChromeModel(function(m) { | |
| 22 tr.e.chrome.ChromeTestUtils.addLoadingEvent(m, {start: 0, end: 10}); | |
| 23 | |
| 24 var mainThread = m.rendererMain; | |
| 25 | |
| 26 mainThread.sliceGroup.pushSlice(TestUtils.newSliceEx({ | |
| 27 type: ThreadSlice, | |
| 28 start: 4, | |
| 29 duration: 4, | |
| 30 title: 'TaskQueueManager::RunTask' | |
| 31 })); | |
| 32 | |
| 33 mainThread.sliceGroup.pushSlice(TestUtils.newSliceEx({ | |
| 34 type: ThreadSlice, | |
| 35 start: 5, | |
| 36 duration: 2, | |
| 37 title: 'ThreadProxy::BeginMainFrame' | |
| 38 })); | |
| 39 | |
| 40 // Two slices that only partially overlaps the loading phase. Both | |
| 41 // should be ignored. | |
| 42 mainThread.sliceGroup.pushSlice(TestUtils.newSliceEx({ | |
| 43 type: ThreadSlice, | |
| 44 start: -5, | |
| 45 duration: 10, | |
| 46 title: 'ThreadProxy::BeginMainFrame' | |
| 47 })); | |
| 48 | |
| 49 mainThread.sliceGroup.pushSlice(TestUtils.newSliceEx({ | |
| 50 type: ThreadSlice, | |
| 51 start: 8, | |
| 52 duration: 10, | |
| 53 title: 'ThreadProxy::BeginMainFrame' | |
| 54 })); | |
| 55 }); | |
| 56 | |
| 57 var result = new pi.mre.MreResult(); | |
| 58 pie.mapRenderingCostForTest(result, m); | |
| 59 | |
| 60 assert.equal(tr.b.dictionaryLength(result.pairs), 1); | |
| 61 | |
| 62 var renderingCost = result.pairs.renderingCost; | |
| 63 assert.deepEqual(renderingCost.loadingDuration, [10]); | |
| 64 assert.deepEqual(renderingCost.loadingTotalCost, [4]); | |
| 65 assert.deepEqual(renderingCost.loadingBeginMainFrameCost, [2]); | |
| 66 assert.deepEqual(renderingCost.loadingBeginMainFrameRelativeCost, [.5]); | |
| 67 }); | |
| 68 }); | |
| 69 | |
| 70 </script> | |
| OLD | NEW |