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

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

Issue 1624783002: DevTools: Switch to using fast stack iterator to collect stacks during timeline recording. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 0a7872fdc5c15b98863135737d5ba1b67cfa9fe5..f3f378553171457f3693fbb8de7e2f9f7b0a45db 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/CPUProfileDataModel.js
@@ -16,6 +16,7 @@ WebInspector.CPUProfileDataModel = function(profile)
this.profileEndTime = profile.endTime * 1000;
this._assignParentsInProfile();
if (this.samples) {
+ this._sortSamples();
this._normalizeTimestamps();
this._buildIdToNodeMap();
this._fixMissingSamples();
@@ -156,6 +157,32 @@ WebInspector.CPUProfileDataModel.prototype = {
}
},
+ _sortSamples: function()
+ {
+ var timestamps = this.timestamps;
+ var samples = this.samples;
+ var indices = timestamps.map((x, index) => index);
+ indices.sort((a, b) => timestamps[a] - timestamps[b]);
+ for (var i = 0; i < timestamps.length; ++i) {
+ var index = indices[i];
+ if (index === i)
+ continue;
+ // Move items in a cycle.
+ var savedTimestamp = timestamps[i];
+ var savedSample = samples[i];
+ var currentIndex = i;
+ while (index !== i) {
+ samples[currentIndex] = samples[index];
+ timestamps[currentIndex] = timestamps[index];
+ currentIndex = index;
+ index = indices[index];
+ indices[currentIndex] = currentIndex;
+ }
+ samples[currentIndex] = savedSample;
+ timestamps[currentIndex] = savedTimestamp;
+ }
+ },
+
_normalizeTimestamps: function()
{
var timestamps = this.timestamps;

Powered by Google App Engine
This is Rietveld 408576698