-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmark that specifically targets
performSymbolLayout
(e.g. t…
…ext shaping and line breaking) Use style_locations as input to ensure CJK-dense tiles are tested.
- Loading branch information
Showing
6 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// @flow | ||
|
||
import Layout from './layout'; | ||
import SymbolBucket from '../../src/data/bucket/symbol_bucket'; | ||
import { performSymbolLayout } from '../../src/symbol/symbol_layout'; | ||
import { OverscaledTileID } from '../../src/source/tile_id'; | ||
|
||
export default class SymbolLayout extends Layout { | ||
parsedTiles: Array<any>; | ||
|
||
constructor(style: string, locations: ?Array<OverscaledTileID>) { | ||
super(style, locations); | ||
this.parsedTiles = []; | ||
} | ||
|
||
setup(): Promise<void> { | ||
return super.setup().then(() => { | ||
// Do initial load/parse of tiles and hold onto all the glyph/icon | ||
// dependencies so that we can re-do symbol layout in isolation | ||
// during the bench step. | ||
return Promise.all(this.tiles.map(tile => | ||
this.parser.parseTile(tile, true).then((tileResult) => { | ||
this.parsedTiles.push(tileResult); | ||
}) | ||
)).then(() => {}); | ||
}); | ||
} | ||
|
||
bench() { | ||
let promise = Promise.resolve(); | ||
for (const tileResult of this.parsedTiles) { | ||
promise = promise.then(() => { | ||
for (const bucket of tileResult.buckets) { | ||
if (bucket instanceof SymbolBucket) { | ||
performSymbolLayout(bucket, | ||
tileResult.glyphMap, | ||
tileResult.glyphPositions, | ||
tileResult.iconMap, | ||
tileResult.imageAtlas.iconPositions, | ||
false); | ||
} | ||
} | ||
}); | ||
} | ||
return promise; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters