| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 WebInspector.TimelineJSProfileProcessor = { }; | 6 WebInspector.TimelineJSProfileProcessor = { }; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * @param {!ProfilerAgent.CPUProfile} jsProfile | 9 * @param {!ProfilerAgent.CPUProfile} jsProfile |
| 10 * @param {!WebInspector.TracingModel.Thread} thread | 10 * @param {!WebInspector.TracingModel.Thread} thread |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 case WebInspector.TimelineModel.RecordType.FunctionCall: | 75 case WebInspector.TimelineModel.RecordType.FunctionCall: |
| 76 case WebInspector.TimelineModel.RecordType.EvaluateScript: | 76 case WebInspector.TimelineModel.RecordType.EvaluateScript: |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 | 81 |
| 82 var jsFrameEvents = []; | 82 var jsFrameEvents = []; |
| 83 var jsFramesStack = []; | 83 var jsFramesStack = []; |
| 84 var lockedJsStackDepth = []; | 84 var lockedJsStackDepth = []; |
| 85 var invocationEventsDepth = 0; | |
| 86 var currentSamplingIntervalMs = 0.1; | 85 var currentSamplingIntervalMs = 0.1; |
| 87 var lastStackSampleTime = 0; | 86 var lastStackSampleTime = 0; |
| 88 var ordinal = 0; | 87 var ordinal = 0; |
| 89 | 88 |
| 90 /** | 89 /** |
| 91 * @param {!WebInspector.TracingModel.Event} e | 90 * @param {!WebInspector.TracingModel.Event} e |
| 92 */ | 91 */ |
| 93 function updateSamplingInterval(e) | 92 function updateSamplingInterval(e) |
| 94 { | 93 { |
| 95 if (e.name !== WebInspector.TimelineModel.RecordType.JSSample) | 94 if (e.name !== WebInspector.TimelineModel.RecordType.JSSample) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 107 | 106 |
| 108 /** | 107 /** |
| 109 * @param {!WebInspector.TracingModel.Event} e | 108 * @param {!WebInspector.TracingModel.Event} e |
| 110 */ | 109 */ |
| 111 function onStartEvent(e) | 110 function onStartEvent(e) |
| 112 { | 111 { |
| 113 e.ordinal = ++ordinal; | 112 e.ordinal = ++ordinal; |
| 114 extractStackTrace(e); | 113 extractStackTrace(e); |
| 115 // For the duration of the event we cannot go beyond the stack associate
d with it. | 114 // For the duration of the event we cannot go beyond the stack associate
d with it. |
| 116 lockedJsStackDepth.push(jsFramesStack.length); | 115 lockedJsStackDepth.push(jsFramesStack.length); |
| 117 if (isJSInvocationEvent(e)) | |
| 118 ++invocationEventsDepth; | |
| 119 } | 116 } |
| 120 | 117 |
| 121 /** | 118 /** |
| 122 * @param {!WebInspector.TracingModel.Event} e | 119 * @param {!WebInspector.TracingModel.Event} e |
| 120 * @param {?WebInspector.TracingModel.Event} parent |
| 123 */ | 121 */ |
| 124 function onInstantEvent(e) | 122 function onInstantEvent(e, parent) |
| 125 { | 123 { |
| 126 e.ordinal = ++ordinal; | 124 e.ordinal = ++ordinal; |
| 127 updateSamplingInterval(e); | 125 updateSamplingInterval(e); |
| 128 if (invocationEventsDepth) | 126 if (parent && isJSInvocationEvent(parent)) |
| 129 extractStackTrace(e); | 127 extractStackTrace(e); |
| 130 } | 128 } |
| 131 | 129 |
| 132 /** | 130 /** |
| 133 * @param {!WebInspector.TracingModel.Event} e | 131 * @param {!WebInspector.TracingModel.Event} e |
| 134 */ | 132 */ |
| 135 function onEndEvent(e) | 133 function onEndEvent(e) |
| 136 { | 134 { |
| 137 if (isJSInvocationEvent(e)) | |
| 138 --invocationEventsDepth; | |
| 139 truncateJSStack(lockedJsStackDepth.pop(), e.endTime); | 135 truncateJSStack(lockedJsStackDepth.pop(), e.endTime); |
| 140 } | 136 } |
| 141 | 137 |
| 142 /** | 138 /** |
| 143 * @param {number} depth | 139 * @param {number} depth |
| 144 * @param {number} time | 140 * @param {number} time |
| 145 */ | 141 */ |
| 146 function truncateJSStack(depth, time) | 142 function truncateJSStack(depth, time) |
| 147 { | 143 { |
| 148 if (lockedJsStackDepth.length) { | 144 if (lockedJsStackDepth.length) { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 WebInspector.TracingModel.Phase.Instant, e.startTime, e.thread); | 385 WebInspector.TracingModel.Phase.Instant, e.startTime, e.thread); |
| 390 sampleEvent.ordinal = e.ordinal; | 386 sampleEvent.ordinal = e.ordinal; |
| 391 sampleEvent.args = {"data": {"stackTrace": stack }}; | 387 sampleEvent.args = {"data": {"stackTrace": stack }}; |
| 392 samples.push(sampleEvent); | 388 samples.push(sampleEvent); |
| 393 break; | 389 break; |
| 394 } | 390 } |
| 395 } | 391 } |
| 396 | 392 |
| 397 return samples; | 393 return samples; |
| 398 } | 394 } |
| OLD | NEW |