Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmark coverage for text-variable-anchor and symbol-sort-key #9322

Merged
merged 2 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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