Layout/floats.html should be runnable by run-perf-tests
authorachicu@adobe.com <achicu@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Mar 2012 01:07:27 +0000 (01:07 +0000)
committerachicu@adobe.com <achicu@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Mar 2012 01:07:27 +0000 (01:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77051

Reviewed by Ryosuke Niwa.

I've split Layout/floats.html into multiple tests for each button in the original manual test.
Some tests take longer to run and I've changed the number of iterations, so that each tests finishes under 30s per run.

* DOM/resources/dom-perf.js:
* Layout/floats.html: Removed.
* Layout/floats_100_100.html: Added.
* Layout/floats_100_100_nested.html: Added.
* Layout/floats_20_100.html: Added.
* Layout/floats_20_100_nested.html: Added.
* Layout/floats_2_100.html: Added.
* Layout/floats_2_100_nested.html: Added.
* Layout/floats_50_100.html: Added.
* Layout/floats_50_100_nested.html: Added.
* Layout/resources/floats.css: Added.
(.container):
(.float):
(.big):
(.float-end):
* Layout/resources/floats.js: Added.
(.):
* Skipped:
* resources/runner.js:
(PerfTestRunner.resetRandomSeed):
(PerfTestRunner.random):
(Math.random):
    Moved the Math.random to runner.js to be used by all tests.
    Added resetRandomSeed to bring the randomizer back to initial seed.
    It is useful to get the same results at every run and minimize the
    differences between runs.

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

15 files changed:
PerformanceTests/ChangeLog
PerformanceTests/DOM/resources/dom-perf.js
PerformanceTests/Layout/floats.html [deleted file]
PerformanceTests/Layout/floats_100_100.html [new file with mode: 0644]
PerformanceTests/Layout/floats_100_100_nested.html [new file with mode: 0644]
PerformanceTests/Layout/floats_20_100.html [new file with mode: 0644]
PerformanceTests/Layout/floats_20_100_nested.html [new file with mode: 0644]
PerformanceTests/Layout/floats_2_100.html [new file with mode: 0644]
PerformanceTests/Layout/floats_2_100_nested.html [new file with mode: 0644]
PerformanceTests/Layout/floats_50_100.html [new file with mode: 0644]
PerformanceTests/Layout/floats_50_100_nested.html [new file with mode: 0644]
PerformanceTests/Layout/resources/floats.css [new file with mode: 0644]
PerformanceTests/Layout/resources/floats.js [new file with mode: 0644]
PerformanceTests/Skipped
PerformanceTests/resources/runner.js

index 72e68c2..7fdebc6 100644 (file)
@@ -1,3 +1,40 @@
+2012-03-14  Alexandru Chiculita  <achicu@adobe.com>
+
+        Layout/floats.html should be runnable by run-perf-tests
+        https://bugs.webkit.org/show_bug.cgi?id=77051
+
+        Reviewed by Ryosuke Niwa.
+
+        I've split Layout/floats.html into multiple tests for each button in the original manual test.
+        Some tests take longer to run and I've changed the number of iterations, so that each tests finishes under 30s per run.
+
+        * DOM/resources/dom-perf.js:
+        * Layout/floats.html: Removed.
+        * Layout/floats_100_100.html: Added.
+        * Layout/floats_100_100_nested.html: Added.
+        * Layout/floats_20_100.html: Added.
+        * Layout/floats_20_100_nested.html: Added.
+        * Layout/floats_2_100.html: Added.
+        * Layout/floats_2_100_nested.html: Added.
+        * Layout/floats_50_100.html: Added.
+        * Layout/floats_50_100_nested.html: Added.
+        * Layout/resources/floats.css: Added.
+        (.container):
+        (.float):
+        (.big):
+        (.float-end):
+        * Layout/resources/floats.js: Added.
+        (.):
+        * Skipped:
+        * resources/runner.js:
+        (PerfTestRunner.resetRandomSeed):
+        (PerfTestRunner.random):
+        (Math.random):
+            Moved the Math.random to runner.js to be used by all tests.
+            Added resetRandomSeed to bring the randomizer back to initial seed.
+            It is useful to get the same results at every run and minimize the
+            differences between runs.
+
 2012-03-14  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r110559.
index 45eb4c6..11291a3 100644 (file)
@@ -115,22 +115,6 @@ function GetProfiler() {
     return new PseudoProfiler();
 }
 
-// To make the benchmark results predictable, we replace Math.random with a
-// 100% deterministic alternative.
-Math.random = (function() {
-    var seed = 49734321;
-    return function() {
-        // Robert Jenkins' 32 bit integer hash function.
-        seed = ((seed + 0x7ed55d16) + (seed << 12))  & 0xffffffff;
-        seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff;
-        seed = ((seed + 0x165667b1) + (seed << 5))   & 0xffffffff;
-        seed = ((seed + 0xd3a2646c) ^ (seed << 9))   & 0xffffffff;
-        seed = ((seed + 0xfd7046c5) + (seed << 3))   & 0xffffffff;
-        seed = ((seed ^ 0xb55a4f09) ^ (seed >>> 16)) & 0xffffffff;
-        return (seed & 0xfffffff) / 0x10000000;
-    };
-})();
-
 function Benchmark(name, run, opt_setup, opt_cleanup, opt_shareSetup) {
     this.name = name;
     this.timeToRun = 100; // ms.
diff --git a/PerformanceTests/Layout/floats.html b/PerformanceTests/Layout/floats.html
deleted file mode 100644 (file)
index 52f95ba..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-<!DOCTYPE html>
-<html>
-    <head>
-        <title>Floats layout performance tester</title>
-        <style>
-            .float {
-                float: left;
-                width: 5px;
-                height: 5px;
-                border: 1px solid green;
-            }
-            .big {
-                width: 10px;
-            }
-            .float-end {
-                clear:left;
-            }
-
-            #framerate_panel {
-                display: none;
-            }
-        </style>
-        <script>
-            function createElement(tag, parent, className, id)
-            {
-                var el = document.createElement(tag);
-                el.className = className;
-                el.id = id;
-                parent.appendChild(el);
-                return el;
-            }
-
-            function createSet(width, height, nested)
-            {
-                var container = createElement("div", document.body, "container");
-                for (var y = 0; y < height; ++y) {
-                    for (var x = 0; x < width; ++x)
-                        createElement("div", container, "float", "float" + x + "_" + y);
-
-                    var nestedContainer = container;
-                    for ( ; nested > 0; --nested)
-                        nestedContainer = createElement("div", nestedContainer, "nested", "nested" + x + "_" + nested);
-                    
-                    createElement("div", container, "float-end", "end" + x)
-                }
-            }
-
-            function toggle(str, str1, str2)
-            {
-                if (str == str1)
-                    return str2;
-                return str1;
-            }
-
-            function test(width, height, nested) 
-            {
-                nested = nested || 0;
-
-                document.getElementById("test_panel").style.display = "none";
-                document.getElementById("framerate_panel").style.display = "block";
-
-                createSet(width, height, nested);
-                var updates = 0;
-                var startTime = new Date();
-
-                function updateTimer()
-                {
-                    ++updates;
-
-                    var newTime = new Date();
-                    var deltaTime = newTime - startTime;
-
-                    if ((deltaTime > 0 && updates > 100) || deltaTime > 1000) {
-                        var fps = updates * 100 / deltaTime;
-                        document.getElementById("fps").innerHTML = fps;
-                        updates = 0;
-                        startTime = newTime;
-                    }
-                }
-
-                function update()
-                {
-                    var x = Math.floor(Math.random() * width);
-                    var y = Math.floor(Math.random() * height);
-                    var el = document.getElementById("float" + x + "_" + y);
-                    el.className = toggle(el.className, "float", "float big");
-                    updateTimer();
-                }
-                setInterval(update, 0);
-            }
-        </script>
-    </head>
-    <body>
-        <div id="framerate_panel">Framerate: <span id="fps">calculating...</span> fps</div>
-        <div id="test_panel">
-            <p>Choose the size of the test:</p>
-            <button onclick="test(2, 100)">2 by 100</button>
-            <button onclick="test(20, 100)">20 by 100</button>
-            <button onclick="test(50, 100)">50 by 100</button>
-            <button onclick="test(100, 100)">100 by 100</button>
-            <p>Nested divs:</p>
-            <button onclick="test(2, 100, 100)">2 by 100, 100 nested</button>
-            <button onclick="test(20, 100, 100)">20 by 100, 100 nested</button>
-            <button onclick="test(50, 100, 100)">50 by 100, 100 nested</button>
-            <button onclick="test(100, 100, 100)">100 by 100, 100 nested</button>
-        </div>
-    </body>
-</html>
\ No newline at end of file
diff --git a/PerformanceTests/Layout/floats_100_100.html b/PerformanceTests/Layout/floats_100_100.html
new file mode 100644 (file)
index 0000000..a0f5970
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Floats layout performance tester with 2 columns and 100 rows</title>
+        <link rel="stylesheet" href="resources/floats.css" TYPE="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/floats.js"></script>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            PerfTestRunner.run(createFloatsLayoutTestFunction(100, 100, 0, 3), 1, 2);
+        </script>
+    </body>
+</html>
diff --git a/PerformanceTests/Layout/floats_100_100_nested.html b/PerformanceTests/Layout/floats_100_100_nested.html
new file mode 100644 (file)
index 0000000..09afd0e
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Floats layout performance tester with 2 columns and 100 rows</title>
+        <link rel="stylesheet" href="resources/floats.css" TYPE="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/floats.js"></script>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            PerfTestRunner.run(createFloatsLayoutTestFunction(100, 100, 100, 3), 1, 2);
+        </script>
+    </body>
+</html>
diff --git a/PerformanceTests/Layout/floats_20_100.html b/PerformanceTests/Layout/floats_20_100.html
new file mode 100644 (file)
index 0000000..a286be5
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Floats layout performance tester with 2 columns and 100 rows</title>
+        <link rel="stylesheet" href="resources/floats.css" TYPE="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/floats.js"></script>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            PerfTestRunner.run(createFloatsLayoutTestFunction(20, 100, 0, 100), 1, 7);
+        </script>
+    </body>
+</html>
diff --git a/PerformanceTests/Layout/floats_20_100_nested.html b/PerformanceTests/Layout/floats_20_100_nested.html
new file mode 100644 (file)
index 0000000..eb9aefe
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Floats layout performance tester with 2 columns and 100 rows</title>
+        <link rel="stylesheet" href="resources/floats.css" TYPE="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/floats.js"></script>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            PerfTestRunner.run(createFloatsLayoutTestFunction(20, 100, 100, 100), 1, 6);
+        </script>
+    </body>
+</html>
diff --git a/PerformanceTests/Layout/floats_2_100.html b/PerformanceTests/Layout/floats_2_100.html
new file mode 100644 (file)
index 0000000..5a69b60
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Floats layout performance tester with 2 columns and 100 rows</title>
+        <link rel="stylesheet" href="resources/floats.css" TYPE="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/floats.js"></script>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            PerfTestRunner.run(createFloatsLayoutTestFunction(2, 100, 0, 500), 1, 10);
+        </script>
+    </body>
+</html>
diff --git a/PerformanceTests/Layout/floats_2_100_nested.html b/PerformanceTests/Layout/floats_2_100_nested.html
new file mode 100644 (file)
index 0000000..abcd65e
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Floats layout performance tester with 2 columns and 100 rows</title>
+        <link rel="stylesheet" href="resources/floats.css" TYPE="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/floats.js"></script>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            PerfTestRunner.run(createFloatsLayoutTestFunction(2, 100, 100, 250), 1, 10);
+        </script>
+    </body>
+</html>
diff --git a/PerformanceTests/Layout/floats_50_100.html b/PerformanceTests/Layout/floats_50_100.html
new file mode 100644 (file)
index 0000000..6a50fb6
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Floats layout performance tester with 2 columns and 100 rows</title>
+        <link rel="stylesheet" href="resources/floats.css" TYPE="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/floats.js"></script>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            PerfTestRunner.run(createFloatsLayoutTestFunction(50, 100, 0, 20), 1, 5);
+        </script>
+    </body>
+</html>
diff --git a/PerformanceTests/Layout/floats_50_100_nested.html b/PerformanceTests/Layout/floats_50_100_nested.html
new file mode 100644 (file)
index 0000000..10956cf
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Floats layout performance tester with 2 columns and 100 rows</title>
+        <link rel="stylesheet" href="resources/floats.css" TYPE="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/floats.js"></script>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            PerfTestRunner.run(createFloatsLayoutTestFunction(50, 100, 100, 20), 1, 5);
+        </script>
+    </body>
+</html>
diff --git a/PerformanceTests/Layout/resources/floats.css b/PerformanceTests/Layout/resources/floats.css
new file mode 100644 (file)
index 0000000..a093426
--- /dev/null
@@ -0,0 +1,18 @@
+.container {
+    display: none;
+}
+
+.float {
+    float: left;
+    width: 5px;
+    height: 5px;
+    border: 1px solid green;
+}
+
+.big {
+    width: 10px;
+}
+
+.float-end {
+    clear:left;
+}
\ No newline at end of file
diff --git a/PerformanceTests/Layout/resources/floats.js b/PerformanceTests/Layout/resources/floats.js
new file mode 100644 (file)
index 0000000..459c2f4
--- /dev/null
@@ -0,0 +1,57 @@
+(function() {
+    function createElement(tag, parent, className, id) {
+        var el = document.createElement(tag);
+        el.className = className;
+        if (id)
+            el.id = id;
+        parent.appendChild(el);
+        return el;
+    }
+
+    function createSet(width, height, nested) {
+        var container = createElement("div", document.body, "container");
+        for (var y = 0; y < height; ++y) {
+            for (var x = 0; x < width; ++x)
+                createElement("div", container, "float", "float" + x + "_" + y);
+
+            var nestedContainer = container;
+            for ( ; nested > 0; --nested)
+                nestedContainer = createElement("div", nestedContainer, "nested", "nested" + x + "_" + nested);
+            
+            createElement("div", container, "float-end", "end" + x)
+        }
+        return container;
+    }
+
+    function toggle(str, str1, str2) {
+        return str == str1 ? str2 : str1;
+    }
+    
+    function resetTest() {
+        PerfTestRunner.resetRandomSeed();
+        var list = document.querySelectorAll(".float.big");
+        for (var i = 0; i < list.length; ++i)
+            list[i].className = "float";
+    }
+    
+    function createTestFunction(width, height, nested, runs) {
+        var container = createSet(width, height, nested);
+        nested = nested || 0;
+        runs = runs || 10;
+        return function() {
+            container.style.display = "block";
+            for (var i = 0; i < runs; ++i) {
+                var x = Math.floor(Math.random() * width);
+                var y = Math.floor(Math.random() * height);
+                var el = document.getElementById("float" + x + "_" + y);
+                el.className = toggle(el.className, "float", "float big");
+                // Force a layout.
+                container.clientHeight;
+            }
+            resetTest();
+            container.style.display = "none";
+        }
+    }
+    
+    window.createFloatsLayoutTestFunction = createTestFunction;
+})();
index 3b48a08..08ad7e6 100644 (file)
@@ -2,7 +2,6 @@
 Mutation
 
 # Do not conform to WebKit or Chromium perf test styles
-Layout
 PageLoad
 SunSpider
 XSSAuditor
index f7b1473..9a7d9ad 100644 (file)
@@ -1,6 +1,27 @@
 
 var PerfTestRunner = {};
 
+// To make the benchmark results predictable, we replace Math.random with a
+// 100% deterministic alternative.
+PerfTestRunner.randomSeed = PerfTestRunner.initialRandomSeed = 49734321;
+
+PerfTestRunner.resetRandomSeed = function() {
+    PerfTestRunner.randomSeed = PerfTestRunner.initialRandomSeed
+}
+
+PerfTestRunner.random = Math.random = function() {
+    // Robert Jenkins' 32 bit integer hash function.
+    var randomSeed = PerfTestRunner.randomSeed;
+    randomSeed = ((randomSeed + 0x7ed55d16) + (randomSeed << 12))  & 0xffffffff;
+    randomSeed = ((randomSeed ^ 0xc761c23c) ^ (randomSeed >>> 19)) & 0xffffffff;
+    randomSeed = ((randomSeed + 0x165667b1) + (randomSeed << 5))   & 0xffffffff;
+    randomSeed = ((randomSeed + 0xd3a2646c) ^ (randomSeed << 9))   & 0xffffffff;
+    randomSeed = ((randomSeed + 0xfd7046c5) + (randomSeed << 3))   & 0xffffffff;
+    randomSeed = ((randomSeed ^ 0xb55a4f09) ^ (randomSeed >>> 16)) & 0xffffffff;
+    PerfTestRunner.randomSeed = randomSeed;
+    return (randomSeed & 0xfffffff) / 0x10000000;
+};
+
 PerfTestRunner.log = function (text) {
     if (!document.getElementById("log")) {
         var pre = document.createElement('pre');