summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-28 15:51:49 +0000
committermnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-28 15:51:49 +0000
commitbc33617353758510d4a7dc8c585a7a8e07e19e55 (patch)
treeaec536e4222277c60801529cb10319da78d29ca6
parent82fbbe66c39262147ee501daa1df53e3b669e385 (diff)
downloadchromium_src-bc33617353758510d4a7dc8c585a7a8e07e19e55.zip
chromium_src-bc33617353758510d4a7dc8c585a7a8e07e19e55.tar.gz
chromium_src-bc33617353758510d4a7dc8c585a7a8e07e19e55.tar.bz2
Separate results of profiling sessions.
Now data for each profiling session is collected separately (previously they were accumulated in a single profile). BUG=none TEST=none Review URL: http://codereview.chromium.org/113950 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17072 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/glue/devtools/js/debugger_agent.js30
-rw-r--r--webkit/glue/devtools/js/devtools_host_stub.js10
-rw-r--r--webkit/glue/devtools/js/profiler_processor.js68
3 files changed, 75 insertions, 33 deletions
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js
index 890f704..e714326 100644
--- a/webkit/glue/devtools/js/debugger_agent.js
+++ b/webkit/glue/devtools/js/debugger_agent.js
@@ -69,11 +69,10 @@ devtools.DebuggerAgent = function() {
this.scriptsCacheInitialized_ = false;
/**
- * Whether user has stopped profiling and we are retrieving the rest of
- * profiler's log.
+ * Whether profiling session is started.
* @type {boolean}
*/
- this.isProcessingProfile_ = false;
+ this.isProfilingStarted_ = false;
/**
* The position in log file to read from.
@@ -85,7 +84,8 @@ devtools.DebuggerAgent = function() {
* Profiler processor instance.
* @type {devtools.profiler.Processor}
*/
- this.profilerProcessor_ = new devtools.profiler.Processor();
+ this.profilerProcessor_ = new devtools.profiler.Processor(
+ goog.bind(WebInspector.addProfile, WebInspector));
};
@@ -348,11 +348,7 @@ devtools.DebuggerAgent.prototype.resolveChildren = function(object, callback) {
* Starts (resumes) profiling.
*/
devtools.DebuggerAgent.prototype.startProfiling = function() {
- if (this.isProcessingProfile_) {
- return;
- }
RemoteDebuggerAgent.StartProfiling();
- // Query if profiling has been really started.
RemoteDebuggerAgent.IsProfilingStarted();
};
@@ -361,7 +357,6 @@ devtools.DebuggerAgent.prototype.startProfiling = function() {
* Stops (pauses) profiling.
*/
devtools.DebuggerAgent.prototype.stopProfiling = function() {
- this.isProcessingProfile_ = true;
RemoteDebuggerAgent.StopProfiling();
};
@@ -613,11 +608,17 @@ devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) {
*/
devtools.DebuggerAgent.prototype.didIsProfilingStarted_ = function(
is_started) {
- if (is_started) {
+ if (is_started && !this.isProfilingStarted_) {
// Start to query log data.
RemoteDebuggerAgent.GetLogLines(this.lastProfileLogPosition_);
}
+ this.isProfilingStarted_ = is_started;
+ // Update button.
WebInspector.setRecordingProfile(is_started);
+ if (is_started) {
+ // Monitor profiler state. It can stop itself on buffer fill-up.
+ setTimeout(function() { RemoteDebuggerAgent.IsProfilingStarted(); }, 1000);
+ }
};
@@ -632,14 +633,11 @@ devtools.DebuggerAgent.prototype.didGetLogLines_ = function(
if (log.length > 0) {
this.profilerProcessor_.processLogChunk(log);
this.lastProfileLogPosition_ = newPosition;
- } else if (this.isProcessingProfile_) {
- this.isProcessingProfile_ = false;
- WebInspector.setRecordingProfile(false);
- WebInspector.addProfile(this.profilerProcessor_.createProfileForView());
+ } else if (!this.isProfilingStarted_) {
+ // No new data and profiling is stopped---suspend log reading.
return;
}
- setTimeout(function() { RemoteDebuggerAgent.GetLogLines(newPosition); },
- this.isProcessingProfile_ ? 100 : 1000);
+ setTimeout(function() { RemoteDebuggerAgent.GetLogLines(newPosition); }, 500);
};
diff --git a/webkit/glue/devtools/js/devtools_host_stub.js b/webkit/glue/devtools/js/devtools_host_stub.js
index ff52d26..d6da1c2 100644
--- a/webkit/glue/devtools/js/devtools_host_stub.js
+++ b/webkit/glue/devtools/js/devtools_host_stub.js
@@ -11,6 +11,7 @@
* @constructor
*/
RemoteDebuggerAgentStub = function() {
+ this.isProfiling_ = false;
};
RemoteDebuggerAgentStub.prototype.DebugBreak = function() {
@@ -21,14 +22,17 @@ RemoteDebuggerAgentStub.prototype.GetContextId = function() {
};
RemoteDebuggerAgentStub.prototype.StopProfiling = function() {
+ this.isProfiling_ = false;
};
RemoteDebuggerAgentStub.prototype.StartProfiling = function() {
+ this.isProfiling_ = true;
};
RemoteDebuggerAgentStub.prototype.IsProfilingStarted = function() {
+ var self = this;
setTimeout(function() {
- RemoteDebuggerAgent.DidIsProfilingStarted(true);
+ RemoteDebuggerAgent.DidIsProfilingStarted(self.isProfiling_);
}, 100);
};
@@ -230,6 +234,7 @@ RemoteToolsAgentStub.prototype.ClearConsoleMessages = function() {
RemoteDebuggerAgentStub.ProfilerLogBuffer =
+ 'profiler,resume\n' +
'code-creation,LazyCompile,0x1000,256,"test1 http://aaa.js:1"\n' +
'code-creation,LazyCompile,0x2000,256,"test2 http://bbb.js:2"\n' +
'code-creation,LazyCompile,0x3000,256,"test3 http://ccc.js:3"\n' +
@@ -240,7 +245,8 @@ RemoteDebuggerAgentStub.ProfilerLogBuffer =
'tick,0x2020,0x0,3,0x1010\n' +
'tick,0x2030,0x0,3,0x2020, 0x1010\n' +
'tick,0x2020,0x0,3,0x1010\n' +
- 'tick,0x1010,0x0,3\n';
+ 'tick,0x1010,0x0,3\n' +
+ 'profiler,pause\n';
/**
diff --git a/webkit/glue/devtools/js/profiler_processor.js b/webkit/glue/devtools/js/profiler_processor.js
index e290350..3f13129 100644
--- a/webkit/glue/devtools/js/profiler_processor.js
+++ b/webkit/glue/devtools/js/profiler_processor.js
@@ -36,14 +36,28 @@ devtools.profiler.JsProfile.prototype.skipThisFunction = function(name) {
/**
* 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) {
+ /**
+ *
+ */
+ this.newProfileCallback_ = newProfileCallback;
+
+ /**
+ * Profiles array.
+ * @type {Array<devtools.profiler.JsProfile>}
+ */
+ this.profiles_ = [];
+
/**
- * Current profile.
+ * 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 = function() {
*/
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 @@ devtools.profiler.Processor.prototype.dispatchLogRow_ = function(fields) {
}
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.dispatchLogRow_ = function(fields) {
};
+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 @@ devtools.profiler.Processor.prototype.processTick_ = function(
fullStack.push(parseInt(frame, 16));
}
}
- this.profile_.recordTick(fullStack);
+ this.currentProfile_.recordTick(fullStack);
};
@@ -194,8 +232,8 @@ devtools.profiler.Processor.prototype.createProfileForView = function() {
// 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;
};