OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 TimelineModel.TimelineProfileTree = {}; | 5 TimelineModel.TimelineProfileTree = {}; |
6 | 6 |
7 /** | 7 /** |
8 * @unrestricted | 8 * @unrestricted |
9 */ | 9 */ |
10 TimelineModel.TimelineProfileTree.Node = class { | 10 TimelineModel.TimelineProfileTree.Node = class { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 hasChildren() { | 42 hasChildren() { |
43 throw 'Not implemented'; | 43 throw 'Not implemented'; |
44 } | 44 } |
45 | 45 |
46 /** | 46 /** |
47 * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>} | 47 * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>} |
48 */ | 48 */ |
49 children() { | 49 children() { |
50 throw 'Not implemented'; | 50 throw 'Not implemented'; |
51 } | 51 } |
| 52 |
| 53 /** |
| 54 * @param {function(!SDK.TracingModel.Event):boolean} matchFunction |
| 55 * @param {!Array<!TimelineModel.TimelineProfileTree.Node>=} results |
| 56 * @return {!Array<!TimelineModel.TimelineProfileTree.Node>} |
| 57 */ |
| 58 searchTree(matchFunction, results) { |
| 59 results = results || []; |
| 60 if (this.event && matchFunction(this.event)) |
| 61 results.push(this); |
| 62 for (var child of this.children().values()) |
| 63 child.searchTree(matchFunction, results); |
| 64 return results; |
| 65 } |
52 }; | 66 }; |
53 | 67 |
54 TimelineModel.TimelineProfileTree.TopDownNode = class extends TimelineModel.Time
lineProfileTree.Node { | 68 TimelineModel.TimelineProfileTree.TopDownNode = class extends TimelineModel.Time
lineProfileTree.Node { |
55 /** | 69 /** |
56 * @param {string} id | 70 * @param {string} id |
57 * @param {?SDK.TracingModel.Event} event | 71 * @param {?SDK.TracingModel.Event} event |
58 * @param {?TimelineModel.TimelineProfileTree.TopDownNode} parent | 72 * @param {?TimelineModel.TimelineProfileTree.TopDownNode} parent |
59 */ | 73 */ |
60 constructor(id, event, parent) { | 74 constructor(id, event, parent) { |
61 super(id, event); | 75 super(id, event); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 } | 512 } |
499 var totalTime = Math.min(e.endTime, endTime) - Math.max(e.startTime, lastT
imeMarker); | 513 var totalTime = Math.min(e.endTime, endTime) - Math.max(e.startTime, lastT
imeMarker); |
500 node.selfTime += selfTime; | 514 node.selfTime += selfTime; |
501 node.totalTime += totalTime; | 515 node.totalTime += totalTime; |
502 lastTimeMarker = Math.min(e.endTime, endTime); | 516 lastTimeMarker = Math.min(e.endTime, endTime); |
503 } | 517 } |
504 | 518 |
505 this._cachedChildren = nodeById; | 519 this._cachedChildren = nodeById; |
506 return nodeById; | 520 return nodeById; |
507 } | 521 } |
| 522 |
| 523 /** |
| 524 * @override |
| 525 * @param {function(!SDK.TracingModel.Event):boolean} matchFunction |
| 526 * @param {!Array<!TimelineModel.TimelineProfileTree.Node>=} results |
| 527 * @return {!Array<!TimelineModel.TimelineProfileTree.Node>} |
| 528 */ |
| 529 searchTree(matchFunction, results) { |
| 530 results = results || []; |
| 531 if (this.event && matchFunction(this.event)) |
| 532 results.push(this); |
| 533 return results; |
| 534 } |
508 }; | 535 }; |
509 | 536 |
510 /** | 537 /** |
511 * @param {!SDK.TracingModel.Event} event | 538 * @param {!SDK.TracingModel.Event} event |
512 * @return {?string} | 539 * @return {?string} |
513 */ | 540 */ |
514 TimelineModel.TimelineProfileTree.eventURL = function(event) { | 541 TimelineModel.TimelineProfileTree.eventURL = function(event) { |
515 var data = event.args['data'] || event.args['beginData']; | 542 var data = event.args['data'] || event.args['beginData']; |
516 if (data && data['url']) | 543 if (data && data['url']) |
517 return data['url']; | 544 return data['url']; |
(...skipping 27 matching lines...) Expand all Loading... |
545 if (event.name !== TimelineModel.TimelineModel.RecordType.JSFrame) | 572 if (event.name !== TimelineModel.TimelineModel.RecordType.JSFrame) |
546 return event.name; | 573 return event.name; |
547 const frame = event.args['data']; | 574 const frame = event.args['data']; |
548 const location = frame['scriptId'] || frame['url'] || ''; | 575 const location = frame['scriptId'] || frame['url'] || ''; |
549 const functionName = frame['functionName']; | 576 const functionName = frame['functionName']; |
550 const name = TimelineModel.TimelineJSProfileProcessor.isNativeRuntimeFrame(fra
me) ? | 577 const name = TimelineModel.TimelineJSProfileProcessor.isNativeRuntimeFrame(fra
me) ? |
551 TimelineModel.TimelineJSProfileProcessor.nativeGroup(functionName) || func
tionName : | 578 TimelineModel.TimelineJSProfileProcessor.nativeGroup(functionName) || func
tionName : |
552 functionName; | 579 functionName; |
553 return `f:${name}@${location}`; | 580 return `f:${name}@${location}`; |
554 }; | 581 }; |
OLD | NEW |