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

Unified Diff: webkit/glue/devtools/js/profiler_processor.js

Issue 113950: Separate results of profiling sessions.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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
« no previous file with comments | « webkit/glue/devtools/js/devtools_host_stub.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/devtools/js/profiler_processor.js
===================================================================
--- webkit/glue/devtools/js/profiler_processor.js (revision 17069)
+++ webkit/glue/devtools/js/profiler_processor.js (working copy)
@@ -36,14 +36,28 @@
/**
* Profiler processor. Consumes profiler log and builds profile views.
+ *
+ * @param {function(devtools.profiler.ProfileView)} newProfileCallback Callback
+ * that receives a new processed profile.
* @constructor
*/
-devtools.profiler.Processor = function() {
+devtools.profiler.Processor = function(newProfileCallback) {
/**
- * Current profile.
+ *
+ */
+ this.newProfileCallback_ = newProfileCallback;
+
+ /**
+ * Profiles array.
+ * @type {Array<devtools.profiler.JsProfile>}
+ */
+ this.profiles_ = [];
+
+ /**
+ * The current profile.
* @type {devtools.profiler.JsProfile}
*/
- this.profile_ = new devtools.profiler.JsProfile();
+ this.currentProfile_ = null;
/**
* Builder of profile views.
@@ -65,14 +79,16 @@
*/
devtools.profiler.Processor.RecordsDispatch_ = {
'code-creation': { parsers: [null, parseInt, parseInt, null],
- processor: 'processCodeCreation_' },
+ processor: 'processCodeCreation_', needsProfile: true },
'code-move': { parsers: [parseInt, parseInt],
- processor: 'processCodeMove_' },
- 'code-delete': { parsers: [parseInt], processor: 'processCodeDelete_' },
+ processor: 'processCodeMove_', needsProfile: true },
+ 'code-delete': { parsers: [parseInt],
+ processor: 'processCodeDelete_', needsProfile: true },
'tick': { parsers: [parseInt, parseInt, parseInt, 'var-args'],
- processor: 'processTick_' },
+ processor: 'processTick_', needsProfile: true },
+ 'profiler': { parsers: [null], processor: 'processProfiler_',
+ needsProfile: false },
// Not used in DevTools Profiler.
- 'profiler': null,
'shared-library': null,
// Obsolete row types.
'code-allocate': null,
@@ -129,7 +145,8 @@
}
var dispatch = devtools.profiler.Processor.RecordsDispatch_[command];
- if (dispatch === null) {
+ if (dispatch === null ||
+ (dispatch.needsProfile && this.currentProfile_ == null)) {
return;
}
@@ -153,19 +170,40 @@
};
+devtools.profiler.Processor.prototype.processProfiler_ = function(state) {
+ switch (state) {
+ case "resume":
+ this.currentProfile_ = new devtools.profiler.JsProfile();
+ this.profiles_.push(this.currentProfile_);
+ break;
+ case "pause":
+ if (this.currentProfile_ != null) {
+ this.newProfileCallback_(this.createProfileForView());
+ this.currentProfile_ = null;
+ }
+ break;
+ // These events are valid but are not used.
+ case "begin": break;
+ case "end": break;
+ default:
+ throw new Error("unknown profiler state: " + state);
+ }
+};
+
+
devtools.profiler.Processor.prototype.processCodeCreation_ = function(
type, start, size, name) {
- this.profile_.addCode(type, name, start, size);
+ this.currentProfile_.addCode(type, name, start, size);
};
devtools.profiler.Processor.prototype.processCodeMove_ = function(from, to) {
- this.profile_.moveCode(from, to);
+ this.currentProfile_.moveCode(from, to);
};
devtools.profiler.Processor.prototype.processCodeDelete_ = function(start) {
- this.profile_.deleteCode(start);
+ this.currentProfile_.deleteCode(start);
};
@@ -179,7 +217,7 @@
fullStack.push(parseInt(frame, 16));
}
}
- this.profile_.recordTick(fullStack);
+ this.currentProfile_.recordTick(fullStack);
};
@@ -194,8 +232,8 @@
// ProfileView.topDownProfileDataGridTree behavior.
profile.head = profile;
profile.heavyProfile = this.viewBuilder_.buildView(
- this.profile_.getBottomUpProfile(), true);
+ this.currentProfile_.getBottomUpProfile(), true);
profile.treeProfile = this.viewBuilder_.buildView(
- this.profile_.getTopDownProfile());
+ this.currentProfile_.getTopDownProfile());
return profile;
};
« no previous file with comments | « webkit/glue/devtools/js/devtools_host_stub.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698