Web Inspector: UI performance tests are required.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Sep 2011 16:26:20 +0000 (16:26 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Sep 2011 16:26:20 +0000 (16:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68234

The idea is to create a set of tests which cover frequently used UI actions
and print the average time of these actions.
There are two pilot tests. The common part was extracted into performance-test helper.

Reviewed by Pavel Feldman.

* inspector/performance/resources/network-append-30-requests.html: Added.
* inspector/performance/resources/performance-test.js: Added.
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer):
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.start):
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.finish):
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.done):
(initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype._runTest):
* inspector/performance/resources/show-panel-network.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/inspector/performance/resources/network-append-30-requests.html [new file with mode: 0644]
LayoutTests/inspector/performance/resources/performance-test.js [new file with mode: 0644]
LayoutTests/inspector/performance/resources/show-panel-network.html [new file with mode: 0644]

index 3727b2ce3e8c5b7118ef51fabe6443537f0603e1..2a46c6cb096bcd48cc63c705e45d457f87a9b718 100644 (file)
@@ -1,3 +1,23 @@
+2011-09-16  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: UI performance tests are required.
+        https://bugs.webkit.org/show_bug.cgi?id=68234
+
+        The idea is to create a set of tests which cover frequently used UI actions
+        and print the average time of these actions.
+        There are two pilot tests. The common part was extracted into performance-test helper.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/performance/resources/network-append-30-requests.html: Added.
+        * inspector/performance/resources/performance-test.js: Added.
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.start):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.finish):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype.done):
+        (initialize_TimeTracker.InspectorTest.runPerformanceTest.Timer.prototype._runTest):
+        * inspector/performance/resources/show-panel-network.html: Added.
+
 2011-09-16  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt] Unreviewed gardening. Skip a flakey test.
diff --git a/LayoutTests/inspector/performance/resources/network-append-30-requests.html b/LayoutTests/inspector/performance/resources/network-append-30-requests.html
new file mode 100644 (file)
index 0000000..a2dd1c8
--- /dev/null
@@ -0,0 +1,46 @@
+<html>
+<head>
+<script src="../../../http/tests/inspector/inspector-test.js"></script>
+<script src="performance-test.js"></script>
+<script>
+
+function makeXHRRequests(count)
+{
+    for (var i = 0; i < count; ++i) {
+        var xhr = new XMLHttpRequest();
+        xhr.open("GET", document.url, true);
+        xhr.send();
+    }
+}
+
+function test()
+{
+    WebInspector.showPanel("network");
+
+    function test(timer)
+    {
+        WebInspector.panels.network._networkLogView._reset();
+        var cookie = timer.start("network-append-30-requests");
+        InspectorTest.evaluateInPage("makeXHRRequests(30)");
+        function finish()
+        {
+            timer.finish(cookie);
+            timer.done();
+        }
+        InspectorTest.addSniffer(WebInspector.panels.network._networkLogView, "refresh", finish);
+    }
+    InspectorTest.runPerformanceTest(test, 15000);
+}
+
+if (!window.layoutTestController) {
+    setTimeout(function() {
+        makeXHRRequests(30);
+    }, 3000);
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+</body>
+</html>
diff --git a/LayoutTests/inspector/performance/resources/performance-test.js b/LayoutTests/inspector/performance/resources/performance-test.js
new file mode 100644 (file)
index 0000000..e84c110
--- /dev/null
@@ -0,0 +1,73 @@
+var initialize_TimeTracker = function() {
+
+InspectorTest.runPerformanceTest = function(perfTest, executeTime, callback)
+{
+    var Timer = function(test, callback)
+    {
+        this._callback = callback;
+        this._test = test;
+        this._times = {};
+        this._testStartTime = new Date();
+    }
+
+    Timer.prototype = {
+        start: function(name)
+        {
+            return {name: name, startTime: new Date()};
+        },
+
+        finish: function(cookie)
+        {
+            var endTime = new Date();
+            if (!this._times[cookie.name])
+                this._times[cookie.name] = [];
+            this._times[cookie.name].push(endTime - cookie.startTime);
+        },
+
+        done: function()
+        {
+            var time = new Date();
+            if (time - this._testStartTime < executeTime)
+                this._runTest();
+            else {
+                this._dump();
+                if (this._callback)
+                    this._callback();
+                else
+                    InspectorTest.completeTest();
+            }
+        },
+
+        _runTest: function()
+        {
+            if (this._guard) {
+                setTimeout(this._runTest.bind(this), 0);
+                return;
+            }
+
+            this._guard = true;
+            var safeTest = InspectorTest.safeWrap(this._test);
+            safeTest(this);
+            this._guard = false;
+        },
+
+        _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);
+            }
+        }
+    }
+
+    var timer = new Timer(perfTest, callback);
+    timer._runTest();
+}
+
+}
diff --git a/LayoutTests/inspector/performance/resources/show-panel-network.html b/LayoutTests/inspector/performance/resources/show-panel-network.html
new file mode 100644 (file)
index 0000000..fa45a04
--- /dev/null
@@ -0,0 +1,48 @@
+<html>
+<head>
+<script src="../../../http/tests/inspector/inspector-test.js"></script>
+<script src="performance-test.js"></script>
+<script>
+
+function makeXHRRequests(count)
+{
+    for (var i = 0; i < count; ++i) {
+        var xhr = new XMLHttpRequest();
+        xhr.open("GET", document.url, true);
+        xhr.send();
+    }
+}
+
+
+function test()
+{
+    WebInspector.showPanel("network");
+    InspectorTest.evaluateInPage("makeXHRRequests(30)", step1);
+
+    function step1()
+    {
+        function perfTest1(timer)
+        {
+            WebInspector.showPanel("audits");
+            var timerCookie = timer.start("show-network-panel");
+            WebInspector.showPanel("network");
+            timer.finish(timerCookie);
+            timer.done();
+        }
+
+        InspectorTest.runPerformanceTest(perfTest1, 5000);
+    }
+}
+
+if (!window.layoutTestController) {
+    setTimeout(function() {
+        makeXHRRequests(700);
+    }, 3000);
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+</body>
+</html>