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
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;
}
BouncingCanvasParticlesBenchmark.prototype.createAnimator = function()
{
- return new BouncingCanvasParticlesAnimator(this);
+ return new BouncingCanvasParticlesAnimator(this, this._options);
}
\ No newline at end of file
}
}
-function BouncingParticlesAnimator(benchmark)
+function BouncingParticlesAnimator(benchmark, options)
{
- StageAnimator.call(this, benchmark);
+ StageAnimator.call(this, benchmark, options);
};
BouncingParticlesAnimator.prototype = Object.create(StageAnimator.prototype);
BouncingParticlesBenchmark.prototype.createAnimator = function()
{
- return new BouncingParticlesAnimator(this);
+ return new BouncingParticlesAnimator(this, this._options);
}
\ No newline at end of file
});
}
-function CanvasElectronsAnimator(benchmark)
+function CanvasElectronsAnimator(benchmark, options)
{
- Animator.call(this, benchmark);
+ Animator.call(this, benchmark, options);
this._context = benchmark._stage.context;
}
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)
});
}
-function CanvasStarsAnimator(benchmark)
+function CanvasStarsAnimator(benchmark, options)
{
- Animator.call(this, benchmark);
+ Animator.call(this, benchmark, options);
this._context = benchmark._stage.context;
}
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)
}
}
-function Animator(benchmark)
+function Animator(benchmark, options)
{
this._benchmark = benchmark;
+ this._options = options;
+
this._frameCount = 0;
this._dropFrameCount = 1;
this._measureFrameCount = 3;
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.
this._options = options;
this._method = this._options["method"] || "requestAnimationFrame";
- this.options = options;
this._recordInterval = 200;
this._isSampling = false;
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 =
}
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);
}
}
-function StageAnimator(benchmark)
+function StageAnimator(benchmark, options)
{
- Animator.call(this, benchmark);
+ Animator.call(this, benchmark, options);
};
StageAnimator.prototype = Object.create(Animator.prototype);
StageBenchmark.prototype.createAnimator = function()
{
- return new StageAnimator(this);
+ return new StageAnimator(this, this._options);
}
StageBenchmark.prototype.tune = function(count)
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);
});
}
-function SimpleCanvasAnimator(benchmark)
+function SimpleCanvasAnimator(benchmark, options)
{
- StageAnimator.call(this, benchmark);
+ StageAnimator.call(this, benchmark, options);
this._context = benchmark._stage.context;
}
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);
}
SimpleCanvasBenchmark.prototype = Object.create(StageBenchmark.prototype);
SimpleCanvasBenchmark.prototype.constructor = SimpleCanvasBenchmark;
SimpleCanvasBenchmark.prototype.createAnimator = function() {
- return new SimpleCanvasAnimator(this);
+ return new SimpleCanvasAnimator(this, this._options);
}
// 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;
}
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)
+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