-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
3 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,61 @@ | ||
// @flow | ||
|
||
import Benchmark from '../lib/benchmark'; | ||
import createMap from '../lib/create_map'; | ||
import type Map from '../../src/ui/map'; | ||
|
||
const width = 1024; | ||
const height = 768; | ||
|
||
export default class Paint extends Benchmark { | ||
style: string; | ||
locations: Array<Object>; | ||
maps: Array<Map>; | ||
|
||
constructor(style: string, locations: Array<Object>) { | ||
super(); | ||
this.style = style; | ||
this.locations = locations; | ||
} | ||
|
||
setup(): Promise<void> { | ||
return Promise.all(this.locations.map(location => { | ||
return createMap({ | ||
zoom: location.zoom, | ||
width, | ||
height, | ||
center: location.center, | ||
style: this.style, | ||
idle: true | ||
}); | ||
})) | ||
.then(maps => { | ||
this.maps = maps; | ||
}) | ||
.catch(error => { | ||
console.error(error); | ||
}); | ||
} | ||
|
||
bench() { | ||
for (const map of this.maps) { | ||
const showCollisionBoxes = false; | ||
const fadeDuration = 300; | ||
const crossSourceCollisions = true; | ||
const forceFullPlacement = true; | ||
|
||
map.style._updatePlacement( | ||
map.transform, | ||
showCollisionBoxes, | ||
fadeDuration, | ||
crossSourceCollisions, | ||
forceFullPlacement); | ||
} | ||
} | ||
|
||
teardown() { | ||
for (const map of this.maps) { | ||
map.remove(); | ||
} | ||
} | ||
} |
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