Clean referencing the options object in the graphics benchmark
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Nov 2015 23:22:16 +0000 (23:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Nov 2015 23:22:16 +0000 (23:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151284

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-11-16
Reviewed by Simon Fraser.

Get rid of the Benchmark.options member and rely only on the private member
Benchmark._options. The animator need to have its own options member instead
of accessing it from its reference to Benchmark object.

* Animometer/tests/bouncing-particles/resources/bouncing-canvas-particles.js:
(BouncingCanvasParticlesAnimator):
(BouncingCanvasParticlesBenchmark.prototype.createAnimator):
* Animometer/tests/bouncing-particles/resources/bouncing-particles.js:
(BouncingParticle.prototype.animate):
(BouncingParticlesAnimator):
(BouncingParticlesBenchmark.prototype.createAnimator):
* Animometer/tests/examples/resources/canvas-electrons.js:
(CanvasElectronsStage.prototype.animate):
(CanvasElectronsAnimator):
(CanvasElectronsBenchmark.prototype.createAnimator):
(window.benchmarkClient.create):
* Animometer/tests/examples/resources/canvas-stars.js:
(CanvasStarsStage.prototype.animate):
(CanvasStarsAnimator):
(CanvasStarsBenchmark.prototype.createAnimator):
(window.benchmarkClient.create):
* Animometer/tests/resources/main.js:
(BenchmarkState.prototype.currentProgress):
(Animator):
(Animator.prototype.animate):
(Benchmark):
(Benchmark.prototype.update):
* Animometer/tests/resources/stage.js:
(Stage.prototype.clear):
(StageAnimator):
(StageBenchmark.prototype.createAnimator):
(StageBenchmark.prototype.tune):
(StageBenchmark.prototype.showResults):
* Animometer/tests/simple/resources/simple-canvas.js:
(SimpleCanvasStage.prototype.animate):
(SimpleCanvasAnimator):
(SimpleCanvasAnimator.prototype.animate):
(SimpleCanvasBenchmark.prototype.createAnimator):
* Animometer/tests/template/resources/template-canvas.js:
(TemplateCanvasStage.prototype.animate):
(TemplateCanvasBenchmark.prototype.createAnimator):
(window.benchmarkClient.create):

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

PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-canvas-particles.js
PerformanceTests/Animometer/tests/bouncing-particles/resources/bouncing-particles.js
PerformanceTests/Animometer/tests/examples/resources/canvas-electrons.js
PerformanceTests/Animometer/tests/examples/resources/canvas-stars.js
PerformanceTests/Animometer/tests/resources/main.js
PerformanceTests/Animometer/tests/resources/stage.js
PerformanceTests/Animometer/tests/simple/resources/simple-canvas.js
PerformanceTests/Animometer/tests/template/resources/template-canvas.js
PerformanceTests/ChangeLog

index 63ad59b..4cf7cd5 100644 (file)
@@ -76,9 +76,9 @@ function BouncingCanvasParticlesStage(element, options)
 BouncingCanvasParticlesStage.prototype = Object.create(BouncingParticlesStage.prototype);
 BouncingCanvasParticlesStage.prototype.constructor = BouncingCanvasParticlesStage;
 
-function BouncingCanvasParticlesAnimator(benchmark)
+function BouncingCanvasParticlesAnimator(benchmark, options)
 {
-    BouncingParticlesAnimator.call(this, benchmark);
+    BouncingParticlesAnimator.call(this, benchmark, options);
     this._context = benchmark._stage.context;
 }
 
@@ -101,5 +101,5 @@ BouncingCanvasParticlesBenchmark.prototype.constructor = BouncingCanvasParticles
 
 BouncingCanvasParticlesBenchmark.prototype.createAnimator = function()
 {
-    return new BouncingCanvasParticlesAnimator(this);
+    return new BouncingCanvasParticlesAnimator(this, this._options);
 }
\ No newline at end of file
index 25c5700..e8500f3 100644 (file)
@@ -57,9 +57,9 @@ BouncingParticle.prototype =
     }
 }
 
-function BouncingParticlesAnimator(benchmark)
+function BouncingParticlesAnimator(benchmark, options)
 {
-    StageAnimator.call(this, benchmark);
+    StageAnimator.call(this, benchmark, options);
 };
 
 BouncingParticlesAnimator.prototype = Object.create(StageAnimator.prototype);
@@ -126,5 +126,5 @@ BouncingParticlesBenchmark.prototype.constructor = BouncingParticlesBenchmark;
 
 BouncingParticlesBenchmark.prototype.createAnimator = function()
 {
-    return new BouncingParticlesAnimator(this);
+    return new BouncingParticlesAnimator(this, this._options);
 }
\ No newline at end of file
index 11f8920..4e93204 100644 (file)
@@ -82,9 +82,9 @@ CanvasElectronsStage.prototype.animate = function(timeDelta)
     });
 }
 
