Skip to content

Commit f8d0a66

Browse files
authored
Add benchmark coverage for text-variable-anchor and symbol-sort-key (#9322)
* Add benchmarks for properties not used by default base map styles Add benchmark for properties such as and not currently being used by default mapbox base styles. #8589 * Fix lint
1 parent cb898bd commit f8d0a66

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

bench/benchmarks/layers.js

+59-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import style from '../data/empty.json';
55

66
const width = 1024;
77
const height = 768;
8+
const layerCount = 50;
89

910
function generateLayers(layer) {
1011
const generated = [];
11-
for (let i = 0; i < 50; i++) {
12+
for (let i = 0; i < layerCount; i++) {
1213
const id = layer.id + i;
1314
generated.push(Object.assign({}, layer, {id}));
1415
}
@@ -239,3 +240,60 @@ export class LayerSymbolWithIcons extends LayerBenchmark {
239240
});
240241
}
241242
}
243+
244+
export class LayerSymbolWithSortKey extends LayerBenchmark {
245+
constructor() {
246+
super();
247+
248+
this.layerStyle = Object.assign({}, style, {
249+
layers: this.generateSortKeyLayers()
250+
});
251+
}
252+
253+
generateSortKeyLayers() {
254+
const generated = [];
255+
for (let i = 0; i < layerCount; i++) {
256+
generated.push({
257+
'id': `symbollayer${i}`,
258+
'type': 'symbol',
259+
'source': 'composite',
260+
'source-layer': 'poi_label',
261+
'layout': {
262+
'symbol-sort-key': i,
263+
'text-field': '{name_en}'
264+
}
265+
});
266+
}
267+
return generated;
268+
}
269+
}
270+
271+
export class LayerTextWithVariableAnchor extends LayerBenchmark {
272+
constructor() {
273+
super();
274+
275+
this.layerStyle = Object.assign({}, style, {
276+
layers: generateLayers({
277+
'id': 'symbollayer',
278+
'type': 'symbol',
279+
'source': 'composite',
280+
'source-layer': 'poi_label',
281+
'layout': {
282+
'text-field': 'Test Test Test',
283+
'text-justify': 'auto',
284+
'text-variable-anchor': [
285+
'center',
286+
'top',
287+
'bottom',
288+
'left',
289+
'right',
290+
'top-left',
291+
'top-right',
292+
'bottom-left',
293+
'bottom-right'
294+
]
295+
}
296+
})
297+
});
298+
}
299+
}

bench/versions/benchmarks.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import WorkerTransfer from '../benchmarks/worker_transfer';
1010
import Paint from '../benchmarks/paint';
1111
import PaintStates from '../benchmarks/paint_states';
1212
import {PropertyLevelRemove, FeatureLevelRemove, SourceLevelRemove} from '../benchmarks/remove_paint_state';
13-
import {LayerBackground, LayerCircle, LayerFill, LayerFillExtrusion, LayerHeatmap, LayerHillshade, LayerLine, LayerRaster, LayerSymbol, LayerSymbolWithIcons} from '../benchmarks/layers';
13+
import {LayerBackground, LayerCircle, LayerFill, LayerFillExtrusion, LayerHeatmap, LayerHillshade, LayerLine, LayerRaster, LayerSymbol, LayerSymbolWithIcons, LayerTextWithVariableAnchor, LayerSymbolWithSortKey} from '../benchmarks/layers';
1414
import Load from '../benchmarks/map_load';
1515
import HillshadeLoad from '../benchmarks/hillshade_load';
1616
import Validate from '../benchmarks/style_validate';
@@ -67,6 +67,8 @@ register('LayerLine', new LayerLine());
6767
register('LayerRaster', new LayerRaster());
6868
register('LayerSymbol', new LayerSymbol());
6969
register('LayerSymbolWithIcons', new LayerSymbolWithIcons());
70+
register('LayerTextWithVariableAnchor', new LayerTextWithVariableAnchor());
71+
register('LayerSymbolWithSortKey', new LayerSymbolWithSortKey());
7072
register('Load', new Load());
7173
register('LayoutDDS', new LayoutDDS());
7274
register('SymbolLayout', new SymbolLayout(style, styleLocations.map(location => location.tileID[0])));

0 commit comments

Comments
 (0)