| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 return node.profileNode === this._profileView.profile.idleNode ? "" : We
bInspector.UIString("%.2f\u2009%%", value); | 342 return node.profileNode === this._profileView.profile.idleNode ? "" : We
bInspector.UIString("%.2f\u2009%%", value); |
| 343 }, | 343 }, |
| 344 | 344 |
| 345 /** | 345 /** |
| 346 * @override | 346 * @override |
| 347 * @param {!WebInspector.ProfileDataGridNode} node | 347 * @param {!WebInspector.ProfileDataGridNode} node |
| 348 * @return {!Element} | 348 * @return {!Element} |
| 349 */ | 349 */ |
| 350 linkifyNode: function(node) | 350 linkifyNode: function(node) |
| 351 { | 351 { |
| 352 return this._profileView.linkifier().linkifyConsoleCallFrameForTimeline(
this._profileView.target(), node.profileNode.frame, "profile-node-file"); | 352 return this._profileView.linkifier().linkifyConsoleCallFrame(this._profi
leView.target(), node.profileNode.callFrame, "profile-node-file"); |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 | 355 |
| 356 /** | 356 /** |
| 357 * @constructor | 357 * @constructor |
| 358 * @extends {WebInspector.ProfileFlameChartDataProvider} | 358 * @extends {WebInspector.ProfileFlameChartDataProvider} |
| 359 * @param {!WebInspector.CPUProfileDataModel} cpuProfile | 359 * @param {!WebInspector.CPUProfileDataModel} cpuProfile |
| 360 * @param {?WebInspector.Target} target | 360 * @param {?WebInspector.Target} target |
| 361 */ | 361 */ |
| 362 WebInspector.CPUFlameChartDataProvider = function(cpuProfile, target) | 362 WebInspector.CPUFlameChartDataProvider = function(cpuProfile, target) |
| 363 { | 363 { |
| 364 WebInspector.ProfileFlameChartDataProvider.call(this, target); | 364 WebInspector.ProfileFlameChartDataProvider.call(this, target); |
| 365 this._cpuProfile = cpuProfile; | 365 this._cpuProfile = cpuProfile; |
| 366 } | 366 } |
| 367 | 367 |
| 368 WebInspector.CPUFlameChartDataProvider.prototype = { | 368 WebInspector.CPUFlameChartDataProvider.prototype = { |
| 369 /** | 369 /** |
| 370 * @override | 370 * @override |
| 371 * @return {!WebInspector.FlameChart.TimelineData} | 371 * @return {!WebInspector.FlameChart.TimelineData} |
| 372 */ | 372 */ |
| 373 _calculateTimelineData: function() | 373 _calculateTimelineData: function() |
| 374 { | 374 { |
| 375 /** | 375 /** |
| 376 * @constructor | 376 * @constructor |
| 377 * @param {number} depth | 377 * @param {number} depth |
| 378 * @param {number} duration | 378 * @param {number} duration |
| 379 * @param {number} startTime | 379 * @param {number} startTime |
| 380 * @param {number} selfTime | 380 * @param {number} selfTime |
| 381 * @param {!ProfilerAgent.CPUProfileNode} node | 381 * @param {!WebInspector.CPUProfileNode} node |
| 382 */ | 382 */ |
| 383 function ChartEntry(depth, duration, startTime, selfTime, node) | 383 function ChartEntry(depth, duration, startTime, selfTime, node) |
| 384 { | 384 { |
| 385 this.depth = depth; | 385 this.depth = depth; |
| 386 this.duration = duration; | 386 this.duration = duration; |
| 387 this.startTime = startTime; | 387 this.startTime = startTime; |
| 388 this.selfTime = selfTime; | 388 this.selfTime = selfTime; |
| 389 this.node = node; | 389 this.node = node; |
| 390 } | 390 } |
| 391 | 391 |
| 392 /** @type {!Array.<?ChartEntry>} */ | 392 /** @type {!Array.<?ChartEntry>} */ |
| 393 var entries = []; | 393 var entries = []; |
| 394 /** @type {!Array.<number>} */ | 394 /** @type {!Array.<number>} */ |
| 395 var stack = []; | 395 var stack = []; |
| 396 var maxDepth = 5; | 396 var maxDepth = 5; |
| 397 | 397 |
| 398 function onOpenFrame() | 398 function onOpenFrame() |
| 399 { | 399 { |
| 400 stack.push(entries.length); | 400 stack.push(entries.length); |
| 401 // Reserve space for the entry, as they have to be ordered by startT
ime. | 401 // Reserve space for the entry, as they have to be ordered by startT
ime. |
| 402 // The entry itself will be put there in onCloseFrame. | 402 // The entry itself will be put there in onCloseFrame. |
| 403 entries.push(null); | 403 entries.push(null); |
| 404 } | 404 } |
| 405 /** |
| 406 * @param {number} depth |
| 407 * @param {!WebInspector.CPUProfileNode} node |
| 408 * @param {number} startTime |
| 409 * @param {number} totalTime |
| 410 * @param {number} selfTime |
| 411 */ |
| 405 function onCloseFrame(depth, node, startTime, totalTime, selfTime) | 412 function onCloseFrame(depth, node, startTime, totalTime, selfTime) |
| 406 { | 413 { |
| 407 var index = stack.pop(); | 414 var index = stack.pop(); |
| 408 entries[index] = new ChartEntry(depth, totalTime, startTime, selfTim
e, node); | 415 entries[index] = new ChartEntry(depth, totalTime, startTime, selfTim
e, node); |
| 409 maxDepth = Math.max(maxDepth, depth); | 416 maxDepth = Math.max(maxDepth, depth); |
| 410 } | 417 } |
| 411 this._cpuProfile.forEachFrame(onOpenFrame, onCloseFrame); | 418 this._cpuProfile.forEachFrame(onOpenFrame, onCloseFrame); |
| 412 | 419 |
| 413 /** @type {!Array.<!ProfilerAgent.CPUProfileNode>} */ | 420 /** @type {!Array<!WebInspector.CPUProfileNode>} */ |
| 414 var entryNodes = new Array(entries.length); | 421 var entryNodes = new Array(entries.length); |
| 415 var entryLevels = new Uint8Array(entries.length); | 422 var entryLevels = new Uint8Array(entries.length); |
| 416 var entryTotalTimes = new Float32Array(entries.length); | 423 var entryTotalTimes = new Float32Array(entries.length); |
| 417 var entrySelfTimes = new Float32Array(entries.length); | 424 var entrySelfTimes = new Float32Array(entries.length); |
| 418 var entryStartTimes = new Float64Array(entries.length); | 425 var entryStartTimes = new Float64Array(entries.length); |
| 419 var minimumBoundary = this.minimumBoundary(); | 426 var minimumBoundary = this.minimumBoundary(); |
| 420 | 427 |
| 421 for (var i = 0; i < entries.length; ++i) { | 428 for (var i = 0; i < entries.length; ++i) { |
| 422 var entry = entries[i]; | 429 var entry = entries[i]; |
| 423 entryNodes[i] = entry.node; | 430 entryNodes[i] = entry.node; |
| 424 entryLevels[i] = entry.depth; | 431 entryLevels[i] = entry.depth; |
| 425 entryTotalTimes[i] = entry.duration; | 432 entryTotalTimes[i] = entry.duration; |
| 426 entryStartTimes[i] = entry.startTime; | 433 entryStartTimes[i] = entry.startTime; |
| 427 entrySelfTimes[i] = entry.selfTime; | 434 entrySelfTimes[i] = entry.selfTime; |
| 428 } | 435 } |
| 429 | 436 |
| 430 this._maxStackDepth = maxDepth; | 437 this._maxStackDepth = maxDepth; |
| 431 | 438 |
| 432 this._timelineData = new WebInspector.FlameChart.TimelineData(entryLevel
s, entryTotalTimes, entryStartTimes, null); | 439 this._timelineData = new WebInspector.FlameChart.TimelineData(entryLevel
s, entryTotalTimes, entryStartTimes, null); |
| 433 | 440 |
| 434 /** @type {!Array.<!ProfilerAgent.CPUProfileNode>} */ | 441 /** @type {!Array<!WebInspector.CPUProfileNode>} */ |
| 435 this._entryNodes = entryNodes; | 442 this._entryNodes = entryNodes; |
| 436 this._entrySelfTimes = entrySelfTimes; | 443 this._entrySelfTimes = entrySelfTimes; |
| 437 | 444 |
| 438 return this._timelineData; | 445 return this._timelineData; |
| 439 }, | 446 }, |
| 440 | 447 |
| 441 /** | 448 /** |
| 442 * @override | 449 * @override |
| 443 * @param {number} entryIndex | 450 * @param {number} entryIndex |
| 444 * @return {?Array<!{title: string, value: (string|!Element)}>} | 451 * @return {?Array<!{title: string, value: (string|!Element)}>} |
| (...skipping 26 matching lines...) Expand all Loading... |
| 471 return WebInspector.UIString("%.1f\u2009ms", ms); | 478 return WebInspector.UIString("%.1f\u2009ms", ms); |
| 472 return Number.secondsToString(ms / 1000, true); | 479 return Number.secondsToString(ms / 1000, true); |
| 473 } | 480 } |
| 474 var name = WebInspector.beautifyFunctionName(node.functionName); | 481 var name = WebInspector.beautifyFunctionName(node.functionName); |
| 475 pushEntryInfoRow(WebInspector.UIString("Name"), name); | 482 pushEntryInfoRow(WebInspector.UIString("Name"), name); |
| 476 var selfTime = millisecondsToString(this._entrySelfTimes[entryIndex]); | 483 var selfTime = millisecondsToString(this._entrySelfTimes[entryIndex]); |
| 477 var totalTime = millisecondsToString(timelineData.entryTotalTimes[entryI
ndex]); | 484 var totalTime = millisecondsToString(timelineData.entryTotalTimes[entryI
ndex]); |
| 478 pushEntryInfoRow(WebInspector.UIString("Self time"), selfTime); | 485 pushEntryInfoRow(WebInspector.UIString("Self time"), selfTime); |
| 479 pushEntryInfoRow(WebInspector.UIString("Total time"), totalTime); | 486 pushEntryInfoRow(WebInspector.UIString("Total time"), totalTime); |
| 480 var linkifier = new WebInspector.Linkifier(); | 487 var linkifier = new WebInspector.Linkifier(); |
| 481 var text = linkifier.linkifyConsoleCallFrameForTimeline(this._target, no
de).textContent; | 488 var text = linkifier.linkifyConsoleCallFrame(this._target, node.callFram
e).textContent; |
| 482 linkifier.dispose(); | 489 linkifier.dispose(); |
| 483 pushEntryInfoRow(WebInspector.UIString("URL"), text); | 490 pushEntryInfoRow(WebInspector.UIString("URL"), text); |
| 484 pushEntryInfoRow(WebInspector.UIString("Aggregated self time"), Number.s
econdsToString(node.selfTime / 1000, true)); | 491 pushEntryInfoRow(WebInspector.UIString("Aggregated self time"), Number.s
econdsToString(node.self / 1000, true)); |
| 485 pushEntryInfoRow(WebInspector.UIString("Aggregated total time"), Number.
secondsToString(node.totalTime / 1000, true)); | 492 pushEntryInfoRow(WebInspector.UIString("Aggregated total time"), Number.
secondsToString(node.total / 1000, true)); |
| 486 if (node.deoptReason && node.deoptReason !== "no reason") | 493 if (node.deoptReason && node.deoptReason !== "no reason") |
| 487 pushEntryInfoRow(WebInspector.UIString("Not optimized"), node.deoptR
eason); | 494 pushEntryInfoRow(WebInspector.UIString("Not optimized"), node.deoptR
eason); |
| 488 | 495 |
| 489 return entryInfo; | 496 return entryInfo; |
| 490 }, | 497 }, |
| 491 | 498 |
| 492 __proto__: WebInspector.ProfileFlameChartDataProvider.prototype | 499 __proto__: WebInspector.ProfileFlameChartDataProvider.prototype |
| 493 } | 500 } |
| OLD | NEW |