Chromium Code Reviews| 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 {!WebInspector.CPUProfileDataModel} jsProfileModel |
| 10 * @param {!WebInspector.TracingModel.Thread} thread | 10 * @param {!WebInspector.TracingModel.Thread} thread |
| 11 * @return {!Array<!WebInspector.TracingModel.Event>} | 11 * @return {!Array<!WebInspector.TracingModel.Event>} |
| 12 */ | 12 */ |
| 13 WebInspector.TimelineJSProfileProcessor.generateTracingEventsFromCpuProfile = fu nction(jsProfile, thread) | 13 WebInspector.TimelineJSProfileProcessor.generateTracingEventsFromCpuProfile = fu nction(jsProfileModel, thread) |
| 14 { | 14 { |
| 15 if (!jsProfile.samples) | |
| 16 return []; | |
| 17 var jsProfileModel = new WebInspector.CPUProfileDataModel(jsProfile); | |
| 18 var idleNode = jsProfileModel.idleNode; | 15 var idleNode = jsProfileModel.idleNode; |
| 19 var programNode = jsProfileModel.programNode; | 16 var programNode = jsProfileModel.programNode; |
| 20 var gcNode = jsProfileModel.gcNode; | 17 var gcNode = jsProfileModel.gcNode; |
| 21 var samples = jsProfileModel.samples; | 18 var samples = jsProfileModel.samples; |
| 22 var timestamps = jsProfileModel.timestamps; | 19 var timestamps = jsProfileModel.timestamps; |
| 23 var jsEvents = []; | 20 var jsEvents = []; |
| 24 /** @type {!Map<!Object, !Array<!RuntimeAgent.CallFrame>>} */ | 21 /** @type {!Map<!Object, !Array<!RuntimeAgent.CallFrame>>} */ |
| 25 var nodeToStackMap = new Map(); | 22 var nodeToStackMap = new Map(); |
| 26 nodeToStackMap.set(programNode, []); | 23 nodeToStackMap.set(programNode, []); |
| 27 for (var i = 0; i < samples.length; ++i) { | 24 for (var i = 0; i < samples.length; ++i) { |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 WebInspector.TracingModel.Phase.Instant, e.startTime, e.thread); | 484 WebInspector.TracingModel.Phase.Instant, e.startTime, e.thread); |
| 488 sampleEvent.ordinal = e.ordinal; | 485 sampleEvent.ordinal = e.ordinal; |
| 489 sampleEvent.args = {"data": {"stackTrace": stack }}; | 486 sampleEvent.args = {"data": {"stackTrace": stack }}; |
| 490 samples.push(sampleEvent); | 487 samples.push(sampleEvent); |
| 491 break; | 488 break; |
| 492 } | 489 } |
| 493 } | 490 } |
| 494 | 491 |
| 495 return samples; | 492 return samples; |
| 496 } | 493 } |
| 494 | |
| 495 /** | |
| 496 * @param {!WebInspector.CPUProfileDataModel} profile | |
| 497 */ | |
| 498 WebInspector.TimelineJSProfileProcessor.buildLineLevelProfiles = function(profil e) | |
| 499 { | |
| 500 if (!Runtime.experiments.isEnabled("lineLevelProfile")) | |
| 501 return; | |
| 502 var nodesToGo = [profile.profileHead]; | |
| 503 var sampleDuration = (profile.profileEndTime - profile.profileStartTime) / p rofile.totalHitCount; | |
| 504 /** @type {!Map<string, !Map<number,number>>} */ | |
| 505 var files = new Map(); | |
| 506 while (nodesToGo.length) { | |
| 507 var nodes = nodesToGo.pop().children; | |
| 508 for (var i = 0; i < nodes.length; ++i) { | |
| 509 var node = nodes[i]; | |
| 510 if (!node.url) continue; | |
|
lushnikov
2016/03/02 03:19:13
new line
alph
2016/03/02 18:34:34
Done.
| |
| 511 var fileInfo = files.get(node.url); | |
| 512 if (!fileInfo) { | |
| 513 fileInfo = new Map(); | |
| 514 files.set(node.url, fileInfo); | |
| 515 } | |
| 516 for (var j = 0; j < node.positionTicks.length; ++j) { | |
| 517 var lineInfo = node.positionTicks[j]; | |
| 518 var line = lineInfo.line; | |
| 519 var time = lineInfo.ticks * sampleDuration; | |
| 520 fileInfo.set(line, (fileInfo.get(line) || 0) + time); | |
| 521 } | |
| 522 nodesToGo.push(node); | |
| 523 } | |
| 524 } | |
| 525 for (var fileInfo of files) { | |
| 526 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(fileInfo[0] ); | |
| 527 if (!uiSourceCode) | |
| 528 continue; | |
| 529 uiSourceCode.setProfileInfo(fileInfo[1]); | |
| 530 } | |
| 531 } | |
| 532 | |
| 533 WebInspector.TimelineJSProfileProcessor.resetLineLevelProfiles = function() | |
| 534 { | |
| 535 if (!Runtime.experiments.isEnabled("lineLevelProfile")) | |
| 536 return; | |
| 537 WebInspector.workspace.uiSourceCodes().forEach(uiSourceCode => uiSourceCode. setProfileInfo(null)); | |
| 538 } | |
| OLD | NEW |