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 f83c2bfbb806a463227f1e1ec428a4716c01e4cf..948236f1ed997cf285928eaabab800fe24902600 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js |
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js |
@@ -36,11 +36,19 @@ 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; |
+ } 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); |
dgozman
2016/08/19 00:45:12
Let's call this in |isLegacyFormat| block?
alph
2016/08/20 01:51:10
Done.
|
this.profileHead = this._translateProfileTree(profile.nodes); |
@@ -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} |
*/ |