-function CanvasElectronsAnimator(benchmark)
+function CanvasElectronsAnimator(benchmark, options)
 {
-    Animator.call(this, benchmark);
+    Animator.call(this, benchmark, options);
     this._context = benchmark._stage.context;
 }
 
@@ -121,7 +121,7 @@ CanvasElectronsBenchmark.prototype.createStage = function(element)
 CanvasElectronsBenchmark.prototype.createAnimator = function()
 {
     // Attach the animator to the benchmark.
-    return new CanvasElectronsAnimator(this);
+    return new CanvasElectronsAnimator(this, this._options);
 }
 
 window.benchmarkClient.create = function(suite, test, options, recordTable, progressBar)
index c9028d7..fbdbb4f 100644 (file)
@@ -83,9 +83,9 @@ CanvasStarsStage.prototype.animate = function(timeDelta)
     });
 }
 
-function CanvasStarsAnimator(benchmark)
+function CanvasStarsAnimator(benchmark, options)
 {
-   Animator.call(this, benchmark);
+   Animator.call(this, benchmark, options);
    this._context = benchmark._stage.context;
 }
 
@@ -118,7 +118,7 @@ CanvasStarsBenchmark.prototype.createStage = function(element)
 CanvasStarsBenchmark.prototype.createAnimator = function()
 {
    // Attach the animator to the benchmark.
-   return new CanvasStarsAnimator(this);
+   return new CanvasStarsAnimator(this, this._options);
 }
 
 window.benchmarkClient.create = function(suite, test, options, recordTable, progressBar)
index 7687334..ed99855 100644 (file)
@@ -59,9 +59,11 @@ BenchmarkState.prototype =
     }
 }
 
-function Animator(benchmark)
+function Animator(benchmark, options)
 {
     this._benchmark = benchmark;
+    this._options = options;
+    
     this._frameCount = 0;
     this._dropFrameCount = 1;
     this._measureFrameCount = 3; 
@@ -109,7 +111,7 @@ Animator.prototype =
         var currentFrameRate = Math.floor(1000 / (measureTimeDelta / this._measureFrameCount));
          
         // Use Kalman filter to get a more non-fluctuating frame rate.
-        if (this._benchmark.options["estimated-frame-rate"])
+        if (this._options["estimated-frame-rate"])
             currentFrameRate = this._estimator.estimate(currentFrameRate);
         
         // Adjust the test to reach the desired FPS.
@@ -138,7 +140,6 @@ function Benchmark(options)
     this._options = options;
     this._method = this._options["method"] || "requestAnimationFrame";
 
-    this.options = options;
     this._recordInterval = 200;    
     this._isSampling = false;
 
@@ -148,7 +149,7 @@ function Benchmark(options)
     
     this._controller = new PIDController(gain, options["frame-rate"], lowValue, highValue);
     this._sampler = new Sampler(2);
-    this._state = new BenchmarkState(this.options["test-interval"] * 1000);
+    this._state = new BenchmarkState(this._options["test-interval"] * 1000);
 }
 
 Benchmark.prototype =
@@ -179,11 +180,11 @@ Benchmark.prototype =
         }
 
         var tuneValue = 0;
-        if (this.options["complexity"] && !this.options["adaptive-test"]) {
+        if (this._options["complexity"] && !this._options["adaptive-test"]) {
             // this.tune(0) returns the current complexity of the test.
-            tuneValue = this.options["complexity"] - this.tune(0);
+            tuneValue = this._options["complexity"] - this.tune(0);
         }
-        else if (!(this._isSampling && this.options["fix-test-complexity"])) {
+        else if (!(this._isSampling && this._options["fix-test-complexity"])) {
             // The relationship between frameRate and test complexity is inverse-proportional so we
             // need to use the negative of PIDController.tune() to change the complexity of the test.
             tuneValue = -this._controller.tune(currentFrameRate, timeDelta / 1000);
index 08f39c9..35f8662 100644 (file)
@@ -112,9 +112,9 @@ Stage.prototype =
     }
 }
 
-function StageAnimator(benchmark)
+function StageAnimator(benchmark, options)
 {
-    Animator.call(this, benchmark);
+    Animator.call(this, benchmark, options);
 };
 
 StageAnimator.prototype = Object.create(Animator.prototype);
@@ -154,7 +154,7 @@ StageBenchmark.prototype.createStage = function(element)
 
 StageBenchmark.prototype.createAnimator = function()
 {
-    return new StageAnimator(this);
+    return new StageAnimator(this, this._options);
 }
 
 StageBenchmark.prototype.tune = function(count)
@@ -172,7 +172,7 @@ StageBenchmark.prototype.showResults = function(message, progress)
     if (!this._recordTable || !this._progressBar || !this._test)
         return;
 
-    if (this.options["show-running-results"])
+    if (this._options["show-running-results"])
         this._recordTable.showRecord(this._test.name, message, this._sampler.toJSON(true, false));
 
     this._progressBar.setPos(progress);
index d332815..adeef18 100644 (file)
@@ -36,9 +36,9 @@ SimpleCanvasStage.prototype.animate = function()
     });
 }
 
