-
-
Notifications
You must be signed in to change notification settings - Fork 754
/
Copy pathindex.html
61 lines (53 loc) · 2.19 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<title>MapLibre GL JS Benchmarks</title>
<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>
<body>
<div id="benchmarks"></div>
<script src="/bench/benchmarks_view_generated.js"></script>
<script>
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')
.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')
.reduce((p, script) => p.then(() => loadScript(script)), Promise.resolve());
})
.then(() => {
const benchmarks = [];
for (const name in window.mapboxglBenchmarks) {
const versions = [];
for (const test in window.mapboxglBenchmarks[name]) {
versions.push({
name: test,
bench: window.mapboxglBenchmarks[name][test]
});
}
benchmarks.push({name, versions});
}
window.Benchmarks.run(benchmarks);
})
.catch(err => console.error(err));
function loadScript(src) {
return new Promise(function (resolve, reject) {
const s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
</script>
</body>
</html>