Skip to content

Commit

Permalink
Add benchmark coverage for text-variable-anchor and symbol-sort-key (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
karimnaaji authored Feb 24, 2020
1 parent cb898bd commit f8d0a66
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
60 changes: 59 additions & 1 deletion bench/benchmarks/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import style from '../data/empty.json';

const width = 1024;
const height = 768;
const layerCount = 50;

function generateLayers(layer) {
const generated = [];
for (let i = 0; i < 50; i++) {
for (let i = 0; i < layerCount; i++) {
const id = layer.id + i;
generated.push(Object.assign({}, layer, {id}));
}
Expand Down Expand Up @@ -239,3 +240,60 @@ export class LayerSymbolWithIcons extends LayerBenchmark {
});
}
}

export class LayerSymbolWithSortKey extends LayerBenchmark {
constructor() {
super();

this.layerStyle = Object.assign({}, style, {
layers: this.generateSortKeyLayers()
});
}

generateSortKeyLayers() {
const generated = [];
for (let i = 0; i < layerCount; i++) {
generated.push({
'id': `symbollayer${i}`,
'type': 'symbol',
'source': 'composite',
'source-layer': 'poi_label',
'layout': {
'symbol-sort-key': i,
'text-field': '{name_en}'
}
});
}
return generated;
}
}

export class LayerTextWithVariableAnchor extends LayerBenchmark {
constructor() {
super();

this.layerStyle = Object.assign({}, style, {
layers: generateLayers({
'id': 'symbollayer',
'type': 'symbol',
'source': 'composite',
'source-layer': 'poi_label',
'layout': {
'text-field': 'Test Test Test',
'text-justify': 'auto',
'text-variable-anchor': [
'center',
'top',
'bottom',
'left',
'right',
'top-left',
'top-right',
'bottom-left',
'bottom-right'
]
}
})
});
}
}
4 changes: 3 additions & 1 deletion bench/versions/benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import WorkerTransfer from '../benchmarks/worker_transfer';
import Paint from '../benchmarks/paint';
import PaintStates from '../benchmarks/paint_states';
import {PropertyLevelRemove, FeatureLevelRemove, SourceLevelRemove} from '../benchmarks/remove_paint_state';
import {LayerBackground, LayerCircle, LayerFill, LayerFillExtrusion, LayerHeatmap, LayerHillshade, LayerLine, LayerRaster, LayerSymbol, LayerSymbolWithIcons} from '../benchmarks/layers';
import {LayerBackground, LayerCircle, LayerFill, LayerFillExtrusion, LayerHeatmap, LayerHillshade, LayerLine, LayerRaster, LayerSymbol, LayerSymbolWithIcons, LayerTextWithVariableAnchor, LayerSymbolWithSortKey} from '../benchmarks/layers';
import Load from '../benchmarks/map_load';
import HillshadeLoad from '../benchmarks/hillshade_load';
import Validate from '../benchmarks/style_validate';
Expand Down Expand Up @@ -67,6 +67,8 @@ register('LayerLine', new LayerLine());
register('LayerRaster', new LayerRaster());
register('LayerSymbol', new LayerSymbol());
register('LayerSymbolWithIcons', new LayerSymbolWithIcons());
register('LayerTextWithVariableAnchor', new LayerTextWithVariableAnchor());
register('LayerSymbolWithSortKey', new LayerSymbolWithSortKey());
register('Load', new Load());
register('LayoutDDS', new LayoutDDS());
register('SymbolLayout', new SymbolLayout(style, styleLocations.map(location => location.tileID[0])));
Expand Down

0 comments on commit f8d0a66

Please sign in to comment.