Skip to content

Commit de7f77d

Browse files
authored
Fix and refactor the benchmark suite (mapbox#8066)
* pin react-dom to 16.3.2 to fix benchmarks build * fix benchmarks builds accidentally switching to dev mode * remove broken share button from benchmarks * make benchmarks production-built for real this time; make source maps external * update gl and rollup w/ plugins to hopefully fix build * simplify benchmark build configs * move Axis to benchmarks_view * shuffle things around in benchmarks code * revert some breaking stuff * disable minifying bench for now * re-enable bench minification; explicitly name benchmarks * cut out UI logic from benchmark builds, reintroduce benchmarks_view * centralize benchmarks rollup configs * fix lint * fix typo * add forgotted watch flag
1 parent 0b1e151 commit de7f77d

20 files changed

+420
-508
lines changed

.circleci/config.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,11 @@ jobs:
200200
name: Build
201201
command: BENCHMARK_VERSION="${CIRCLE_TAG:-$CIRCLE_BRANCH} $(git rev-parse --short=7 HEAD)" yarn run build-benchmarks
202202
- run:
203-
name: Upload
203+
name: Upload benchmark
204204
command: aws s3 cp --acl public-read --content-type application/javascript bench/versions/benchmarks_generated.js s3://mapbox-gl-js/${CIRCLE_TAG:-$CIRCLE_BRANCH}/benchmarks.js
205+
- run:
206+
name: Upload source maps
207+
command: aws s3 cp --acl public-read --content-type application/javascript bench/versions/benchmarks_generated.js.map s3://mapbox-gl-js/${CIRCLE_TAG:-$CIRCLE_BRANCH}/benchmarks.js.map
205208

206209
deploy-release:
207210
<<: *defaults

.gitignore

+2-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ coverage
1111
flow-coverage
1212
.DS_Store
1313
.nyc_output
14-
bench/versions/benchmarks_generated.js
15-
bench/versions/benchmarks_view_generated.js
16-
bench/styles/benchmarks_generated.js
17-
bench/styles/benchmarks_view_generated.js
18-
debug/access_token_generated.js
19-
debug/style_property_editor_generated.js
14+
*_generated.js
15+
*_generated.js.map
2016
test/integration/**/index*.html
2117
test/integration/**/actual.png
2218
test/integration/**/actual.json

bench/benchmarks/expressions.js

+5-13
Original file line numberDiff line numberDiff line change
@@ -71,50 +71,42 @@ class ExpressionBenchmark extends Benchmark {
7171
}
7272
}
7373

