|
1 | 1 | import * as $ from '../packages/svelte/src/internal/client/index.js';
|
2 |
| -import { kairo_avoidable } from './benchmarks/kairo/kairo_avoidable.js'; |
3 |
| -import { kairo_broad } from './benchmarks/kairo/kairo_broad.js'; |
4 |
| -import { kairo_deep } from './benchmarks/kairo/kairo_deep.js'; |
5 |
| -import { kairo_diamond } from './benchmarks/kairo/kairo_diamond.js'; |
6 |
| -import { kairo_mux } from './benchmarks/kairo/kairo_mux.js'; |
7 |
| -import { kairo_repeated } from './benchmarks/kairo/kairo_repeated.js'; |
8 |
| -import { kairo_triangle } from './benchmarks/kairo/kairo_triangle.js'; |
9 |
| -import { kairo_unstable } from './benchmarks/kairo/kairo_unstable.js'; |
10 |
| -import { mol_bench } from './benchmarks/mol_bench.js'; |
| 2 | +import { benchmarks } from './benchmarks.js'; |
11 | 3 |
|
12 |
| -// This benchmark has been adapted from the js-reactivity-benchmark (https://github.com/milomg/js-reactivity-benchmark) |
13 |
| -// Not all tests are the same, and many parts have been tweaked to capture different data. |
| 4 | +let total_time = 0; |
| 5 | +let total_gc_time = 0; |
14 | 6 |
|
15 |
| -const benchmarks = [ |
16 |
| - kairo_avoidable, |
17 |
| - kairo_broad, |
18 |
| - kairo_deep, |
19 |
| - kairo_diamond, |
20 |
| - kairo_triangle, |
21 |
| - kairo_mux, |
22 |
| - kairo_repeated, |
23 |
| - kairo_unstable, |
24 |
| - mol_bench |
25 |
| -]; |
26 |
| - |
27 |
| -async function run_benchmarks() { |
28 |
| - let total_time = 0; |
29 |
| - let total_gc_time = 0; |
30 |
| - // eslint-disable-next-line no-console |
31 |
| - console.log('-- Benchmarking Started --'); |
32 |
| - $.push({}, true); |
33 |
| - try { |
34 |
| - for (const benchmark of benchmarks) { |
35 |
| - const results = await benchmark(); |
36 |
| - // eslint-disable-next-line no-console |
37 |
| - console.log(results); |
38 |
| - total_time += Number(results.time); |
39 |
| - total_gc_time += Number(results.gc_time); |
40 |
| - } |
41 |
| - } catch (e) { |
| 7 | +// eslint-disable-next-line no-console |
| 8 | +console.log('-- Benchmarking Started --'); |
| 9 | +$.push({}, true); |
| 10 | +try { |
| 11 | + for (const benchmark of benchmarks) { |
| 12 | + const results = await benchmark(); |
42 | 13 | // eslint-disable-next-line no-console
|
43 |
| - console.error('-- Benchmarking Failed --'); |
44 |
| - // eslint-disable-next-line no-console |
45 |
| - console.error(e); |
46 |
| - process.exit(1); |
| 14 | + console.log(results); |
| 15 | + total_time += Number(results.time); |
| 16 | + total_gc_time += Number(results.gc_time); |
47 | 17 | }
|
48 |
| - $.pop(); |
| 18 | +} catch (e) { |
49 | 19 | // eslint-disable-next-line no-console
|
50 |
| - console.log(`-- Benchmarking Complete --`); |
| 20 | + console.error('-- Benchmarking Failed --'); |
51 | 21 | // eslint-disable-next-line no-console
|
52 |
| - console.log({ |
53 |
| - total_time: total_time.toFixed(2), |
54 |
| - total_gc_time: total_gc_time.toFixed(2) |
55 |
| - }); |
| 22 | + console.error(e); |
| 23 | + process.exit(1); |
56 | 24 | }
|
57 |
| - |
58 |
| -run_benchmarks(); |
| 25 | +$.pop(); |
| 26 | +// eslint-disable-next-line no-console |
| 27 | +console.log('-- Benchmarking Complete --'); |
| 28 | +// eslint-disable-next-line no-console |
| 29 | +console.log({ |
| 30 | + total_time: total_time.toFixed(2), |
| 31 | + total_gc_time: total_gc_time.toFixed(2) |
| 32 | +}); |
0 commit comments