| Index: third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
|
| index e42e66f5a8210468f45db59955fbc06fa7af4a83..a93f1e099b3aa1b2fce035f4a67777ad70dc4cf6 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
|
| @@ -36,13 +36,21 @@ WebInspector.CPUProfileNode.prototype = {
|
| */
|
| WebInspector.CPUProfileDataModel = function(profile)
|
| {
|
| + var isLegacyFormat = !!profile.head;
|
| + if (isLegacyFormat) {
|
| + // Legacy format contains raw timestamps and start/stop times are in seconds.
|
| + this.profileStartTime = profile.startTime * 1000;
|
| + this.profileEndTime = profile.endTime * 1000;
|
| + this.timestamps = profile.timestamps;
|
| + this._compatibilityConversionHeadToNodes(profile);
|
| + } else {
|
| + // Current format encodes timestamps as deltas. Start/stop times are in microseconds.
|
| + this.profileStartTime = profile.startTime / 1000;
|
| + this.profileEndTime = profile.endTime / 1000;
|
| + this.timestamps = this._convertTimestampDeltas(profile);
|
| + }
|
| this.samples = profile.samples;
|
| - this.timestamps = profile.timestamps;
|
| - // Convert times from sec to msec.
|
| - this.profileStartTime = profile.startTime * 1000;
|
| - this.profileEndTime = profile.endTime * 1000;
|
| this.totalHitCount = 0;
|
| - this._compatibilityConversionHeadToNodes(profile);
|
| this.profileHead = this._translateProfileTree(profile.nodes);
|
| WebInspector.ProfileTreeModel.call(this, this.profileHead);
|
| this._extractMetaNodes();
|
| @@ -79,6 +87,23 @@ WebInspector.CPUProfileDataModel.prototype = {
|
| },
|
|
|
| /**
|
| + * @param {!ProfilerAgent.CPUProfile} profile
|
| + * @return {?Array<number>}
|
| + */
|
| + _convertTimestampDeltas: function(profile)
|
| + {
|
| + if (!profile.timestampDeltas)
|
| + return null;
|
| + var lastTimeUsec = profile.startTime;
|
| + var timestamps = new Array(profile.timestampDeltas.length);
|
| + for (var i = 0; i < timestamps.length; ++i) {
|
| + lastTimeUsec += profile.timestampDeltas[i];
|
| + timestamps[i] = lastTimeUsec;
|
| + }
|
| + return timestamps;
|
| + },
|
| +
|
| + /**
|
| * @param {!Array<!ProfilerAgent.CPUProfileNode>} nodes
|
| * @return {!WebInspector.CPUProfileNode}
|
| */
|
|
|