74-
class FunctionCreate extends ExpressionBenchmark {
74+
export class FunctionCreate extends ExpressionBenchmark {
7575
bench() {
7676
for (const {rawValue, propertySpec} of this.data) {
7777
createFunction(rawValue, propertySpec);
7878
}
7979
}
8080
}
8181

82-
class FunctionEvaluate extends ExpressionBenchmark {
82+
export class FunctionEvaluate extends ExpressionBenchmark {
8383
bench() {
8484
for (const {compiledFunction} of this.data) {
8585
compiledFunction.evaluate({zoom: 0});
8686
}
8787
}
8888
}
8989

90-
class FunctionConvert extends ExpressionBenchmark {
90+
export class FunctionConvert extends ExpressionBenchmark {
9191
bench() {
9292
for (const {rawValue, propertySpec} of this.data) {
9393
convertFunction(rawValue, propertySpec);
9494
}
9595
}
9696
}
9797

98-
class ExpressionCreate extends ExpressionBenchmark {
98+
export class ExpressionCreate extends ExpressionBenchmark {
9999
bench() {
100100
for (const {rawExpression, propertySpec} of this.data) {
101101
createPropertyExpression(rawExpression, propertySpec);
102102
}
103103
}
104104
}
105105

106-
class ExpressionEvaluate extends ExpressionBenchmark {
106+
export class ExpressionEvaluate extends ExpressionBenchmark {
107107
bench() {
108108
for (const {compiledExpression} of this.data) {
109109
compiledExpression.evaluate({zoom: 0});
110110
}
111111
}
112112
}
113-
114-
export default [
115-
FunctionCreate,
116-
FunctionConvert,
117-
FunctionEvaluate,
118-
ExpressionCreate,
119-
ExpressionEvaluate
120-
];

bench/benchmarks/layers.js

+10-23
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function generateLayers(layer) {
1515
return generated;
1616
}
1717

18-
class LayerBenchmark extends Benchmark {
18+
export class LayerBenchmark extends Benchmark {
1919
setup() {
2020
return createMap({
2121
zoom: 16,
@@ -37,7 +37,7 @@ class LayerBenchmark extends Benchmark {
3737
}
3838
}
3939

40-
class LayerBackground extends LayerBenchmark {
40+
export class LayerBackground extends LayerBenchmark {
4141
constructor() {
4242
super();
4343

@@ -50,7 +50,7 @@ class LayerBackground extends LayerBenchmark {
5050
}
5151
}
5252

53-
class LayerCircle extends LayerBenchmark {
53+
export class LayerCircle extends LayerBenchmark {
5454
constructor() {
5555
super();
5656

@@ -65,7 +65,7 @@ class LayerCircle extends LayerBenchmark {
6565
}
6666
}
6767

68-
class LayerFill extends LayerBenchmark {
68+
export class LayerFill extends LayerBenchmark {
6969
constructor() {
7070
super();
7171

@@ -84,7 +84,7 @@ class LayerFill extends LayerBenchmark {
8484
}
8585
}
8686

87-
class LayerFillExtrusion extends LayerBenchmark {
87+
export class LayerFillExtrusion extends LayerBenchmark {
8888
constructor() {
8989
super();
9090

@@ -102,7 +102,7 @@ class LayerFillExtrusion extends LayerBenchmark {
102102
}
103103
}
104104

105-
class LayerHeatmap extends LayerBenchmark {
105+
export class LayerHeatmap extends LayerBenchmark {
106106
setup() {
107107
return fetch('/bench/data/naturalearth-land.json')
108108
.then(response => response.json())
@@ -144,7 +144,7 @@ class LayerHeatmap extends LayerBenchmark {
144144
}
145145
}
146146

147-
class LayerHillshade extends LayerBenchmark {
147+
export class LayerHillshade extends LayerBenchmark {
148148
constructor() {
149149
super();
150150

@@ -164,7 +164,7 @@ class LayerHillshade extends LayerBenchmark {
164164
}
165165
}
166166

167-
class LayerLine extends LayerBenchmark {
167+
export class LayerLine extends LayerBenchmark {
168168
constructor() {
169169
super();
170170

@@ -179,7 +179,7 @@ class LayerLine extends LayerBenchmark {
179179
}
180180
}
181181

182-
class LayerRaster extends LayerBenchmark {
182+
export class LayerRaster extends LayerBenchmark {
183183
constructor() {
184184
super();
185185

@@ -200,7 +200,7 @@ class LayerRaster extends LayerBenchmark {
200200
}
201201
}
202202

203-
class LayerSymbol extends LayerBenchmark {
203+
export class LayerSymbol extends LayerBenchmark {
204204
constructor() {
205205
super();
206206

@@ -218,16 +218,3 @@ class LayerSymbol extends LayerBenchmark {
218218
});
219219
}
220220
}
221-
222-
223-
export default [
224-
LayerBackground,
225-
LayerCircle,
226-
LayerFill,
227-
LayerFillExtrusion,
228-
LayerHeatmap,
229-
LayerHillshade,
230-
LayerLine,
231-
LayerRaster,
232-
LayerSymbol
233-
];

bench/benchmarks/layout.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@ export default class Layout extends Benchmark {
1010
tiles: Array<{tileID: OverscaledTileID, buffer: ArrayBuffer}>;
1111
parser: TileParser;
1212
style: string | StyleSpecification;
13-
locations: Array<OverscaledTileID>;
13+
tileIDs: Array<OverscaledTileID>;
1414

15-
constructor(style: string | StyleSpecification, locations: ?Array<OverscaledTileID>) {
15+
constructor(style: string | StyleSpecification, tileIDs: ?Array<OverscaledTileID>) {
1616
super();
1717
this.style = style;
18-
this.locations = locations || this.tileIDs();
19-
}
20-
21-
tileIDs(): Array<OverscaledTileID> {
22-
return [
18+
this.tileIDs = tileIDs || [
2319
new OverscaledTileID(12, 0, 12, 655, 1583),
2420
new OverscaledTileID(8, 0, 8, 40, 98),
2521
new OverscaledTileID(4, 0, 4, 3, 6),
@@ -34,7 +30,7 @@ export default class Layout extends Benchmark {
3430
return this.parser.setup();
3531
})
3632
.then(() => {
37-
return Promise.all(this.locations.map(tileID => this.parser.fetchTile(tileID)));
33+
return Promise.all(this.tileIDs.map(tileID => this.parser.fetchTile(tileID)));
3834
})
3935
.then((tiles) => {
4036
this.tiles = tiles;

bench/benchmarks/remove_paint_state.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class RemovePaintState extends Benchmark {
6868
}
6969
}
7070

71-
class PropertyLevelRemove extends RemovePaintState {
71+
export class PropertyLevelRemove extends RemovePaintState {
7272
bench() {
7373

7474
for (let i = 0; i < this.numFeatures; i += 50) {
@@ -82,7 +82,7 @@ class PropertyLevelRemove extends RemovePaintState {
8282
}
8383
}
8484

85-
class FeatureLevelRemove extends RemovePaintState {
85+
export class FeatureLevelRemove extends RemovePaintState {
8686
bench() {
8787

8888
for (let i = 0; i < this.numFeatures; i += 50) {
@@ -96,7 +96,7 @@ class FeatureLevelRemove extends RemovePaintState {
9696
}
9797
}
9898

99-
class SourceLevelRemove extends RemovePaintState {
99+
export class SourceLevelRemove extends RemovePaintState {
100100
bench() {
101101

102102
for (let i = 0; i < this.numFeatures; i += 50) {
@@ -109,9 +109,3 @@ class SourceLevelRemove extends RemovePaintState {
109109

110110
}
111111
}
112-
113-
export default [
114-
PropertyLevelRemove,
115-
FeatureLevelRemove,
116-
SourceLevelRemove
117-
];

0 commit comments

Comments
 (0)