Web Inspector: It'd be useful to have performance stats for the back-end to front...
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2011 14:30:54 +0000 (14:30 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Sep 2011 14:30:54 +0000 (14:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69002

Reviewed by Yury Semikhatsky.

* inspector/CodeGeneratorInspector.pm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@96222 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/CodeGeneratorInspector.pm

index 7ed06c989373d5a299b568eb7713629b4ffe817b..9c6ce0875e1c4540bea9b8eae9faee5d50caa9f9 100644 (file)
@@ -1,3 +1,12 @@
+2011-09-28  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        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  <podivilov@chromium.org>
 
         Web Inspector: live edit cursor always appears at the beginning of the file.
index 1dda980e444d6985b4bafb732aec3ba2c12f750e..a4f72ebf66ea94c70e45b49d90653240fcf44cc1 100644 (file)
@@ -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));
         }
     },