[MotionMark] Update Leaves test
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Aug 2018 23:02:07 +0000 (23:02 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Aug 2018 23:02:07 +0000 (23:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188530
<rdar://problem/43251862>

Reviewed by Said Abou-Hallawa.

Update Leaves test to include opacity and scale. Add new Leaves suite that isolate those components
for debugging purposes.

* MotionMark/resources/debug-runner/tests.js:
* MotionMark/tests/dom/leaves.html:
* MotionMark/tests/dom/resources/leaves.js:
* MotionMark/tests/master/resources/leaves.js:

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

PerformanceTests/ChangeLog
PerformanceTests/MotionMark/resources/debug-runner/tests.js
PerformanceTests/MotionMark/tests/dom/leaves.html
PerformanceTests/MotionMark/tests/dom/resources/leaves.js
PerformanceTests/MotionMark/tests/master/resources/leaves.js

index b2d5ce9..c299a09 100644 (file)
@@ -1,3 +1,19 @@
+2018-08-13  Jon Lee  <jonlee@apple.com>
+
+        [MotionMark] Update Leaves test
+        https://bugs.webkit.org/show_bug.cgi?id=188530
+        <rdar://problem/43251862>
+
+        Reviewed by Said Abou-Hallawa.
+
+        Update Leaves test to include opacity and scale. Add new Leaves suite that isolate those components
+        for debugging purposes.
+
+        * MotionMark/resources/debug-runner/tests.js:
+        * MotionMark/tests/dom/leaves.html:
+        * MotionMark/tests/dom/resources/leaves.js:
+        * MotionMark/tests/master/resources/leaves.js:
+
 2018-08-10  Ben Richards  <benton_richards@apple.com>
 
         Add ability to ignore process prewarming for launch time benchmark
index f178314..03b3626 100644 (file)
@@ -191,10 +191,6 @@ Suites.push(new Suite("HTML suite",
             name: "CSS bouncing tagged images"
         },
         {
-            url: "dom/leaves.html",
-            name: "Leaves 2.0"
-        },
-        {
             url: "dom/focus.html",
             name: "Focus 2.0"
         },
@@ -267,6 +263,23 @@ Suites.push(new Suite("SVG suite",
     ]
 ));
 
+Suites.push(new Suite("Leaves suite",
+    [
+        {
+            url: "dom/leaves.html?style=simple",
+            name: "Translate-only Leaves"
+        },
+        {
+            url: "dom/leaves.html?style=scale",
+            name: "Translate + Scale Leaves"
+        },
+        {
+            url: "dom/leaves.html?style=opacity",
+            name: "Translate + Opacity Leaves"
+        }
+    ]
+));
+
 Suites.push(new Suite("Text suite",
     [
         {
index 8dbefce..8dff64d 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-  Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+  Copyright (C) 2015-2018 Apple Inc. All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
@@ -29,7 +29,7 @@
     <link rel="stylesheet" type="text/css" href="../resources/stage.css">
     <style>
         #stage {
-            background-color: #23282B;
+            background-color: #33282B;
         }
         #stage img {
             position: absolute;
index 8c16dec..a0bb633 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
-Leaf = Utilities.createSubclass(Particle,
+(function() {
+
+var SuperLeaf = window.Leaf;
+var SimpleLeaf = Utilities.createSubclass(SuperLeaf,
     function(stage)
     {
-        this.element = document.createElement("img");
-        this.element.setAttribute("src", Stage.randomElementInArray(stage.images).src);
-        stage.element.appendChild(this.element);
+        SuperLeaf.call(this, stage);
+    }, {
+
+    sizeMinimum: 25,
+    sizeRange: 0,
+    usesOpacity: false,
+
+    move: function()
+    {
+        this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotater.rotateZ();
+    }
+});
 
-        Particle.call(this, stage);
+var ScaleLeaf = Utilities.createSubclass(SuperLeaf,
+    function(stage)
+    {
+        SuperLeaf.call(this, stage);
     }, {
 
     sizeMinimum: 20,
-    sizeRange: 40,
+    sizeRange: 30,
+    usesOpacity: false,
 
-    reset: function()
+    move: 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));
-    },
+        this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotater.rotateZ();
+    }
+});
 
-    animate: function(timeDelta)
+var OpacityLeaf = Utilities.createSubclass(SuperLeaf,
+    function(stage)
     {
-        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.height)
-            this.reset();
+        SuperLeaf.call(this, stage);
+    }, {
 
-        if (this._position.x < -this.size.width || this._position.x > this.stage.size.width)
-            this._position.x = this._position.x - Math.sign(this._position.x) * (this.size.width + this.stage.size.width);
-        this.move();
-    },
+    sizeMinimum: 25,
+    sizeRange: 0,
+    usesOpacity: true,
 
     move: function()
     {
@@ -70,3 +73,27 @@ Leaf = Utilities.createSubclass(Particle,
         this.element.style.opacity = this._opacity;
     }
 });
+
+
+var LeavesBenchmark = window.benchmarkClass;
+var LeavesDerivedBenchmark = Utilities.createSubclass(LeavesBenchmark,
+    function(options)
+    {
+        switch (options["style"]) {
+        case "simple":
+            window.Leaf = SimpleLeaf;
+            break;
+        case "scale":
+            window.Leaf = ScaleLeaf;
+            break;
+        case "opacity":
+            window.Leaf = OpacityLeaf;
+            break;
+        }
+        LeavesBenchmark.call(this, options);
+    }
+);
+
+window.benchmarkClass = LeavesDerivedBenchmark;
+
+})();
index fefda14..5317e50 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
-Leaf = Utilities.createSubclass(Particle,
+(function() {
+
+window.Leaf = Utilities.createSubclass(Particle,
     function(stage)
     {
         this.element = document.createElement("img");
         this.element.setAttribute("src", Stage.randomElementInArray(stage.images).src);
-        var sizeString = this.sizeMinimum + "px";
-        this.element.style.width = sizeString;
-        this.element.style.height = sizeString;
         stage.element.appendChild(this.element);
 
         Particle.call(this, stage);
     }, {
 
-    sizeMinimum: 25,
-    sizeRange: 0,
+    sizeMinimum: 20,
+    sizeRange: 30,
+    usesOpacity: true,
 
     reset: function()
     {
         Particle.prototype.reset.call(this);
-        this._life = Stage.randomInt(20, 100);
+        this.element.style.width = this.size.x + "px";
+        this.element.style.height = this.size.y + "px";
+
+        if (this.usesOpacity) {
+            this._opacity = .01;
+            this._opacityRate = 0.02 * Stage.random(1, 6);
+        } else
+            this._life = Stage.randomInt(20, 100);
+
         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));
     },
@@ -53,9 +61,18 @@ Leaf = Utilities.createSubclass(Particle,
         this._position.x += this._velocity.x + 8 * this.stage.focusX;
         this._position.y += this._velocity.y;
 
-        this._life--;
-        if (!this._life || this._position.y > this.stage.size.height)
-            this.reset();
+        if (this.usesOpacity) {
+            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.height)
+                this.reset();
+        } else {
+            this._life--;
+            if (!this._life || this._position.y > this.stage.size.height)
+                this.reset();
+        }
 
         if (this._position.x < -this.size.width || this._position.x > this.stage.size.width)
             this._position.x = this._position.x - Math.sign(this._position.x) * (this.size.width + this.stage.size.width);
@@ -65,6 +82,7 @@ Leaf = Utilities.createSubclass(Particle,
     move: function()
     {
         this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotater.rotateZ();
+        this.element.style.opacity = this._opacity;
     }
 });
 
@@ -143,7 +161,7 @@ Utilities.extendObject(ParticlesStage.prototype, {
     }
 });
 
-LeavesBenchmark = Utilities.createSubclass(Benchmark,
+var LeavesBenchmark = Utilities.createSubclass(Benchmark,
     function(options)
     {
         Benchmark.call(this, new ParticlesStage(), options);
@@ -157,3 +175,5 @@ LeavesBenchmark = Utilities.createSubclass(Benchmark,
 });
 
 window.benchmarkClass = LeavesBenchmark;
+
+})();