Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js

Issue 2262543002: DevTools: Profiler domain refactoring: encode timestamps as deltas. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 4 landing Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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}
*/

Powered by Google App Engine
This is Rietveld 408576698