| 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/base/range.html"> | 9 <link rel="import" href="/tracing/base/range.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 17 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 // Look for main thread input handling in each renderer process. | 30 // Look for main thread input handling in each renderer process. |
| 31 var inputBlockers = {}; | 31 var inputBlockers = {}; |
| 32 var foundInputBlockers = false; | 32 var foundInputBlockers = false; |
| 33 for (var pid in rendererHelpers) { | 33 for (var pid in rendererHelpers) { |
| 34 var rendererHelper = rendererHelpers[pid]; | 34 var rendererHelper = rendererHelpers[pid]; |
| 35 var mainThread = rendererHelper.mainThread; | 35 var mainThread = rendererHelper.mainThread; |
| 36 // Look for events that represent main thread input handling that also | 36 // Look for events that represent main thread input handling that also |
| 37 // have one associated flow event showing where the input came from. | 37 // have one associated flow event showing where the input came from. |
| 38 mainThread.iterateAllEvents(function(event) { | 38 for (var event of mainThread.getDescendantEvents()) { |
| 39 if (event.title !== 'LatencyInfo.Flow' || | 39 if (event.title !== 'LatencyInfo.Flow' || |
| 40 event.args['step'] !== 'HandleInputEventMain' || | 40 event.args['step'] !== 'HandleInputEventMain' || |
| 41 event.inFlowEvents.length !== 1) { | 41 event.inFlowEvents.length !== 1) { |
| 42 return; | 42 continue; |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Now we can derive the queueing interval from the flow event. | 45 // Now we can derive the queueing interval from the flow event. |
| 46 var flowEvent = event.inFlowEvents[0]; | 46 var flowEvent = event.inFlowEvents[0]; |
| 47 var queueRange = | 47 var queueRange = |
| 48 tr.b.Range.fromExplicitRange(flowEvent.start, event.start); | 48 tr.b.Range.fromExplicitRange(flowEvent.start, event.start); |
| 49 | 49 |
| 50 // Find all events that intersect the queueing interval and compute how | 50 // Find all events that intersect the queueing interval and compute how |
| 51 // much they contributed to it. | 51 // much they contributed to it. |
| 52 mainThread.iterateAllEvents(function(event) { | 52 for (var intersectingEvent of mainThread.getDescendantEvents()) { |
| 53 var eventRange = | 53 var eventRange = |
| 54 tr.b.Range.fromExplicitRange(event.start, | 54 tr.b.Range.fromExplicitRange(intersectingEvent.start, |
| 55 event.start + event.duration); | 55 intersectingEvent.start + intersectingEvent.duration); |
| 56 var intersection = queueRange.findIntersection(eventRange); | 56 var intersection = queueRange.findIntersection(eventRange); |
| 57 if (intersection.isEmpty || intersection.duration === 0) | 57 if (intersection.isEmpty || intersection.duration === 0) |
| 58 return; | 58 continue; |
| 59 if (inputBlockers[event.title] === undefined) | 59 if (inputBlockers[intersectingEvent.title] === undefined) |
| 60 inputBlockers[event.title] = []; | 60 inputBlockers[intersectingEvent.title] = []; |
| 61 inputBlockers[event.title].push(intersection.duration); | 61 inputBlockers[intersectingEvent.title].push(intersection.duration); |
| 62 foundInputBlockers = true; | 62 foundInputBlockers = true; |
| 63 }); | 63 } |
| 64 }); | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 if (!foundInputBlockers) { | 67 if (!foundInputBlockers) { |
| 68 result.addPair('inputBlockers', null); | 68 result.addPair('inputBlockers', null); |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 | 71 |
| 72 result.addPair('inputBlockers', inputBlockers); | 72 result.addPair('inputBlockers', inputBlockers); |
| 73 } | 73 } |
| 74 | 74 |
| 75 pi.FunctionRegistry.register(mapInputBlockers); | 75 pi.FunctionRegistry.register(mapInputBlockers); |
| 76 | 76 |
| 77 return { | 77 return { |
| 78 mapInputBlockersForTest: mapInputBlockers | 78 mapInputBlockersForTest: mapInputBlockers |
| 79 }; | 79 }; |
| 80 }); | 80 }); |
| 81 </script> | 81 </script> |
| OLD | NEW |