Title: [198315] trunk/PerformanceTests
Revision
198315
Author
[email protected]
Date
2016-03-16 19:49:16 -0700 (Wed, 16 Mar 2016)

Log Message

Add a new benchmark test
https://bugs.webkit.org/show_bug.cgi?id=155570

Reviewed by Simon Fraser.

New Leaves test includes various image sizes and opacity.

* Animometer/resources/debug-runner/tests.js: Add it to the HTML test suite.
* Animometer/tests/dom/leaves.html: Added.
* Animometer/tests/dom/resources/leaves.js: Added. Override the
(Particle.call.reset): Uses a range of sizes, and opacity.
(Particle.call.animate): Opacity goes up then down. When it hits 0, reset the particle.
(Particle.call.move): Set transform and opacity.
* Animometer/tests/master/resources/leaves.js: Get rid of the closure so that it
can be used in this test. Update the relative path so that it works in both the master
and dom test suite.

Modified Paths

Added Paths

Diff

Modified: trunk/PerformanceTests/Animometer/resources/debug-runner/tests.js (198314 => 198315)


--- trunk/PerformanceTests/Animometer/resources/debug-runner/tests.js	2016-03-17 02:18:04 UTC (rev 198314)
+++ trunk/PerformanceTests/Animometer/resources/debug-runner/tests.js	2016-03-17 02:49:16 UTC (rev 198315)
@@ -164,6 +164,10 @@
         {
             url: "bouncing-particles/bouncing-tagged-images.html?particleWidth=100&particleHeight=100",
             name: "CSS bouncing tagged images"
+        },
+        {
+            url: "dom/leaves.html",
+            name: "Leaves 2.0"
         }
     ]
 ));

Added: trunk/PerformanceTests/Animometer/tests/dom/leaves.html (0 => 198315)


--- trunk/PerformanceTests/Animometer/tests/dom/leaves.html	                        (rev 0)
+++ trunk/PerformanceTests/Animometer/tests/dom/leaves.html	2016-03-17 02:49:16 UTC (rev 198315)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <link rel="stylesheet" type="text/css" href=""
+    <style>
+        #stage {
+            background-color: #23282B;
+        }
+        #stage img {
+            position: absolute;
+        }
+    </style>
+</head>
+<body>
+    <div id="stage"></div>
+    <script src=""
+    <script src=""
+    <script src=""
+    <script src=""
+    <script src=""
+    <script src=""
+    <script src=""
+    <script src=""
+</body>
+</html>

Added: trunk/PerformanceTests/Animometer/tests/dom/resources/leaves.js (0 => 198315)


--- trunk/PerformanceTests/Animometer/tests/dom/resources/leaves.js	                        (rev 0)
+++ trunk/PerformanceTests/Animometer/tests/dom/resources/leaves.js	2016-03-17 02:49:16 UTC (rev 198315)
@@ -0,0 +1,48 @@
+Leaf = Utilities.createSubclass(Particle,
+    function(stage)
+    {
+        this.element = document.createElement("img");
+        this.element.setAttribute("src", stage.images[Stage.randomInt(0, stage.images.length - 1)].src);
+        stage.element.appendChild(this.element);
+
+        Particle.call(this, stage);
+    }, {
+
+    sizeMinimum: 20,
+    sizeRange: 40,
+
+    reset: function()
+    {
+        Particle.prototype.reset.call(this);
+        this.element.style.width = this.size.x + "px";
+        this.element.style.height = this.size.y + "px";
+        this._opacity = .01;
+        this._opacityRate = 0.02 * Stage.random(1, 6);
+        this._position = new Point(Stage.random(0, this.maxPosition.x), Stage.random(-this.size.height, this.maxPosition.y));
+        this._velocity = new Point(Stage.random(-6, -2), .1 * this.size.y + Stage.random(-1, 1));
+    },
+
+    animate: function(timeDelta)
+    {
+        this.rotater.next(timeDelta);
+
+        this._position.x += this._velocity.x + 8 * this.stage.focusX;
+        this._position.y += this._velocity.y;
+        this._opacity += this._opacityRate;
+        if (this._opacity > 1) {
+            this._opacity = 1;
+            this._opacityRate *= -1;
+        } else if (this._opacity < 0 || this._position.y > this.stage.size.y)
+            this.reset();
+
+        if (this._position.x < -this.size.width || this._position.x > this.maxPosition.x)
+            this._position.x = (this._position.x + this.maxPosition.x) % this.maxPosition.x;
+        this.move();
+    },
+
+    move: function()
+    {
+        this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotater.rotateZ();
+        this.element.style.opacity = this._opacity;
+    }
+});

Modified: trunk/PerformanceTests/Animometer/tests/master/resources/leaves.js (198314 => 198315)


--- trunk/PerformanceTests/Animometer/tests/master/resources/leaves.js	2016-03-17 02:18:04 UTC (rev 198314)
+++ trunk/PerformanceTests/Animometer/tests/master/resources/leaves.js	2016-03-17 02:49:16 UTC (rev 198315)
@@ -1,5 +1,3 @@
-(function() {
-
 Leaf = Utilities.createSubclass(Particle,
     function(stage)
     {
@@ -20,7 +18,7 @@
     {
         Particle.prototype.reset.call(this);
         this._life = Stage.randomInt(20, 100);
-        this._position = new Point(Stage.random(-this.size.width, this.maxPosition.x), Stage.random(-this.size.height, this.maxPosition.y));
+        this._position = new Point(Stage.random(0, this.maxPosition.x), Stage.random(-this.size.height, this.maxPosition.y));
         this._velocity = new Point(Stage.random(-6, -2), .1 * this.size.y + Stage.random(-1, 1));
     },
 
@@ -72,7 +70,7 @@
         var lastPromise;
         var images = this.images;
         this.imageSrcs.forEach(function(imageSrc) {
-            var promise = this._loadImage("resources/" + imageSrc + "100.png");
+            var promise = this._loadImage("../master/resources/" + imageSrc + "100.png");
             if (!lastPromise)
                 lastPromise = promise;
             else {
@@ -135,5 +133,3 @@
 });
 
 window.benchmarkClass = LeavesBenchmark;
-
-})();

Modified: trunk/PerformanceTests/ChangeLog (198314 => 198315)


--- trunk/PerformanceTests/ChangeLog	2016-03-17 02:18:04 UTC (rev 198314)
+++ trunk/PerformanceTests/ChangeLog	2016-03-17 02:49:16 UTC (rev 198315)
@@ -1,3 +1,22 @@
+2016-03-16  Jon Lee  <[email protected]>
+
+        Add a new benchmark test
+        https://bugs.webkit.org/show_bug.cgi?id=155570
+
+        Reviewed by Simon Fraser.
+
+        New Leaves test includes various image sizes and opacity.
+
+        * Animometer/resources/debug-runner/tests.js: Add it to the HTML test suite.
+        * Animometer/tests/dom/leaves.html: Added.
+        * Animometer/tests/dom/resources/leaves.js: Added. Override the
+        (Particle.call.reset): Uses a range of sizes, and opacity.
+        (Particle.call.animate): Opacity goes up then down. When it hits 0, reset the particle.
+        (Particle.call.move): Set transform and opacity.
+        * Animometer/tests/master/resources/leaves.js: Get rid of the closure so that it
+        can be used in this test. Update the relative path so that it works in both the master
+        and dom test suite.
+
 2016-03-15  Simon Fraser  <[email protected]>
 
         Add developer Animometer test that bounces P3-tagged images
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to