Web Inspector: native memory snapshot performance and coverage test implementation.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2012 19:53:38 +0000 (19:53 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2012 19:53:38 +0000 (19:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89363

We have to track the performance of MemoryAgent.getProcessMemoryDistribution.
Also this test will work as a burn down chart for Unknown memory metric.

Reviewed by Pavel Feldman.

* inspector/native-memory-snapshot.html: Added.
* inspector/performance-test.js:
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer):
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.reportSize):
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype._dump):
(initialize_TimeTracker.InspectorTest.runPerformanceTest):

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

PerformanceTests/ChangeLog
PerformanceTests/inspector/native-memory-snapshot.html [new file with mode: 0644]
PerformanceTests/inspector/performance-test.js

index e3a8298..efb587b 100644 (file)
@@ -1,3 +1,20 @@
+2012-06-18  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: native memory snapshot performance and coverage test implementation.
+        https://bugs.webkit.org/show_bug.cgi?id=89363
+
+        We have to track the performance of MemoryAgent.getProcessMemoryDistribution.
+        Also this test will work as a burn down chart for Unknown memory metric.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/native-memory-snapshot.html: Added.
+        * inspector/performance-test.js:
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.reportSize):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype._dump):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest):
+
 2012-06-05  Alexei Filippov  <alexeif@chromium.org>
 
         Web Inspector: serialize edge counts instead of indexes in heap snapshot
diff --git a/PerformanceTests/inspector/native-memory-snapshot.html b/PerformanceTests/inspector/native-memory-snapshot.html
new file mode 100644 (file)
index 0000000..2ae05ba
--- /dev/null
@@ -0,0 +1,60 @@
+<html>
+<head>
+  <script src="../../LayoutTests/http/tests/inspector/inspector-test.js"></script>
+  <script src="performance-test.js"></script>
+<script>
+
+function test()
+{
+    function performanceTest(timer)
+    {
+        var testName = /([^\/]+)\.html$/.exec(WebInspector.inspectedPageURL)[1];
+        var takeTimerCookie = timer.start("take");
+        MemoryAgent.getProcessMemoryDistribution(dump);
+
+        function dump(e, data)
+        {
+            timer.finish(takeTimerCookie);
+            function reportSize(data)
+            {
+                timer.reportSize(data.name, data.size);
+                if (data.children) {
+                    for (var i = 0; i < data.children.length; ++i)
+                        reportSize(data.children[i]);
+                }
+            }
+            reportSize(data);
+            var knownSize = 0;
+            for (var i = 0; i < data.children.length; ++i)
+                knownSize += data.children[i].size;
+            timer.reportSize("Unknown", data.size - knownSize);
+            timer.done(testName);
+        }
+    }
+
+    InspectorTest.runPerformanceTest(performanceTest, 2000);
+}
+
+function createDOMTree(elementsCount)
+{
+    var root = document.getElementById("testTreeRoot");
+
+    for (var i = 0; i < elementsCount; ++i)
+        root.appendChild(document.createElement("span"));
+
+    for (var i = 0; i < elementsCount; ++i)
+        root.appendChild(document.createElement("div"));
+
+    for (var i = 0; i < elementsCount; ++i)
+        root.appendChild(document.createElement("a"));
+}
+
+setTimeout(createDOMTree.bind(null,1000), 0);
+
+</script>
+</head>
+<body onload="runTest()">
+  <div id="testTreeRoot">
+  </div>
+</body>
+</html>
index fbb5ec2..fec1dd3 100644 (file)
@@ -7,6 +7,7 @@ InspectorTest.runPerformanceTest = function(perfTest, executeTime, callback)
         this._callback = callback;
         this._test = test;
         this._times = {};
+        this._sizes = {};
         this._testStartTime = new Date();
         this._heapSizeDeltas = [];
         this._jsHeapSize = this._getJSHeapSize();
@@ -26,6 +27,13 @@ InspectorTest.runPerformanceTest = function(perfTest, executeTime, callback)
             this._times[cookie.name].push(endTime - cookie.startTime);
         },
 
+        reportSize: function(name, size)
+        {
+            if (!this._sizes[name])
+                this._sizes[name] = [];
+            this._sizes[name].push(size);
+        },
+
         _getJSHeapSize: function()
         {
             if (window.gc) {
@@ -75,6 +83,9 @@ InspectorTest.runPerformanceTest = function(perfTest, executeTime, callback)
             for (var testName in this._times)
                 InspectorTest.dumpTestStats(groupName, testName, this._times[testName], "ms");
 
+            for (var testName in this._sizes)
+                InspectorTest.dumpTestStats(groupName, testName, this._sizes[testName], "kB", 1024);
+
             var url = WebInspector.inspectedPageURL;
             var regExp = /([^\/]+)\.html/;
             var matches = regExp.exec(url);