Simplify the test harness
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Jan 2016 23:05:41 +0000 (23:05 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Jan 2016 23:05:41 +0000 (23:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152562

Reviewed by Simon Fraser.

Update the simple canvas tests. For the paths, start from the center instead of the
top-left corner. Instead of using a coordinate limit, use a canonized factor, and
use that along both the x and y axes, so that more capable tests use more of the
canvas.

* Animometer/tests/simple/resources/simple-canvas-paths.js:
(CanvasLinePoint): Rewrite to use the coordinate maximum factor.
(CanvasQuadraticPoint): Ditto.
(CanvasBezierPoint): Ditto.
* Animometer/tests/simple/resources/simple-canvas.js:
(tune): Calculate a factor instead of a maximum coordinate.

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

PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js
PerformanceTests/Animometer/tests/simple/resources/simple-canvas.js
PerformanceTests/ChangeLog

index a743a2b..f496e4e 100644 (file)
@@ -21,8 +21,9 @@ CanvasLineSegment.prototype.draw = function(context) {
     context.stroke();
 };
 
-function CanvasLinePoint(stage, coordinateMaximum) {
-    this._point = stage.randomPosition(new Point(Math.min(stage.size.x, coordinateMaximum), Math.min(stage.size.y, coordinateMaximum)));
+function CanvasLinePoint(stage, coordinateMaximumFactor) {
+    var pointMaximum = new Point(Math.min(stage.size.x, coordinateMaximumFactor * stage.size.x), Math.min(stage.size.y, coordinateMaximumFactor * stage.size.y));
+    this._point = stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2));
 }
 CanvasLinePoint.prototype.draw = function(context) {
     context.lineTo(this._point.x, this._point.y);
@@ -47,10 +48,10 @@ CanvasQuadraticSegment.prototype.draw = function(context) {
     context.stroke();
 };
 
-function CanvasQuadraticPoint(stage, coordinateMaximum) {
-    var pointMaximum = new Point(Math.min(stage.size.x, coordinateMaximum), Math.min(stage.size.y, coordinateMaximum));
-    this._point1 = stage.randomPosition(pointMaximum);
-    this._point2 = stage.randomPosition(pointMaximum);
+function CanvasQuadraticPoint(stage, coordinateMaximumFactor) {
+    var pointMaximum = stage.randomPosition(new Point(Math.min(stage.size.x, coordinateMaximumFactor * stage.size.x), Math.min(stage.size.y, coordinateMaximumFactor * stage.size.y)));
+    this._point1 = stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2));
+    this._point2 = stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2));
 };
 CanvasQuadraticPoint.prototype.draw = function(context) {
     context.quadraticCurveTo(this._point1.x, this._point1.y, this._point2.x, this._point2.y);
@@ -76,11 +77,11 @@ CanvasBezierSegment.prototype.draw = function(context) {
     context.stroke();
 };
 
-function CanvasBezierPoint(stage, coordinateMaximum) {
-    var pointMaximum = new Point(Math.min(stage.size.x, coordinateMaximum), Math.min(stage.size.y, coordinateMaximum));
-    this._point1 = stage.randomPosition(pointMaximum);
-    this._point2 = stage.randomPosition(pointMaximum);
-    this._point3 = stage.randomPosition(pointMaximum);
+function CanvasBezierPoint(stage, coordinateMaximumFactor) {
+    var pointMaximum = stage.randomPosition(new Point(Math.min(stage.size.x, coordinateMaximumFactor * stage.size.x), Math.min(stage.size.y, coordinateMaximumFactor * stage.size.y)));
+    this._point1 = stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2));
+    this._point2 = stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2));
+    this._point3 = stage.randomPosition(pointMaximum).add(new Point((stage.size.x - pointMaximum.x) / 2, (stage.size.y - pointMaximum.y) / 2));
 };
 CanvasBezierPoint.prototype.draw = function(context) {
     context.bezierCurveTo(this._point1.x, this._point1.y, this._point2.x, this._point2.y, this._point3.x, this._point3.y);
@@ -186,7 +187,7 @@ SimpleCanvasPathStrokeStage = Utilities.createSubclass(SimpleCanvasStage,
         context.lineWidth = this.randomInt(1, 20);
         context.strokeStyle = this.randomColor();
         context.beginPath();
-        context.moveTo(0,0);
+        context.moveTo(this.size.x / 2, this.size.y / 2);
         this.objects.forEach(function(object) {
             object.draw(context);
         });
@@ -205,7 +206,7 @@ SimpleCanvasPathFillStage = Utilities.createSubclass(SimpleCanvasStage,
         context.clearRect(0, 0, this.size.x, this.size.y);
         context.fillStyle = this.randomColor();
         context.beginPath();
-        context.moveTo(0,0);
+        context.moveTo(this.size.x / 2, this.size.y / 2);
         this.objects.forEach(function(object) {
             object.draw(context);
         });
@@ -260,7 +261,7 @@ CanvasLineDashStage = Utilities.createSubclass(SimpleCanvasStage,
         context.clearRect(0, 0, this.size.x, this.size.y);
         context.lineDashOffset = this._step++;
         context.beginPath();
-        context.moveTo(0,0);
+        context.moveTo(this.size.x / 2, this.size.y / 2);
         this.objects.forEach(function(object) {
             object.draw(context);
         });
index 14a4454..33cf6f0 100644 (file)
@@ -5,11 +5,11 @@ Utilities.extendObject(SimpleCanvasStage.prototype, {
             return this.objects.length;
 
         if (count > 0) {
-            // For path-based tests, use the object length as a maximum coordinate value
-            // to make it easier to see what the test is doing
-            var coordinateMaximum = Math.max(this.objects.length, 200);
+            // For some tests, it may be easier to see how well the test is going
+            // by limiting the range of coordinates in which new objects can reside
+            var coordinateMaximumFactor = Math.min(this.objects.length, Math.min(this.size.x, this.size.y)) / Math.min(this.size.x, this.size.y);
             for (var i = 0; i < count; ++i)
-                this.objects.push(new this._canvasObject(this, coordinateMaximum));
+                this.objects.push(new this._canvasObject(this, coordinateMaximumFactor));
             return this.objects.length;
         }
 
index da7e86f..9c8f5dd 100644 (file)
@@ -5,6 +5,25 @@
 
         Reviewed by Simon Fraser.
 
+        Update the simple canvas tests. For the paths, start from the center instead of the
+        top-left corner. Instead of using a coordinate limit, use a canonized factor, and
+        use that along both the x and y axes, so that more capable tests use more of the
+        canvas.
+
+        * Animometer/tests/simple/resources/simple-canvas-paths.js:
+        (CanvasLinePoint): Rewrite to use the coordinate maximum factor.
+        (CanvasQuadraticPoint): Ditto.
+        (CanvasBezierPoint): Ditto.
+        * Animometer/tests/simple/resources/simple-canvas.js:
+        (tune): Calculate a factor instead of a maximum coordinate.
+
+2015-12-27  Jon Lee  <jonlee@apple.com>
+
+        Simplify the test harness
+        https://bugs.webkit.org/show_bug.cgi?id=152562
+
+        Reviewed by Simon Fraser.
+
         All of the benchmarks use the default Animator(). Don't require new tests
         to pass a new instance, and instead just make one in the Benchmark constructor.