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

Migrate benchmarks #201

Closed
wants to merge 5 commits into from
Closed
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
16 changes: 0 additions & 16 deletions bench/lib/access_token.js

This file was deleted.

10 changes: 4 additions & 6 deletions bench/rollup_config_benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ import buble from 'rollup-plugin-buble';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

let styles = ['mapbox://styles/mapbox/streets-v10'];
let styles = ['https://api.maptiler.com/maps/streets/style.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL'];

if (process.env.MAPBOX_STYLES) {
styles = process.env.MAPBOX_STYLES
if (process.env.MAPLIBRE_STYLES) {
styles = process.env.MAPLIBRE_STYLES
.split(',')
.map(style => style.match(/\.json$/) ? require(style) : style);
}

const replaceConfig = {
'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION),
'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN),
'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken),
'process.env.MAPBOX_STYLES': JSON.stringify(styles),
'process.env.MAPLIBRE_STYLES': JSON.stringify(styles),
'process.env.NODE_ENV': JSON.stringify('production')
};

Expand Down
11 changes: 4 additions & 7 deletions bench/styles/benchmarks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import maplibregl from '../../src';
import accessToken from '../lib/access_token';
import locationsWithTileID from '../lib/locations_with_tile_id';
import styleBenchmarkLocations from '@mapbox/gazetteer/benchmark/style-benchmark-locations.json';
import StyleLayerCreate from '../benchmarks/style_layer_create';
Expand All @@ -13,25 +12,23 @@ import getWorkerPool from '../../src/util/global_worker_pool';

const locations = locationsWithTileID(styleBenchmarkLocations.features);

maplibregl.accessToken = accessToken;

const benchmarks = window.benchmarks = [];

function register(name, Benchmark, locations, location) {
const versions = [];

for (const style of process.env.MAPBOX_STYLES) {
for (const style of process.env.MAPLIBRE_STYLES) {
versions.push({
name: style.name || style.replace('mapbox://styles/', ''),
name: style.name || style,
bench: new Benchmark(style, locations)
});
}
benchmarks.push({name, versions, location});
}

register('StyleLayerCreate', StyleLayerCreate);
register('Validate', Validate);
locations.forEach(location => register('Layout', Layout, location.tileID, location));
//register('Validate', Validate);
//locations.forEach(location => register('Layout', Layout, location.tileID, location));
locations.forEach(location => register('Paint', Paint, [location], location));
register('QueryPoint', QueryPoint, locations);
register('QueryBox', QueryBox, locations);
Expand Down
29 changes: 14 additions & 15 deletions bench/versions/benchmarks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import maplibregl from '../../src';
import accessToken from '../lib/access_token';
import locationsWithTileID from '../lib/locations_with_tile_id';
import styleBenchmarkLocations from '@mapbox/gazetteer/benchmark/style-benchmark-locations.json';
import Layout from '../benchmarks/layout';
Expand All @@ -25,8 +24,6 @@ import getWorkerPool from '../../src/util/global_worker_pool';

const styleLocations = locationsWithTileID(styleBenchmarkLocations.features);

maplibregl.accessToken = accessToken;

window.maplibreglBenchmarks = window.maplibreglBenchmarks || {};

const version = process.env.BENCHMARK_VERSION;
Expand All @@ -36,27 +33,28 @@ function register(name, bench) {
window.maplibreglBenchmarks[name][version] = bench;
}

const style = 'mapbox://styles/mapbox/streets-v10';
const style = 'https://api.maptiler.com/maps/streets/style.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL';
const center = [-77.032194, 38.912753];
const zooms = [4, 8, 11, 13, 15, 17];
const locations = zooms.map(zoom => ({center, zoom}));

register('Paint', new Paint(style, locations));
register('QueryPoint', new QueryPoint(style, locations));
register('QueryBox', new QueryBox(style, locations));
register('Layout', new Layout(style));
//register('Layout', new Layout(style));
register('Placement', new Placement(style, locations));
register('Validate', new Validate(style));
//register('Validate', new Validate(style));
register('StyleLayerCreate', new StyleLayerCreate(style));
register('FunctionCreate', new FunctionCreate(style));
register('FunctionEvaluate', new FunctionEvaluate(style));
register('ExpressionCreate', new ExpressionCreate(style));
register('ExpressionEvaluate', new ExpressionEvaluate(style));
register('WorkerTransfer', new WorkerTransfer(style));
register('PaintStates', new PaintStates(center));
register('PropertyLevelRemove', new PropertyLevelRemove(center));
register('FeatureLevelRemove', new FeatureLevelRemove(center));
register('SourceLevelRemove', new SourceLevelRemove(center));
//register('WorkerTransfer', new WorkerTransfer(style));
//register('PaintStates', new PaintStates(center));
//register('PropertyLevelRemove', new PropertyLevelRemove(center));
//register('FeatureLevelRemove', new FeatureLevelRemove(center));
//register('SourceLevelRemove', new SourceLevelRemove(center));
/*
register('LayerBackground', new LayerBackground());
register('LayerCircle', new LayerCircle());
register('LayerFill', new LayerFill());
Expand All @@ -69,12 +67,13 @@ 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])));
//register('LayoutDDS', new LayoutDDS());
//register('SymbolLayout', new SymbolLayout(style, styleLocations.map(location => location.tileID[0])));
register('FilterCreate', new FilterCreate());
register('FilterEvaluate', new FilterEvaluate());
register('HillshadeLoad', new HillshadeLoad());
//register('FilterEvaluate', new FilterEvaluate());
//register('HillshadeLoad', new HillshadeLoad());

Promise.resolve().then(() => {
// Ensure the global worker pool is never drained. Browsers have resource limits
Expand Down
14 changes: 6 additions & 8 deletions bench/versions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<link rel='stylesheet' href='/dist/maplibre-gl.css'/>
<script src='https://unpkg.com/url-search-params@0.10.0/build/url-search-params.js'></script>
</head>
Expand All @@ -18,25 +17,24 @@
const params = new URLSearchParams(location.search.slice(1));
Promise.resolve(params.has('compare') ?
params.getAll('compare').filter(Boolean) :
fetch('https://api.github.com/repos/mapbox/mapbox-gl-js/releases/latest')
fetch('https://api.github.com/repos/maplibre/maplibre-gl-js/releases/latest')
.then(response => response.json())
.then(pkg => [pkg['tag_name'], 'main']))
.then(versions => {
return versions
.map(v => `https://s3.amazonaws.com/mapbox-gl-js/${v}/benchmarks.js`)
.concat('/bench/versions/benchmarks_generated.js')
//TODO get generated benchmarks_generated.js for released maplibre-gl-js
return ['/bench/versions/benchmarks_generated.js']
.reduce((p, script) => p.then(() => loadScript(script)), Promise.resolve());
})
.then(() => {
const benchmarks = [];

for (const name in window.mapboxglBenchmarks) {
for (const name in window.maplibreglBenchmarks) {
const versions = [];

for (const test in window.mapboxglBenchmarks[name]) {
for (const test in window.maplibreglBenchmarks[name]) {
versions.push({
name: test,
bench: window.mapboxglBenchmarks[name][test]
bench: window.maplibreglBenchmarks[name][test]
});
}
benchmarks.push({name, versions});
Expand Down