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

Unified Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineJSProfile.js

Issue 1748993002: DevTools: Initial implementation of line-level CPU profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added a test. Created 4 years, 9 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/timeline/TimelineJSProfile.js
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineJSProfile.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineJSProfile.js
index ea1e23a3123759c3492dfe581a30c41828784ed1..6c9a3ba0cbe68e6b0c6aa549167d2b6e7d7c0d50 100644
--- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineJSProfile.js
+++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineJSProfile.js
@@ -6,15 +6,12 @@
WebInspector.TimelineJSProfileProcessor = { };
/**
- * @param {!ProfilerAgent.CPUProfile} jsProfile
+ * @param {!WebInspector.CPUProfileDataModel} jsProfileModel
* @param {!WebInspector.TracingModel.Thread} thread
* @return {!Array<!WebInspector.TracingModel.Event>}
*/
-WebInspector.TimelineJSProfileProcessor.generateTracingEventsFromCpuProfile = function(jsProfile, thread)
+WebInspector.TimelineJSProfileProcessor.generateTracingEventsFromCpuProfile = function(jsProfileModel, thread)
{
- if (!jsProfile.samples)
- return [];
- var jsProfileModel = new WebInspector.CPUProfileDataModel(jsProfile);
var idleNode = jsProfileModel.idleNode;
var programNode = jsProfileModel.programNode;
var gcNode = jsProfileModel.gcNode;
@@ -494,3 +491,55 @@ WebInspector.TimelineJSProfileProcessor.processRawV8Samples = function(events)
return samples;
}
+
+/**
+ * @param {!WebInspector.CPUProfileDataModel} profile
+ */
+WebInspector.TimelineJSProfileProcessor.buildLineLevelProfiles = function(profile)
+{
+ var nodesToGo = [profile.profileHead];
+ var sampleDuration = (profile.profileEndTime - profile.profileStartTime) / profile.totalHitCount;
+ /** @type {!Map<string, !Map<number,number>>} */
+ var files = new Map();
+ while (nodesToGo.length) {
+ var nodes = nodesToGo.pop().children;
+ for (var i = 0; i < nodes.length; ++i) {
+ var node = nodes[i];
+ if (!node.url || !node.positionTicks)
+ continue;
+ var fileInfo = files.get(node.url);
+ if (!fileInfo) {
+ fileInfo = new Map();
+ files.set(node.url, fileInfo);
+ }
+ for (var j = 0; j < node.positionTicks.length; ++j) {
+ var lineInfo = node.positionTicks[j];
+ var line = lineInfo.line - 1;
+ var time = lineInfo.ticks * sampleDuration;
+ fileInfo.set(line, (fileInfo.get(line) || 0) + time);
+ }
+ nodesToGo.push(node);
+ }
+ }
+ for (var fileInfo of files) {
+ var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(/** @type {string} */ (fileInfo[0]));
+ if (!uiSourceCode)
+ continue;
+ for (var lineInfo of fileInfo[1]) {
+ var line = lineInfo[0];
+ var time = lineInfo[1];
+ var text = WebInspector.UIString("%.1f\xa0ms", time);
caseq 2016/03/11 22:52:05 Can we get UI stuff out of model classes?
alph 2016/03/12 00:47:54 Done.
+ var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1);
+ var object = {
+ text: text,
+ intensity: intensity
+ };
+ uiSourceCode.addLineDecoration(line, "performance", object);
caseq 2016/03/11 22:52:05 ditto.
alph 2016/03/12 00:47:54 Done.
+ }
+ }
+}
+
+WebInspector.TimelineJSProfileProcessor.resetLineLevelProfiles = function()
+{
+ WebInspector.workspace.uiSourceCodes().forEach(uiSourceCode => uiSourceCode.removeAllLineDecorations("performance"));
+}

Powered by Google App Engine
This is Rietveld 408576698