Add a new benchmark test
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Mar 2016 02:49:16 +0000 (02:49 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Mar 2016 02:49:16 +0000 (02:49 +0000)
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.

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

PerformanceTests/Animometer/resources/debug-runner/tests.js
PerformanceTests/Animometer/tests/dom/leaves.html [new file with mode: 0644]
PerformanceTests/Animometer/tests/dom/resources/leaves.js [new file with mode: 0644]
PerformanceTests/Animometer/tests/master/resources/leaves.js
PerformanceTests/ChangeLog

index 859c32deb2bb4ee1e4dd53c3d7b6cf08957524b4..0dcd4c246d7b7c915afb829bd763fc09dc8e18a0 100644 (file)
@@ -164,6 +164,10 @@ Suites.push(new Suite("HTML suite",
         {
             url: "bouncing-particles/bouncing-tagged-images.html?particleWidth=100&particleHeight=100",
             name: "CSS bouncing tagged images"
+        },
+        {
+            url: "dom/leaves.html",
+            name: "Leaves 2.0"
         }
     ]
 ));
diff --git a/PerformanceTests/Animometer/tests/dom/leaves.html b/PerformanceTests/Animometer/tests/dom/leaves.html
new file mode 100644 (file)
index 0000000..625882e
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <link rel="stylesheet" type="text/css" href="../resources/stage.css">
+    <style>
+        #stage {
+            background-color: #23282B;
+        }
+        #stage img {
+            position: absolute;
+        }
+    </style>
+</head>
+<body>
+    <div id="stage"></div>
+    <script src="../../resources/strings.js"></script>
+    <script src="../../resources/extensions.js"></script>
+    <script src="../../resources/statistics.js"></script>
+    <script src="../resources/math.js"></script>
+    <script src="../resources/main.js"></script>
+    <script src="../master/resources/particles.js"></script>
+    <script src="../master/resources/leaves.js"></script>
+    <script src="resources/leaves.js"></script>
+</body>
+</html>
diff --git a/PerformanceTests/Animometer/tests/dom/resources/leaves.js b/PerformanceTests/Animometer/tests/dom/resources/leaves.js
new file mode 100644 (file)
index 0000000..7b0778e
--- /dev/null
@@ -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;
+    }
+});
index 52d481171a8f3018a9ea6f2cba5d459d09e00a5e..9101b75a272fd7f0d48f1214afff0632613f8ea4 100644 (file)
@@ -1,5 +1,3 @@
-(function() {
-
 Leaf = Utilities.createSubclass(Particle,
     function(stage)
     {
@@ -20,7 +18,7 @@ Leaf = Utilities.createSubclass(Particle,
     {
         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 @@ Utilities.extendObject(ParticlesStage.prototype, {
         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 @@ LeavesBenchmark = Utilities.createSubclass(Benchmark,
 });
 
 window.benchmarkClass = LeavesBenchmark;
-
-})();
index eee4f44b09d2b74452f6cbbea3b9412f2ebd3fff..e3481ca8838457e28289eca96d1ad1a49c933eff 100644 (file)
@@ -1,3 +1,22 @@
+2016-03-16  Jon Lee  <jonlee@apple.com>
+
+        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  <simon.fraser@apple.com>
 
         Add developer Animometer test that bounces P3-tagged images