From c7aeb223d42d4be7d98f288a56e454564fa272bb Mon Sep 17 00:00:00 2001 From: "loislo@chromium.org" Date: Wed, 28 Sep 2011 14:30:54 +0000 Subject: [PATCH] Web Inspector: It'd be useful to have performance stats for the back-end to front-end communication channel. https://bugs.webkit.org/show_bug.cgi?id=69002 Reviewed by Yury Semikhatsky. * inspector/CodeGeneratorInspector.pm: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96222 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 9 +++++++ Source/WebCore/inspector/CodeGeneratorInspector.pm | 29 +++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 7ed06c9..9c6ce08 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,12 @@ +2011-09-28 Ilya Tikhonovsky + + Web Inspector: It'd be useful to have performance stats for the back-end to front-end communication channel. + https://bugs.webkit.org/show_bug.cgi?id=69002 + + Reviewed by Yury Semikhatsky. + + * inspector/CodeGeneratorInspector.pm: + 2011-09-27 Pavel Podivilov Web Inspector: live edit cursor always appears at the beginning of the file. diff --git a/Source/WebCore/inspector/CodeGeneratorInspector.pm b/Source/WebCore/inspector/CodeGeneratorInspector.pm index 1dda980..a4f72eb 100644 --- a/Source/WebCore/inspector/CodeGeneratorInspector.pm +++ b/Source/WebCore/inspector/CodeGeneratorInspector.pm @@ -776,6 +776,9 @@ $JSRegisterDomainDispatchers } InspectorBackendStub.prototype = { + dumpInspectorTimeStats: 0, + dumpInspectorProtocolMessages: 0, + _wrap: function(callback) { var callbackId = this._lastCallbackId++; @@ -849,9 +852,15 @@ InspectorBackendStub.prototype = { _wrapCallbackAndSendMessageObject: function(messageObject, callback) { - messageObject.id = this._wrap(callback || function() {}); + messageObject.id = this._wrap(callback); + + if (this.dumpInspectorTimeStats) { + var wrappedCallback = this._callbacks[messageObject.id]; + wrappedCallback.methodName = messageObject.method; + wrappedCallback.sendRequestTime = Date.now(); + } - if (window.dumpInspectorProtocolMessages) + if (this.dumpInspectorProtocolMessages) console.log("frontend: " + JSON.stringify(messageObject)); ++this._pendingResponsesCount; @@ -872,7 +881,7 @@ InspectorBackendStub.prototype = { dispatch: function(message) { - if (window.dumpInspectorProtocolMessages) + if (this.dumpInspectorProtocolMessages) console.log("backend: " + ((typeof message === "string") ? message : JSON.stringify(message))); var messageObject = (typeof message === "string") ? JSON.parse(message) : message; @@ -916,10 +925,17 @@ InspectorBackendStub.prototype = { var callback = this._callbacks[messageObject.id]; if (callback) { + var processingStartTime; + if (this.dumpInspectorTimeStats && callback.methodName) + processingStartTime = Date.now(); + arguments.unshift(messageObject.error); callback.apply(null, arguments); --this._pendingResponsesCount; delete this._callbacks[messageObject.id]; + + if (this.dumpInspectorTimeStats && callback.methodName) + console.log("time-stats: " + callback.methodName + " = " + (processingStartTime - callback.sendRequestTime) + " + " + (Date.now() - processingStartTime)); } if (this._scripts && !this._pendingResponsesCount) @@ -952,7 +968,14 @@ InspectorBackendStub.prototype = { params.push(messageObject.params[paramNames[i]]); } + var processingStartTime; + if (this.dumpInspectorTimeStats) + processingStartTime = Date.now(); + dispatcher[functionName].apply(dispatcher, params); + + if (this.dumpInspectorTimeStats) + console.log("time-stats: " + messageObject.method + " = " + (Date.now() - processingStartTime)); } }, -- 2.7.4