Skip to content

Commit

Permalink
Move benchmarks to ES modules (#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
birkskyum authored Feb 7, 2022
1 parent 2af917e commit aa8ed9d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions bench/rollup_config_benchmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const splitConfig = (name: string): RollupOptions[] => [{
input: [`${srcDir}bench/${name}/benchmarks.${inputExt}`, `${srcDir}src/source/worker.${inputExt}`],
output: {
dir: `rollup/build/benchmarks/${name}`,
format: 'amd',
format: 'es',
indent: false,
sourcemap: 'inline',
chunkFileNames: 'shared.js'
Expand All @@ -48,7 +48,7 @@ const splitConfig = (name: string): RollupOptions[] => [{
input: `rollup/benchmarks_${name}.js`,
output: {
file: `bench/${name}/benchmarks_generated.js`,
format: 'umd',
format: 'es',
indent: false,
sourcemap: true,
intro
Expand All @@ -62,7 +62,7 @@ const viewConfig: RollupOptions = {
output: {
name: 'Benchmarks',
file: 'bench/benchmarks_view_generated.js',
format: 'umd',
format: 'es',
indent: false,
sourcemap: false
},
Expand Down
10 changes: 6 additions & 4 deletions bench/styles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

<body>
<div id="benchmarks"></div>
<script src="/bench/styles/benchmarks_generated.js"></script>
<script src="/bench/benchmarks_view_generated.js"></script>
<script>
window.Benchmarks.run(benchmarks);

<script type="module">
await import('/bench/styles/benchmarks_generated.js');
const {run} = await import('/bench/benchmarks_view_generated.js');

run(benchmarks);
</script>
</body>

Expand Down
8 changes: 5 additions & 3 deletions bench/versions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

<body>
<div id="benchmarks"></div>
<script src="/bench/benchmarks_view_generated.js"></script>
<script>
<!-- <script type="module" src="/bench/benchmarks_view_generated.js"></script> -->
<script type="module">
const {run} = await import('/bench/benchmarks_view_generated.js');
runComparison();

async function runComparison() {
Expand Down Expand Up @@ -52,7 +53,7 @@
benchmarks.push({name, versions});
}

const results = await window.Benchmarks.run(benchmarks);
const results = await run(benchmarks);
// eslint-disable-next-line require-atomic-updates
window.maplibreglBenchmarkResults = {};
for (const result of results) {
Expand All @@ -72,6 +73,7 @@
return new Promise((resolve, reject) => {
const s = document.createElement('script');
s.src = src;
s.type = 'module';
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
Expand Down

0 comments on commit aa8ed9d

Please sign in to comment.