-function SimpleCanvasAnimator(benchmark)
+function SimpleCanvasAnimator(benchmark, options)
 {
-    StageAnimator.call(this, benchmark);
+    StageAnimator.call(this, benchmark, options);
     this._context = benchmark._stage.context;
 }
 
@@ -47,7 +47,7 @@ SimpleCanvasAnimator.prototype.constructor = SimpleCanvasAnimator;
 SimpleCanvasAnimator.prototype.animate = function()
 {
     this._context.clearRect(0, 0, this._benchmark._stage.size.x, this._benchmark._stage.size.y);
-    return StageAnimator.prototype.animate.call(this);
+    return StageAnimator.prototype.animate.call(this, this._options);
 }
 
 
@@ -60,6 +60,6 @@ function SimpleCanvasBenchmark(suite, test, options, recordTable, progressBar) {
 SimpleCanvasBenchmark.prototype = Object.create(StageBenchmark.prototype);
 SimpleCanvasBenchmark.prototype.constructor = SimpleCanvasBenchmark;
 SimpleCanvasBenchmark.prototype.createAnimator = function() {
-    return new SimpleCanvasAnimator(this);
+    return new SimpleCanvasAnimator(this, this._options);
 }
 
index 7ee006d..c6a600d 100644 (file)
@@ -57,9 +57,9 @@ TemplateCanvasStage.prototype.animate = function(timeDelta)
     // Loop through all your objects and ask them to animate.
 }
 
-function TemplateCanvasAnimator(benchmark)
+function TemplateCanvasAnimator(benchmark, options)
 {
-    Animator.call(this, benchmark);
+    Animator.call(this, benchmark, options);
     this._context = benchmark._stage.context;
 }
 
@@ -93,7 +93,7 @@ TemplateCanvasBenchmark.prototype.createStage = function(element)
 TemplateCanvasBenchmark.prototype.createAnimator = function()
 {
     // Attach the animator to the benchmark.
-    return new TemplateCanvasAnimator(this);
+    return new TemplateCanvasAnimator(this, this._options);
 }
 
 window.benchmarkClient.create = function(suite, test, options, recordTable, progressBar)
index 583419f..d017a57 100644 (file)
@@ -1,3 +1,53 @@
+2015-11-16  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Clean referencing the options object in the graphics benchmark
+        https://bugs.webkit.org/show_bug.cgi?id=151284
+
+        Reviewed by Simon Fraser.
+
+        Get rid of the Benchmark.options member and rely only on the private member
+        Benchmark._options. The animator need to have its own options member instead
+        of accessing it from its reference to Benchmark object.
+
+        * Animometer/tests/bouncing-particles/resources/bouncing-canvas-particles.js:
+        (BouncingCanvasParticlesAnimator):
+        (BouncingCanvasParticlesBenchmark.prototype.createAnimator):
+        * Animometer/tests/bouncing-particles/resources/bouncing-particles.js:
+        (BouncingParticle.prototype.animate):
+        (BouncingParticlesAnimator):
+        (BouncingParticlesBenchmark.prototype.createAnimator):
+        * Animometer/tests/examples/resources/canvas-electrons.js:
+        (CanvasElectronsStage.prototype.animate):
+        (CanvasElectronsAnimator):
+        (CanvasElectronsBenchmark.prototype.createAnimator):
+        (window.benchmarkClient.create):
+        * Animometer/tests/examples/resources/canvas-stars.js:
+        (CanvasStarsStage.prototype.animate):
+        (CanvasStarsAnimator):
+        (CanvasStarsBenchmark.prototype.createAnimator):
+        (window.benchmarkClient.create):
+        * Animometer/tests/resources/main.js:
+        (BenchmarkState.prototype.currentProgress):
+        (Animator):
+        (Animator.prototype.animate):
+        (Benchmark):
+        (Benchmark.prototype.update):
+        * Animometer/tests/resources/stage.js:
+        (Stage.prototype.clear):
+        (StageAnimator):
+        (StageBenchmark.prototype.createAnimator):
+        (StageBenchmark.prototype.tune):
+        (StageBenchmark.prototype.showResults):
+        * Animometer/tests/simple/resources/simple-canvas.js:
+        (SimpleCanvasStage.prototype.animate):
+        (SimpleCanvasAnimator):
+        (SimpleCanvasAnimator.prototype.animate):
+        (SimpleCanvasBenchmark.prototype.createAnimator):
+        * Animometer/tests/template/resources/template-canvas.js:
+        (TemplateCanvasStage.prototype.animate):
+        (TemplateCanvasBenchmark.prototype.createAnimator):
+        (window.benchmarkClient.create):
+
 2015-11-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Eliminate a request for layout every time an item is added to the stage of the graphics benchmark