| Index: third_party/WebKit/Source/devtools/front_end/profiler/CPUProfileView.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/profiler/CPUProfileView.js b/third_party/WebKit/Source/devtools/front_end/profiler/CPUProfileView.js
|
| index 7adcc93e91bbf142b65395c0366cd990e6b6c51a..717606fef030fa428a8911fa4adce3f558fd2b71 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/profiler/CPUProfileView.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/profiler/CPUProfileView.js
|
| @@ -22,481 +22,449 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
| -
|
| /**
|
| - * @constructor
|
| * @implements {WebInspector.Searchable}
|
| - * @extends {WebInspector.ProfileView}
|
| - * @param {!WebInspector.CPUProfileHeader} profileHeader
|
| + * @unrestricted
|
| */
|
| -WebInspector.CPUProfileView = function(profileHeader)
|
| -{
|
| - WebInspector.ProfileView.call(this);
|
| +WebInspector.CPUProfileView = class extends WebInspector.ProfileView {
|
| + /**
|
| + * @param {!WebInspector.CPUProfileHeader} profileHeader
|
| + */
|
| + constructor(profileHeader) {
|
| + super();
|
| this._profileHeader = profileHeader;
|
| this.profile = new WebInspector.CPUProfileDataModel(profileHeader._profile || profileHeader.protocolProfile());
|
| this.adjustedTotal = this.profile.profileHead.total;
|
| this.adjustedTotal -= this.profile.idleNode ? this.profile.idleNode.total : 0;
|
| this.initialize(new WebInspector.CPUProfileView.NodeFormatter(this));
|
| -};
|
| -
|
| -WebInspector.CPUProfileView.prototype = {
|
| - /**
|
| - * @override
|
| - */
|
| - wasShown: function()
|
| - {
|
| - WebInspector.ProfileView.prototype.wasShown.call(this);
|
| - var lineLevelProfile = WebInspector.LineLevelProfile.instance();
|
| - lineLevelProfile.reset();
|
| - lineLevelProfile.appendCPUProfile(this.profile);
|
| - },
|
| -
|
| - /**
|
| - * @override
|
| - * @param {string} columnId
|
| - * @return {string}
|
| - */
|
| - columnHeader: function(columnId)
|
| - {
|
| - switch (columnId) {
|
| - case "self": return WebInspector.UIString("Self Time");
|
| - case "total": return WebInspector.UIString("Total Time");
|
| - }
|
| - return "";
|
| - },
|
| -
|
| - /**
|
| - * @override
|
| - * @return {!WebInspector.FlameChartDataProvider}
|
| - */
|
| - createFlameChartDataProvider: function()
|
| - {
|
| - return new WebInspector.CPUFlameChartDataProvider(this.profile, this._profileHeader.target());
|
| - },
|
| -
|
| - __proto__: WebInspector.ProfileView.prototype
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + */
|
| + wasShown() {
|
| + super.wasShown();
|
| + var lineLevelProfile = WebInspector.LineLevelProfile.instance();
|
| + lineLevelProfile.reset();
|
| + lineLevelProfile.appendCPUProfile(this.profile);
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @param {string} columnId
|
| + * @return {string}
|
| + */
|
| + columnHeader(columnId) {
|
| + switch (columnId) {
|
| + case 'self':
|
| + return WebInspector.UIString('Self Time');
|
| + case 'total':
|
| + return WebInspector.UIString('Total Time');
|
| + }
|
| + return '';
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @return {!WebInspector.FlameChartDataProvider}
|
| + */
|
| + createFlameChartDataProvider() {
|
| + return new WebInspector.CPUFlameChartDataProvider(this.profile, this._profileHeader.target());
|
| + }
|
| };
|
|
|
| /**
|
| - * @constructor
|
| - * @extends {WebInspector.ProfileType}
|
| + * @unrestricted
|
| */
|
| -WebInspector.CPUProfileType = function()
|
| -{
|
| - WebInspector.ProfileType.call(this, WebInspector.CPUProfileType.TypeId, WebInspector.UIString("Record JavaScript CPU Profile"));
|
| +WebInspector.CPUProfileType = class extends WebInspector.ProfileType {
|
| + constructor() {
|
| + super(WebInspector.CPUProfileType.TypeId, WebInspector.UIString('Record JavaScript CPU Profile'));
|
| this._recording = false;
|
|
|
| this._nextAnonymousConsoleProfileNumber = 1;
|
| this._anonymousConsoleProfileIdToTitle = {};
|
|
|
| WebInspector.CPUProfileType.instance = this;
|
| - WebInspector.targetManager.addModelListener(WebInspector.CPUProfilerModel, WebInspector.CPUProfilerModel.Events.ConsoleProfileStarted, this._consoleProfileStarted, this);
|
| - WebInspector.targetManager.addModelListener(WebInspector.CPUProfilerModel, WebInspector.CPUProfilerModel.Events.ConsoleProfileFinished, this._consoleProfileFinished, this);
|
| -};
|
| -
|
| -WebInspector.CPUProfileType.TypeId = "CPU";
|
| -
|
| -WebInspector.CPUProfileType.prototype = {
|
| - /**
|
| - * @override
|
| - * @return {string}
|
| - */
|
| - typeName: function()
|
| - {
|
| - return "CPU";
|
| - },
|
| -
|
| - /**
|
| - * @override
|
| - * @return {string}
|
| - */
|
| - fileExtension: function()
|
| - {
|
| - return ".cpuprofile";
|
| - },
|
| -
|
| - get buttonTooltip()
|
| - {
|
| - return this._recording ? WebInspector.UIString("Stop CPU profiling") : WebInspector.UIString("Start CPU profiling");
|
| - },
|
| -
|
| - /**
|
| - * @override
|
| - * @return {boolean}
|
| - */
|
| - buttonClicked: function()
|
| - {
|
| - if (this._recording) {
|
| - this.stopRecordingProfile();
|
| - return false;
|
| - } else {
|
| - this.startRecordingProfile();
|
| - return true;
|
| - }
|
| - },
|
| -
|
| - get treeItemTitle()
|
| - {
|
| - return WebInspector.UIString("CPU PROFILES");
|
| - },
|
| -
|
| - get description()
|
| - {
|
| - return WebInspector.UIString("CPU profiles show where the execution time is spent in your page's JavaScript functions.");
|
| - },
|
| -
|
| - /**
|
| - * @param {!WebInspector.Event} event
|
| - */
|
| - _consoleProfileStarted: function(event)
|
| - {
|
| - var data = /** @type {!WebInspector.CPUProfilerModel.EventData} */ (event.data);
|
| - var resolvedTitle = data.title;
|
| - if (!resolvedTitle) {
|
| - resolvedTitle = WebInspector.UIString("Profile %s", this._nextAnonymousConsoleProfileNumber++);
|
| - this._anonymousConsoleProfileIdToTitle[data.id] = resolvedTitle;
|
| - }
|
| - this._addMessageToConsole(WebInspector.ConsoleMessage.MessageType.Profile, data.scriptLocation, WebInspector.UIString("Profile '%s' started.", resolvedTitle));
|
| - },
|
| + WebInspector.targetManager.addModelListener(
|
| + WebInspector.CPUProfilerModel, WebInspector.CPUProfilerModel.Events.ConsoleProfileStarted,
|
| + this._consoleProfileStarted, this);
|
| + WebInspector.targetManager.addModelListener(
|
| + WebInspector.CPUProfilerModel, WebInspector.CPUProfilerModel.Events.ConsoleProfileFinished,
|
| + this._consoleProfileFinished, this);
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @return {string}
|
| + */
|
| + typeName() {
|
| + return 'CPU';
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @return {string}
|
| + */
|
| + fileExtension() {
|
| + return '.cpuprofile';
|
| + }
|
| +
|
| + get buttonTooltip() {
|
| + return this._recording ? WebInspector.UIString('Stop CPU profiling') : WebInspector.UIString('Start CPU profiling');
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @return {boolean}
|
| + */
|
| + buttonClicked() {
|
| + if (this._recording) {
|
| + this.stopRecordingProfile();
|
| + return false;
|
| + } else {
|
| + this.startRecordingProfile();
|
| + return true;
|
| + }
|
| + }
|
| +
|
| + get treeItemTitle() {
|
| + return WebInspector.UIString('CPU PROFILES');
|
| + }
|
| +
|
| + get description() {
|
| + return WebInspector.UIString(
|
| + 'CPU profiles show where the execution time is spent in your page\'s JavaScript functions.');
|
| + }
|
| +
|
| + /**
|
| + * @param {!WebInspector.Event} event
|
| + */
|
| + _consoleProfileStarted(event) {
|
| + var data = /** @type {!WebInspector.CPUProfilerModel.EventData} */ (event.data);
|
| + var resolvedTitle = data.title;
|
| + if (!resolvedTitle) {
|
| + resolvedTitle = WebInspector.UIString('Profile %s', this._nextAnonymousConsoleProfileNumber++);
|
| + this._anonymousConsoleProfileIdToTitle[data.id] = resolvedTitle;
|
| + }
|
| + this._addMessageToConsole(
|
| + WebInspector.ConsoleMessage.MessageType.Profile, data.scriptLocation,
|
| + WebInspector.UIString('Profile \'%s\' started.', resolvedTitle));
|
| + }
|
| +
|
| + /**
|
| + * @param {!WebInspector.Event} event
|
| + */
|
| + _consoleProfileFinished(event) {
|
| + var data = /** @type {!WebInspector.CPUProfilerModel.EventData} */ (event.data);
|
| + var cpuProfile = /** @type {!ProfilerAgent.Profile} */ (data.cpuProfile);
|
| + var resolvedTitle = data.title;
|
| + if (typeof resolvedTitle === 'undefined') {
|
| + resolvedTitle = this._anonymousConsoleProfileIdToTitle[data.id];
|
| + delete this._anonymousConsoleProfileIdToTitle[data.id];
|
| + }
|
| + var profile = new WebInspector.CPUProfileHeader(data.scriptLocation.target(), this, resolvedTitle);
|
| + profile.setProtocolProfile(cpuProfile);
|
| + this.addProfile(profile);
|
| + this._addMessageToConsole(
|
| + WebInspector.ConsoleMessage.MessageType.ProfileEnd, data.scriptLocation,
|
| + WebInspector.UIString('Profile \'%s\' finished.', resolvedTitle));
|
| + }
|
| +
|
| + /**
|
| + * @param {string} type
|
| + * @param {!WebInspector.DebuggerModel.Location} scriptLocation
|
| + * @param {string} messageText
|
| + */
|
| + _addMessageToConsole(type, scriptLocation, messageText) {
|
| + var script = scriptLocation.script();
|
| + var target = scriptLocation.target();
|
| + var message = new WebInspector.ConsoleMessage(
|
| + target, WebInspector.ConsoleMessage.MessageSource.ConsoleAPI, WebInspector.ConsoleMessage.MessageLevel.Debug,
|
| + messageText, type, undefined, undefined, undefined, undefined, [{
|
| + functionName: '',
|
| + scriptId: scriptLocation.scriptId,
|
| + url: script ? script.contentURL() : '',
|
| + lineNumber: scriptLocation.lineNumber,
|
| + columnNumber: scriptLocation.columnNumber || 0
|
| + }]);
|
| +
|
| + target.consoleModel.addMessage(message);
|
| + }
|
| +
|
| + startRecordingProfile() {
|
| + var target = WebInspector.context.flavor(WebInspector.Target);
|
| + if (this._profileBeingRecorded || !target)
|
| + return;
|
| + var profile = new WebInspector.CPUProfileHeader(target, this);
|
| + this.setProfileBeingRecorded(profile);
|
| + WebInspector.targetManager.suspendAllTargets();
|
| + this.addProfile(profile);
|
| + profile.updateStatus(WebInspector.UIString('Recording\u2026'));
|
| + this._recording = true;
|
| + target.cpuProfilerModel.startRecording();
|
| + }
|
| +
|
| + stopRecordingProfile() {
|
| + this._recording = false;
|
| + if (!this._profileBeingRecorded || !this._profileBeingRecorded.target())
|
| + return;
|
|
|
| - /**
|
| - * @param {!WebInspector.Event} event
|
| - */
|
| - _consoleProfileFinished: function(event)
|
| - {
|
| - var data = /** @type {!WebInspector.CPUProfilerModel.EventData} */ (event.data);
|
| - var cpuProfile = /** @type {!ProfilerAgent.Profile} */ (data.cpuProfile);
|
| - var resolvedTitle = data.title;
|
| - if (typeof resolvedTitle === "undefined") {
|
| - resolvedTitle = this._anonymousConsoleProfileIdToTitle[data.id];
|
| - delete this._anonymousConsoleProfileIdToTitle[data.id];
|
| - }
|
| - var profile = new WebInspector.CPUProfileHeader(data.scriptLocation.target(), this, resolvedTitle);
|
| - profile.setProtocolProfile(cpuProfile);
|
| - this.addProfile(profile);
|
| - this._addMessageToConsole(WebInspector.ConsoleMessage.MessageType.ProfileEnd, data.scriptLocation, WebInspector.UIString("Profile '%s' finished.", resolvedTitle));
|
| - },
|
| + var recordedProfile;
|
|
|
| /**
|
| - * @param {string} type
|
| - * @param {!WebInspector.DebuggerModel.Location} scriptLocation
|
| - * @param {string} messageText
|
| + * @param {?ProfilerAgent.Profile} profile
|
| + * @this {WebInspector.CPUProfileType}
|
| */
|
| - _addMessageToConsole: function(type, scriptLocation, messageText)
|
| - {
|
| - var script = scriptLocation.script();
|
| - var target = scriptLocation.target();
|
| - var message = new WebInspector.ConsoleMessage(
|
| - target,
|
| - WebInspector.ConsoleMessage.MessageSource.ConsoleAPI,
|
| - WebInspector.ConsoleMessage.MessageLevel.Debug,
|
| - messageText,
|
| - type,
|
| - undefined,
|
| - undefined,
|
| - undefined,
|
| - undefined,
|
| - [{
|
| - functionName: "",
|
| - scriptId: scriptLocation.scriptId,
|
| - url: script ? script.contentURL() : "",
|
| - lineNumber: scriptLocation.lineNumber,
|
| - columnNumber: scriptLocation.columnNumber || 0
|
| - }]);
|
| -
|
| - target.consoleModel.addMessage(message);
|
| - },
|
| -
|
| - startRecordingProfile: function()
|
| - {
|
| - var target = WebInspector.context.flavor(WebInspector.Target);
|
| - if (this._profileBeingRecorded || !target)
|
| - return;
|
| - var profile = new WebInspector.CPUProfileHeader(target, this);
|
| - this.setProfileBeingRecorded(profile);
|
| - WebInspector.targetManager.suspendAllTargets();
|
| - this.addProfile(profile);
|
| - profile.updateStatus(WebInspector.UIString("Recording\u2026"));
|
| - this._recording = true;
|
| - target.cpuProfilerModel.startRecording();
|
| - },
|
| -
|
| - stopRecordingProfile: function()
|
| - {
|
| - this._recording = false;
|
| - if (!this._profileBeingRecorded || !this._profileBeingRecorded.target())
|
| - return;
|
| -
|
| - var recordedProfile;
|
| -
|
| - /**
|
| - * @param {?ProfilerAgent.Profile} profile
|
| - * @this {WebInspector.CPUProfileType}
|
| - */
|
| - function didStopProfiling(profile)
|
| - {
|
| - if (!this._profileBeingRecorded)
|
| - return;
|
| - console.assert(profile);
|
| - this._profileBeingRecorded.setProtocolProfile(profile);
|
| - this._profileBeingRecorded.updateStatus("");
|
| - recordedProfile = this._profileBeingRecorded;
|
| - this.setProfileBeingRecorded(null);
|
| - }
|
| -
|
| - /**
|
| - * @this {WebInspector.CPUProfileType}
|
| - */
|
| - function fireEvent()
|
| - {
|
| - this.dispatchEventToListeners(WebInspector.ProfileType.Events.ProfileComplete, recordedProfile);
|
| - }
|
| -
|
| - this._profileBeingRecorded.target().cpuProfilerModel.stopRecording()
|
| - .then(didStopProfiling.bind(this))
|
| - .then(WebInspector.targetManager.resumeAllTargets.bind(WebInspector.targetManager))
|
| - .then(fireEvent.bind(this));
|
| - },
|
| -
|
| - /**
|
| - * @override
|
| - * @param {string} title
|
| - * @return {!WebInspector.ProfileHeader}
|
| - */
|
| - createProfileLoadedFromFile: function(title)
|
| - {
|
| - return new WebInspector.CPUProfileHeader(null, this, title);
|
| - },
|
| + function didStopProfiling(profile) {
|
| + if (!this._profileBeingRecorded)
|
| + return;
|
| + console.assert(profile);
|
| + this._profileBeingRecorded.setProtocolProfile(profile);
|
| + this._profileBeingRecorded.updateStatus('');
|
| + recordedProfile = this._profileBeingRecorded;
|
| + this.setProfileBeingRecorded(null);
|
| + }
|
|
|
| /**
|
| - * @override
|
| + * @this {WebInspector.CPUProfileType}
|
| */
|
| - profileBeingRecordedRemoved: function()
|
| - {
|
| - this.stopRecordingProfile();
|
| - },
|
| + function fireEvent() {
|
| + this.dispatchEventToListeners(WebInspector.ProfileType.Events.ProfileComplete, recordedProfile);
|
| + }
|
|
|
| - __proto__: WebInspector.ProfileType.prototype
|
| + this._profileBeingRecorded.target()
|
| + .cpuProfilerModel.stopRecording()
|
| + .then(didStopProfiling.bind(this))
|
| + .then(WebInspector.targetManager.resumeAllTargets.bind(WebInspector.targetManager))
|
| + .then(fireEvent.bind(this));
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @param {string} title
|
| + * @return {!WebInspector.ProfileHeader}
|
| + */
|
| + createProfileLoadedFromFile(title) {
|
| + return new WebInspector.CPUProfileHeader(null, this, title);
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + */
|
| + profileBeingRecordedRemoved() {
|
| + this.stopRecordingProfile();
|
| + }
|
| };
|
|
|
| +WebInspector.CPUProfileType.TypeId = 'CPU';
|
| +
|
| /**
|
| - * @constructor
|
| - * @extends {WebInspector.WritableProfileHeader}
|
| - * @param {?WebInspector.Target} target
|
| - * @param {!WebInspector.CPUProfileType} type
|
| - * @param {string=} title
|
| + * @unrestricted
|
| */
|
| -WebInspector.CPUProfileHeader = function(target, type, title)
|
| -{
|
| - WebInspector.WritableProfileHeader.call(this, target, type, title);
|
| -};
|
| -
|
| -WebInspector.CPUProfileHeader.prototype = {
|
| - /**
|
| - * @override
|
| - * @return {!WebInspector.ProfileView}
|
| - */
|
| - createView: function()
|
| - {
|
| - return new WebInspector.CPUProfileView(this);
|
| - },
|
| -
|
| - /**
|
| - * @return {!ProfilerAgent.Profile}
|
| - */
|
| - protocolProfile: function()
|
| - {
|
| - return this._protocolProfile;
|
| - },
|
| -
|
| - __proto__: WebInspector.WritableProfileHeader.prototype
|
| +WebInspector.CPUProfileHeader = class extends WebInspector.WritableProfileHeader {
|
| + /**
|
| + * @param {?WebInspector.Target} target
|
| + * @param {!WebInspector.CPUProfileType} type
|
| + * @param {string=} title
|
| + */
|
| + constructor(target, type, title) {
|
| + super(target, type, title);
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @return {!WebInspector.ProfileView}
|
| + */
|
| + createView() {
|
| + return new WebInspector.CPUProfileView(this);
|
| + }
|
| +
|
| + /**
|
| + * @return {!ProfilerAgent.Profile}
|
| + */
|
| + protocolProfile() {
|
| + return this._protocolProfile;
|
| + }
|
| };
|
|
|
| /**
|
| * @implements {WebInspector.ProfileDataGridNode.Formatter}
|
| - * @constructor
|
| + * @unrestricted
|
| */
|
| -WebInspector.CPUProfileView.NodeFormatter = function(profileView)
|
| -{
|
| +WebInspector.CPUProfileView.NodeFormatter = class {
|
| + constructor(profileView) {
|
| this._profileView = profileView;
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @param {number} value
|
| + * @return {string}
|
| + */
|
| + formatValue(value) {
|
| + return WebInspector.UIString('%.1f\u2009ms', value);
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @param {number} value
|
| + * @param {!WebInspector.ProfileDataGridNode} node
|
| + * @return {string}
|
| + */
|
| + formatPercent(value, node) {
|
| + return node.profileNode === this._profileView.profile.idleNode ? '' : WebInspector.UIString('%.2f\u2009%%', value);
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @param {!WebInspector.ProfileDataGridNode} node
|
| + * @return {?Element}
|
| + */
|
| + linkifyNode(node) {
|
| + return this._profileView.linkifier().maybeLinkifyConsoleCallFrame(
|
| + this._profileView.target(), node.profileNode.callFrame, 'profile-node-file');
|
| + }
|
| };
|
|
|
| -WebInspector.CPUProfileView.NodeFormatter.prototype = {
|
| +/**
|
| + * @unrestricted
|
| + */
|
| +WebInspector.CPUFlameChartDataProvider = class extends WebInspector.ProfileFlameChartDataProvider {
|
| + /**
|
| + * @param {!WebInspector.CPUProfileDataModel} cpuProfile
|
| + * @param {?WebInspector.Target} target
|
| + */
|
| + constructor(cpuProfile, target) {
|
| + super(target);
|
| + this._cpuProfile = cpuProfile;
|
| + }
|
| +
|
| + /**
|
| + * @override
|
| + * @return {!WebInspector.FlameChart.TimelineData}
|
| + */
|
| + _calculateTimelineData() {
|
| + /** @type {!Array.<?WebInspector.CPUFlameChartDataProvider.ChartEntry>} */
|
| + var entries = [];
|
| + /** @type {!Array.<number>} */
|
| + var stack = [];
|
| + var maxDepth = 5;
|
| +
|
| + function onOpenFrame() {
|
| + stack.push(entries.length);
|
| + // Reserve space for the entry, as they have to be ordered by startTime.
|
| + // The entry itself will be put there in onCloseFrame.
|
| + entries.push(null);
|
| + }
|
| /**
|
| - * @override
|
| - * @param {number} value
|
| - * @return {string}
|
| + * @param {number} depth
|
| + * @param {!WebInspector.CPUProfileNode} node
|
| + * @param {number} startTime
|
| + * @param {number} totalTime
|
| + * @param {number} selfTime
|
| */
|
| - formatValue: function(value)
|
| - {
|
| - return WebInspector.UIString("%.1f\u2009ms", value);
|
| - },
|
| + function onCloseFrame(depth, node, startTime, totalTime, selfTime) {
|
| + var index = stack.pop();
|
| + entries[index] =
|
| + new WebInspector.CPUFlameChartDataProvider.ChartEntry(depth, totalTime, startTime, selfTime, node);
|
| + maxDepth = Math.max(maxDepth, depth);
|
| + }
|
| + this._cpuProfile.forEachFrame(onOpenFrame, onCloseFrame);
|
| +
|
| + /** @type {!Array<!WebInspector.CPUProfileNode>} */
|
| + var entryNodes = new Array(entries.length);
|
| + var entryLevels = new Uint16Array(entries.length);
|
| + var entryTotalTimes = new Float32Array(entries.length);
|
| + var entrySelfTimes = new Float32Array(entries.length);
|
| + var entryStartTimes = new Float64Array(entries.length);
|
| + var minimumBoundary = this.minimumBoundary();
|
| +
|
| + for (var i = 0; i < entries.length; ++i) {
|
| + var entry = entries[i];
|
| + entryNodes[i] = entry.node;
|
| + entryLevels[i] = entry.depth;
|
| + entryTotalTimes[i] = entry.duration;
|
| + entryStartTimes[i] = entry.startTime;
|
| + entrySelfTimes[i] = entry.selfTime;
|
| + }
|
| +
|
| + this._maxStackDepth = maxDepth;
|
| +
|
| + this._timelineData = new WebInspector.FlameChart.TimelineData(entryLevels, entryTotalTimes, entryStartTimes, null);
|
| +
|
| + /** @type {!Array<!WebInspector.CPUProfileNode>} */
|
| + this._entryNodes = entryNodes;
|
| + this._entrySelfTimes = entrySelfTimes;
|
| +
|
| + return this._timelineData;
|
| + }
|
|
|
| + /**
|
| + * @override
|
| + * @param {number} entryIndex
|
| + * @return {?Element}
|
| + */
|
| + prepareHighlightedEntryInfo(entryIndex) {
|
| + var timelineData = this._timelineData;
|
| + var node = this._entryNodes[entryIndex];
|
| + if (!node)
|
| + return null;
|
| +
|
| + var entryInfo = [];
|
| /**
|
| - * @override
|
| - * @param {number} value
|
| - * @param {!WebInspector.ProfileDataGridNode} node
|
| - * @return {string}
|
| + * @param {string} title
|
| + * @param {string} value
|
| */
|
| - formatPercent: function(value, node)
|
| - {
|
| - return node.profileNode === this._profileView.profile.idleNode ? "" : WebInspector.UIString("%.2f\u2009%%", value);
|
| - },
|
| -
|
| + function pushEntryInfoRow(title, value) {
|
| + entryInfo.push({title: title, value: value});
|
| + }
|
| /**
|
| - * @override
|
| - * @param {!WebInspector.ProfileDataGridNode} node
|
| - * @return {?Element}
|
| + * @param {number} ms
|
| + * @return {string}
|
| */
|
| - linkifyNode: function(node)
|
| - {
|
| - return this._profileView.linkifier().maybeLinkifyConsoleCallFrame(this._profileView.target(), node.profileNode.callFrame, "profile-node-file");
|
| + function millisecondsToString(ms) {
|
| + if (ms === 0)
|
| + return '0';
|
| + if (ms < 1000)
|
| + return WebInspector.UIString('%.1f\u2009ms', ms);
|
| + return Number.secondsToString(ms / 1000, true);
|
| }
|
| + var name = WebInspector.beautifyFunctionName(node.functionName);
|
| + pushEntryInfoRow(WebInspector.UIString('Name'), name);
|
| + var selfTime = millisecondsToString(this._entrySelfTimes[entryIndex]);
|
| + var totalTime = millisecondsToString(timelineData.entryTotalTimes[entryIndex]);
|
| + pushEntryInfoRow(WebInspector.UIString('Self time'), selfTime);
|
| + pushEntryInfoRow(WebInspector.UIString('Total time'), totalTime);
|
| + var linkifier = new WebInspector.Linkifier();
|
| + var link = linkifier.maybeLinkifyConsoleCallFrame(this._target, node.callFrame);
|
| + if (link)
|
| + pushEntryInfoRow(WebInspector.UIString('URL'), link.textContent);
|
| + linkifier.dispose();
|
| + pushEntryInfoRow(WebInspector.UIString('Aggregated self time'), Number.secondsToString(node.self / 1000, true));
|
| + pushEntryInfoRow(WebInspector.UIString('Aggregated total time'), Number.secondsToString(node.total / 1000, true));
|
| + if (node.deoptReason)
|
| + pushEntryInfoRow(WebInspector.UIString('Not optimized'), node.deoptReason);
|
| +
|
| + return WebInspector.ProfileView.buildPopoverTable(entryInfo);
|
| + }
|
| };
|
|
|
| /**
|
| - * @constructor
|
| - * @extends {WebInspector.ProfileFlameChartDataProvider}
|
| - * @param {!WebInspector.CPUProfileDataModel} cpuProfile
|
| - * @param {?WebInspector.Target} target
|
| + * @unrestricted
|
| */
|
| -WebInspector.CPUFlameChartDataProvider = function(cpuProfile, target)
|
| -{
|
| - WebInspector.ProfileFlameChartDataProvider.call(this, target);
|
| - this._cpuProfile = cpuProfile;
|
| -};
|
| -
|
| -WebInspector.CPUFlameChartDataProvider.prototype = {
|
| - /**
|
| - * @override
|
| - * @return {!WebInspector.FlameChart.TimelineData}
|
| - */
|
| - _calculateTimelineData: function()
|
| - {
|
| - /**
|
| - * @constructor
|
| - * @param {number} depth
|
| - * @param {number} duration
|
| - * @param {number} startTime
|
| - * @param {number} selfTime
|
| - * @param {!WebInspector.CPUProfileNode} node
|
| - */
|
| - function ChartEntry(depth, duration, startTime, selfTime, node)
|
| - {
|
| - this.depth = depth;
|
| - this.duration = duration;
|
| - this.startTime = startTime;
|
| - this.selfTime = selfTime;
|
| - this.node = node;
|
| - }
|
| -
|
| - /** @type {!Array.<?ChartEntry>} */
|
| - var entries = [];
|
| - /** @type {!Array.<number>} */
|
| - var stack = [];
|
| - var maxDepth = 5;
|
| -
|
| - function onOpenFrame()
|
| - {
|
| - stack.push(entries.length);
|
| - // Reserve space for the entry, as they have to be ordered by startTime.
|
| - // The entry itself will be put there in onCloseFrame.
|
| - entries.push(null);
|
| - }
|
| - /**
|
| - * @param {number} depth
|
| - * @param {!WebInspector.CPUProfileNode} node
|
| - * @param {number} startTime
|
| - * @param {number} totalTime
|
| - * @param {number} selfTime
|
| - */
|
| - function onCloseFrame(depth, node, startTime, totalTime, selfTime)
|
| - {
|
| - var index = stack.pop();
|
| - entries[index] = new ChartEntry(depth, totalTime, startTime, selfTime, node);
|
| - maxDepth = Math.max(maxDepth, depth);
|
| - }
|
| - this._cpuProfile.forEachFrame(onOpenFrame, onCloseFrame);
|
| -
|
| - /** @type {!Array<!WebInspector.CPUProfileNode>} */
|
| - var entryNodes = new Array(entries.length);
|
| - var entryLevels = new Uint16Array(entries.length);
|
| - var entryTotalTimes = new Float32Array(entries.length);
|
| - var entrySelfTimes = new Float32Array(entries.length);
|
| - var entryStartTimes = new Float64Array(entries.length);
|
| - var minimumBoundary = this.minimumBoundary();
|
| -
|
| - for (var i = 0; i < entries.length; ++i) {
|
| - var entry = entries[i];
|
| - entryNodes[i] = entry.node;
|
| - entryLevels[i] = entry.depth;
|
| - entryTotalTimes[i] = entry.duration;
|
| - entryStartTimes[i] = entry.startTime;
|
| - entrySelfTimes[i] = entry.selfTime;
|
| - }
|
| -
|
| - this._maxStackDepth = maxDepth;
|
| -
|
| - this._timelineData = new WebInspector.FlameChart.TimelineData(entryLevels, entryTotalTimes, entryStartTimes, null);
|
| -
|
| - /** @type {!Array<!WebInspector.CPUProfileNode>} */
|
| - this._entryNodes = entryNodes;
|
| - this._entrySelfTimes = entrySelfTimes;
|
| -
|
| - return this._timelineData;
|
| - },
|
| -
|
| - /**
|
| - * @override
|
| - * @param {number} entryIndex
|
| - * @return {?Element}
|
| - */
|
| - prepareHighlightedEntryInfo: function(entryIndex)
|
| - {
|
| - var timelineData = this._timelineData;
|
| - var node = this._entryNodes[entryIndex];
|
| - if (!node)
|
| - return null;
|
| -
|
| - var entryInfo = [];
|
| - /**
|
| - * @param {string} title
|
| - * @param {string} value
|
| - */
|
| - function pushEntryInfoRow(title, value)
|
| - {
|
| - entryInfo.push({ title: title, value: value });
|
| - }
|
| - /**
|
| - * @param {number} ms
|
| - * @return {string}
|
| - */
|
| - function millisecondsToString(ms)
|
| - {
|
| - if (ms === 0)
|
| - return "0";
|
| - if (ms < 1000)
|
| - return WebInspector.UIString("%.1f\u2009ms", ms);
|
| - return Number.secondsToString(ms / 1000, true);
|
| - }
|
| - var name = WebInspector.beautifyFunctionName(node.functionName);
|
| - pushEntryInfoRow(WebInspector.UIString("Name"), name);
|
| - var selfTime = millisecondsToString(this._entrySelfTimes[entryIndex]);
|
| - var totalTime = millisecondsToString(timelineData.entryTotalTimes[entryIndex]);
|
| - pushEntryInfoRow(WebInspector.UIString("Self time"), selfTime);
|
| - pushEntryInfoRow(WebInspector.UIString("Total time"), totalTime);
|
| - var linkifier = new WebInspector.Linkifier();
|
| - var link = linkifier.maybeLinkifyConsoleCallFrame(this._target, node.callFrame);
|
| - if (link)
|
| - pushEntryInfoRow(WebInspector.UIString("URL"), link.textContent);
|
| - linkifier.dispose();
|
| - pushEntryInfoRow(WebInspector.UIString("Aggregated self time"), Number.secondsToString(node.self / 1000, true));
|
| - pushEntryInfoRow(WebInspector.UIString("Aggregated total time"), Number.secondsToString(node.total / 1000, true));
|
| - if (node.deoptReason)
|
| - pushEntryInfoRow(WebInspector.UIString("Not optimized"), node.deoptReason);
|
| -
|
| - return WebInspector.ProfileView.buildPopoverTable(entryInfo);
|
| - },
|
| -
|
| - __proto__: WebInspector.ProfileFlameChartDataProvider.prototype
|
| +WebInspector.CPUFlameChartDataProvider.ChartEntry = class {
|
| + /**
|
| + * @param {number} depth
|
| + * @param {number} duration
|
| + * @param {number} startTime
|
| + * @param {number} selfTime
|
| + * @param {!WebInspector.CPUProfileNode} node
|
| + */
|
| + constructor(depth, duration, startTime, selfTime, node) {
|
| + this.depth = depth;
|
| + this.duration = duration;
|
| + this.startTime = startTime;
|
| + this.selfTime = selfTime;
|
| + this.node = node;
|
| + }
|
| };
|
|
|