Web Inspector: UI performance: introduce heap size tracking stats.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2011 15:26:34 +0000 (15:26 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2011 15:26:34 +0000 (15:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68901

It is interesting how much the heap memory is used by Inspector in order of running the test.

Reviewed by Yury Semikhatsky.

Tools:

* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::showDevTools):
(TestShell::closeDevTools):

LayoutTests:

* inspector/performance/resources/network-append-30-requests.html:
* inspector/performance/resources/performance-test.js:
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer):
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype._getJSHeapSize):
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.done):
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype._dump):

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

LayoutTests/ChangeLog
LayoutTests/inspector/performance/resources/network-append-30-requests.html
LayoutTests/inspector/performance/resources/performance-test.js
Tools/ChangeLog
Tools/DumpRenderTree/chromium/TestShell.cpp

index 815be3d7e1e3b1f025860cddee21b6f9ad3c07d9..63e01258465cd0e329625cee7cae0fc385d8d2ff 100644 (file)
@@ -1,3 +1,19 @@
+2011-09-27  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: UI performance: introduce heap size tracking stats.
+        https://bugs.webkit.org/show_bug.cgi?id=68901
+
+        It is interesting how much the heap memory is used by Inspector in order of running the test.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/performance/resources/network-append-30-requests.html:
+        * inspector/performance/resources/performance-test.js:
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype._getJSHeapSize):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.done):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype._dump):
+
 2011-09-27  W. James MacLean  <wjmaclean@chromium.org>
 
         Layout Test platform/chromium/compositing/zoom-animator-scale-test.html is failing.
index a2dd1c8cc3f57cd5bd6c6831b18014330cdcb11a..644db5d9c302a6dde13d5e8e7549262e26845142 100644 (file)
@@ -8,7 +8,7 @@ function makeXHRRequests(count)
 {
     for (var i = 0; i < count; ++i) {
         var xhr = new XMLHttpRequest();
-        xhr.open("GET", document.url, true);
+        xhr.open("GET", document.URL, true);
         xhr.send();
     }
 }
index 9eac9aefb8c50998adb0f965a71340ef2913b1dd..54b6df9bb974f65e035e0698b68c5fd545c3f6e7 100644 (file)
@@ -8,6 +8,8 @@ InspectorTest.runPerformanceTest = function(perfTest, executeTime, callback)
         this._test = test;
         this._times = {};
         this._testStartTime = new Date();
+        this._heapSizeDeltas = [];
+        this._jsHeapSize = this._getJSHeapSize();
     }
 
     Timer.prototype = {
@@ -24,8 +26,18 @@ InspectorTest.runPerformanceTest = function(perfTest, executeTime, callback)
             this._times[cookie.name].push(endTime - cookie.startTime);
         },
 
+        _getJSHeapSize: function()
+        {
+            window.gc();
+            window.gc();
+            return console.memory.usedJSHeapSize;
+        },
+
         done: function()
         {
+            this._heapSizeDeltas.push(console.memory.usedJSHeapSize - this._jsHeapSize);
+            this._jsHeapSize = this._getJSHeapSize();
+
             var time = new Date();
             if (time - this._testStartTime < executeTime)
                 this._runTest();
@@ -53,16 +65,25 @@ InspectorTest.runPerformanceTest = function(perfTest, executeTime, callback)
 
         _dump: function()
         {
-            for (var testName in this._times) {
-                var samples = this._times[testName];
-                var stripNResults = Math.floor(samples.length / 10);
-                samples.sort(function(a, b) { return a - b; });
-                var sum = 0;
-                for (var i = stripNResults; i < samples.length - stripNResults; ++i)
-                    sum += samples[i];
-                InspectorTest.addResult("* " + testName + ": " + Math.floor(sum / (samples.length - stripNResults * 2)));
-                InspectorTest.addResult(testName + " min/max/count: " + samples[0] + "/" + samples[samples.length-1] + "/" + samples.length);
-            }
+            for (var testName in this._times)
+                this._dumpTestStats(testName, this._times[testName]);
+
+            var url = WebInspector.mainResource._documentURL;
+            var regExp = /([^\/]+)\.html/;
+            var matches = regExp.exec(url);
+            this._dumpTestStats("heap-delta-kb-" + matches[1], this._heapSizeDeltas, 1024);
+        },
+
+        _dumpTestStats: function(testName, samples, divider)
+        {
+            divider = divider || 1;
+            var stripNResults = Math.floor(samples.length / 10);
+            samples.sort(function(a, b) { return a - b; });
+            var sum = 0;
+            for (var i = stripNResults; i < samples.length - stripNResults; ++i)
+                sum += samples[i];
+            InspectorTest.addResult("* " + testName + ": " + Math.floor(sum / (samples.length - stripNResults * 2) / divider));
+            InspectorTest.addResult(testName + " min/max/count: " + Math.floor(samples[0] / divider) + "/" + Math.floor(samples[samples.length-1] / divider) + "/" + samples.length);
         }
     }
 
@@ -85,5 +106,4 @@ InspectorTest.addBackendResponseSniffer = function(object, methodName, override,
     }
 }
 
-
 }
index 165ade6fae7dd4ac064d7d6b08ee961aa781a5d6..565548a498a62caee4dad172546bca14b191175c 100644 (file)
@@ -1,3 +1,16 @@
+2011-09-27  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: UI performance: introduce heap size tracking stats.
+        https://bugs.webkit.org/show_bug.cgi?id=68901
+
+        It is interesting how much the heap memory is used by Inspector in order of running the test.
+
+        Reviewed by Yury Semikhatsky.
+
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::showDevTools):
+        (TestShell::closeDevTools):
+
 2011-09-23  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
 
         [Qt] Fix build against Qt5 after refactor of widgets out of QtGUi
index 7b1501c909df3ba1c9d52d257b7a670adf0187ad..3e4c94ce8b25e2c9ce3c3005e2b7c3df88758833 100644 (file)
@@ -176,6 +176,7 @@ void TestShell::showDevTools()
             return;
         }
         m_devTools = createNewWindow(url);
+        m_devTools->webView()->settings()->setMemoryInfoEnabled(true);
         ASSERT(m_devTools);
         createDRTDevToolsClient(m_drtDevToolsAgent.get());
     }
@@ -185,6 +186,7 @@ void TestShell::showDevTools()
 void TestShell::closeDevTools()
 {
     if (m_devTools) {
+        m_devTools->webView()->settings()->setMemoryInfoEnabled(false);
         m_drtDevToolsAgent->reset();
         m_drtDevToolsClient.clear();
         closeWindow(m_devTools);