OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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="/perf_insights/mre/function_handle.html"> | 8 <link rel="import" href="/perf_insights/mre/function_handle.html"> |
9 <link rel="import" href="/tracing/model/helpers/chrome_browser_helper.html"> | 9 <link rel="import" href="/tracing/model/helpers/chrome_browser_helper.html"> |
10 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> | 10 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> |
(...skipping 30 matching lines...) Expand all Loading... |
41 var loadingBeginMainFrameRelativeCost = new Array(loadingEvents.length); | 41 var loadingBeginMainFrameRelativeCost = new Array(loadingEvents.length); |
42 var beginMainFrameCount = 0; | 42 var beginMainFrameCount = 0; |
43 loadingEvents.forEach(function(loadingEvent, index) { | 43 loadingEvents.forEach(function(loadingEvent, index) { |
44 loadingDurations[index] = loadingEvent.duration; | 44 loadingDurations[index] = loadingEvent.duration; |
45 | 45 |
46 var totalCost = 0; | 46 var totalCost = 0; |
47 var beginMainFrameCost = 0; | 47 var beginMainFrameCost = 0; |
48 for (var pid in rendererHelpers) { | 48 for (var pid in rendererHelpers) { |
49 var rendererHelper = rendererHelpers[pid]; | 49 var rendererHelper = rendererHelpers[pid]; |
50 var mainThread = rendererHelper.mainThread; | 50 var mainThread = rendererHelper.mainThread; |
51 mainThread.iterateAllEvents(function(event) { | 51 for (var event of mainThread.getDescendantEvents()) { |
52 // Look for tasks executed by the scheduler. Note that this only | 52 // Look for tasks executed by the scheduler. Note that this only |
53 // includes slices that are *completely* inside the loading phase. | 53 // includes slices that are *completely* inside the loading phase. |
54 if (event.title !== 'TaskQueueManager::RunTask' || | 54 if (event.title !== 'TaskQueueManager::RunTask' || |
55 event.start < loadingEvent.start || | 55 event.start < loadingEvent.start || |
56 event.start + event.duration > | 56 event.start + event.duration > |
57 loadingEvent.start + loadingEvent.duration) { | 57 loadingEvent.start + loadingEvent.duration) { |
58 return; | 58 continue; |
59 } | 59 } |
60 totalCost += eventCost(event); | 60 totalCost += eventCost(event); |
61 | 61 |
62 var beginMainFrame = | 62 var beginMainFrame = |
63 event.findDescendentSlice('ThreadProxy::BeginMainFrame'); | 63 event.findDescendentSlice('ThreadProxy::BeginMainFrame'); |
64 if (beginMainFrame) { | 64 if (beginMainFrame) { |
65 beginMainFrameCount++; | 65 beginMainFrameCount++; |
66 beginMainFrameCost += eventCost(beginMainFrame); | 66 beginMainFrameCost += eventCost(beginMainFrame); |
67 } | 67 } |
68 }); | 68 } |
69 } | 69 } |
70 | 70 |
71 loadingTotalCost[index] = totalCost; | 71 loadingTotalCost[index] = totalCost; |
72 loadingBeginMainFrameCost[index] = beginMainFrameCost; | 72 loadingBeginMainFrameCost[index] = beginMainFrameCost; |
73 loadingBeginMainFrameRelativeCost[index] = beginMainFrameCost / totalCost; | 73 loadingBeginMainFrameRelativeCost[index] = beginMainFrameCost / totalCost; |
74 }); | 74 }); |
75 | 75 |
76 if (loadingDurations.length === 0) { | 76 if (loadingDurations.length === 0) { |
77 result.addValue('renderingCost', null); | 77 result.addValue('renderingCost', null); |
78 return; | 78 return; |
79 } | 79 } |
80 | 80 |
81 result.addPair('renderingCost', { | 81 result.addPair('renderingCost', { |
82 loadingDuration: loadingDurations, | 82 loadingDuration: loadingDurations, |
83 loadingTotalCost: loadingTotalCost, | 83 loadingTotalCost: loadingTotalCost, |
84 loadingBeginMainFrameCost: loadingBeginMainFrameCost, | 84 loadingBeginMainFrameCost: loadingBeginMainFrameCost, |
85 loadingBeginMainFrameRelativeCost: loadingBeginMainFrameRelativeCost, | 85 loadingBeginMainFrameRelativeCost: loadingBeginMainFrameRelativeCost, |
86 beginMainFramesPerLoad: beginMainFrameCount / loadingDurations.length | 86 beginMainFramesPerLoad: beginMainFrameCount / loadingDurations.length |
87 }); | 87 }); |
88 } | 88 } |
89 | 89 |
90 pi.FunctionRegistry.register(mapRenderingCost); | 90 pi.FunctionRegistry.register(mapRenderingCost); |
91 | 91 |
92 return { | 92 return { |
93 mapRenderingCostForTest: mapRenderingCost | 93 mapRenderingCostForTest: mapRenderingCost |
94 }; | 94 }; |
95 }); | 95 }); |
96 </script> | 96 </script> |
OLD | NEW |