Skip to content

Commit b22f857

Browse files
committed
Convert Benchmark to a JS class
1 parent 505bd52 commit b22f857

30 files changed

+154
-188
lines changed

MotionMark/tests/3d/resources/webgl.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ class WebGLStage extends Stage {
193193
}
194194
}
195195

196-
WebGLBenchmark = Utilities.createSubclass(Benchmark,
197-
function(options)
196+
class WebGLBenchmark extends Benchmark {
197+
constructor(options)
198198
{
199-
Benchmark.call(this, new WebGLStage(), options);
199+
super(new WebGLStage(), options);
200200
}
201-
);
201+
}
202202

203203
window.benchmarkClass = WebGLBenchmark;

MotionMark/tests/3d/resources/webgpu.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fragment float4 fragmentMain(float4 inColor : attribute(1)) : SV_Target 0 {
6565
}
6666
`;
6767

68-
class WebGLStage extends Stage
68+
class WebGLStage extends Stage {
6969
constructor(element, options)
7070
{
7171
super();
@@ -314,16 +314,17 @@ class WebGLStage extends Stage
314314
}
315315
}
316316

317-
WebGLBenchmark = Utilities.createSubclass(Benchmark,
318-
function(options)
317+
class WebGLBenchmark extends Benchmark {
318+
constructor(options)
319319
{
320-
Benchmark.call(this, new WebGLStage(), options);
321-
}, {
320+
super(new WebGLStage(), options);
321+
}
322322

323-
waitUntilReady: function() {
323+
waitUntilReady()
324+
{
324325
this._initPromise = new SimplePromise;
325326
return this._initPromise;
326-
},
327-
});
327+
}
328+
}
328329

329330
window.benchmarkClass = WebGLBenchmark;

MotionMark/tests/bouncing-particles/resources/bouncing-canvas-images.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ class BouncingCanvasImagesStage extends BouncingCanvasParticlesStage {
5858
}
5959
}
6060

61-
BouncingCanvasImagesBenchmark = Utilities.createSubclass(Benchmark,
62-
function(options)
61+
class BouncingCanvasImagesBenchmark extends Benchmark {
62+
constructor(options)
6363
{
64-
Benchmark.call(this, new BouncingCanvasImagesStage(), options);
64+
super(new BouncingCanvasImagesStage(), options);
6565
}
66-
);
66+
}
6767

6868
window.benchmarkClass = BouncingCanvasImagesBenchmark;

MotionMark/tests/bouncing-particles/resources/bouncing-canvas-shapes.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ class BouncingCanvasShapesStage extends BouncingCanvasParticlesStage {
9898
}
9999
}
100100

101-
BouncingCanvasShapesBenchmark = Utilities.createSubclass(Benchmark,
102-
function(options)
101+
class BouncingCanvasShapesBenchmark extends Benchmark {
102+
constructor(options)
103103
{
104-
Benchmark.call(this, new BouncingCanvasShapesStage(), options);
104+
super(new BouncingCanvasShapesStage(), options);
105105
}
106-
);
106+
}
107107

108108
window.benchmarkClass = BouncingCanvasShapesBenchmark;

MotionMark/tests/bouncing-particles/resources/bouncing-css-images.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ class BouncingCssImagesStage extends BouncingParticlesStage {
7272
}
7373
}
7474

75-
BouncingCssImagesBenchmark = Utilities.createSubclass(Benchmark,
76-
function(options)
75+
class BouncingCssImagesBenchmark extends Benchmark {
76+
constructor(options)
7777
{
78-
Benchmark.call(this, new BouncingCssImagesStage(), options);
78+
super(new BouncingCssImagesStage(), options);
7979
}
80-
);
80+
}
8181

8282
window.benchmarkClass = BouncingCssImagesBenchmark;

MotionMark/tests/bouncing-particles/resources/bouncing-css-shapes.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015-2017 Apple Inc. All rights reserved.
2+
* Copyright (C) 2015-2024 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -22,7 +22,6 @@
2222
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2323
* THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
25-
(function() {
2625

2726
BouncingCssShape = Utilities.createSubclass(BouncingParticle,
2827
function(stage)
@@ -98,13 +97,11 @@ class BouncingCssShapesStage extends BouncingParticlesStage {
9897
}
9998
}
10099

101-
BouncingCssShapesBenchmark = Utilities.createSubclass(Benchmark,
102-
function(options)
100+
class BouncingCssShapesBenchmark extends Benchmark {
101+
constructor(options)
103102
{
104-
Benchmark.call(this, new BouncingCssShapesStage(), options);
103+
super(new BouncingCssShapesStage(), options);
105104
}
106-
);
105+
}
107106

108107
window.benchmarkClass = BouncingCssShapesBenchmark;
109-
110-
})();

MotionMark/tests/bouncing-particles/resources/bouncing-svg-images.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ class BouncingSvgImagesStage extends BouncingSvgParticlesStage {
5353
}
5454
}
5555

56-
BouncingSvgImagesBenchmark = Utilities.createSubclass(Benchmark,
57-
function(options)
56+
class BouncingSvgImagesBenchmark extends Benchmark {
57+
constructor(options)
5858
{
59-
Benchmark.call(this, new BouncingSvgImagesStage(), options);
59+
super(new BouncingSvgImagesStage(), options);
6060
}
61-
);
61+
}
6262

6363
window.benchmarkClass = BouncingSvgImagesBenchmark;

MotionMark/tests/bouncing-particles/resources/bouncing-svg-shapes.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ class BouncingSvgShapesStage extends BouncingSvgParticlesStage {
112112
}
113113
}
114114

115-
BouncingSvgShapesBenchmark = Utilities.createSubclass(Benchmark,
116-
function(options)
115+
class BouncingSvgShapesBenchmark extends Benchmark {
116+
constructor(options)
117117
{
118-
Benchmark.call(this, new BouncingSvgShapesStage(), options);
118+
super(new BouncingSvgShapesStage(), options);
119119
}
120-
);
120+
}
121121

122122
window.benchmarkClass = BouncingSvgShapesBenchmark;

MotionMark/tests/bouncing-particles/resources/bouncing-tagged-images.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,17 @@ class BouncingTaggedImagesStage extends BouncingParticlesStage {
112112
}
113113
}
114114

115-
BouncingTaggedImagesBenchmark = Utilities.createSubclass(Benchmark,
116-
function(options)
115+
class BouncingTaggedImagesBenchmark extends Benchmark {
116+
constructor(options)
117117
{
118-
Benchmark.call(this, new BouncingTaggedImagesStage(), options);
119-
}, {
118+
super(new BouncingTaggedImagesStage(), options);
119+
}
120120

121-
waitUntilReady: function() {
121+
waitUntilReady()
122+
{
122123
this.readyPromise = new SimplePromise;
123124
return this.readyPromise;
124125
}
125-
});
126+
}
126127

127128
window.benchmarkClass = BouncingTaggedImagesBenchmark;

MotionMark/tests/core/resources/canvas-tests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ class CanvasLinePathStage extends SimpleCanvasStage {
310310

311311
// === BENCHMARK ===
312312

313-
CanvasPathBenchmark = Utilities.createSubclass(Benchmark,
314-
function(options)
313+
class CanvasPathBenchmark extends Benchmark {
314+
constructor(options)
315315
{
316316
var stage;
317317
switch (options["pathType"]) {
@@ -326,8 +326,8 @@ CanvasPathBenchmark = Utilities.createSubclass(Benchmark,
326326
break;
327327
}
328328

329-
Benchmark.call(this, stage, options);
329+
super(stage, options);
330330
}
331-
);
331+
}
332332

333333
window.benchmarkClass = CanvasPathBenchmark;

0 commit comments

Comments
 (0)