diff --git a/bench/benchmarks/layers.js b/bench/benchmarks/layers.js index a251a07a40a..13ba7214db3 100644 --- a/bench/benchmarks/layers.js +++ b/bench/benchmarks/layers.js @@ -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})); } @@ -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' + ] + } + }) + }); + } +} diff --git a/bench/versions/benchmarks.js b/bench/versions/benchmarks.js index c243613cbab..3738aded4e1 100644 --- a/bench/versions/benchmarks.js +++ b/bench/versions/benchmarks.js @@ -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'; @@ -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])));