2024-06-19 19:33:53 +02:00
|
|
|
import * as $ from '../packages/svelte/src/internal/client/index.js';
|
2024-11-19 19:06:32 +01:00
|
|
|
import { reactivity_benchmarks } from './benchmarks/reactivity/index.js';
|
|
|
|
import { ssr_benchmarks } from './benchmarks/ssr/index.js';
|
2024-06-19 19:33:53 +02:00
|
|
|
|
2024-06-20 11:05:11 +02:00
|
|
|
let total_time = 0;
|
|
|
|
let total_gc_time = 0;
|
2024-06-19 19:33:53 +02:00
|
|
|
|
2024-11-19 19:06:32 +01:00
|
|
|
const suites = [
|
|
|
|
{ benchmarks: reactivity_benchmarks, name: 'reactivity benchmarks' },
|
|
|
|
{ benchmarks: ssr_benchmarks, name: 'server-side rendering benchmarks' }
|
|
|
|
];
|
|
|
|
|
2024-06-20 11:05:11 +02:00
|
|
|
// eslint-disable-next-line no-console
|
2024-11-19 19:06:32 +01:00
|
|
|
console.log('\x1b[1m', '-- Benchmarking Started --', '\x1b[0m');
|
2024-06-20 11:05:11 +02:00
|
|
|
$.push({}, true);
|
|
|
|
try {
|
2024-11-19 19:06:32 +01:00
|
|
|
for (const { benchmarks, name } of suites) {
|
|
|
|
let suite_time = 0;
|
|
|
|
let suite_gc_time = 0;
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log(`\nRunning ${name}...\n`);
|
|
|
|
|
|
|
|
for (const benchmark of benchmarks) {
|
|
|
|
const results = await benchmark();
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log(results);
|
|
|
|
total_time += Number(results.time);
|
|
|
|
total_gc_time += Number(results.gc_time);
|
|
|
|
suite_time += Number(results.time);
|
|
|
|
suite_gc_time += Number(results.gc_time);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(`\nFinished ${name}.\n`);
|
|
|
|
|
2024-06-19 21:52:20 +02:00
|
|
|
// eslint-disable-next-line no-console
|
2024-11-19 19:06:32 +01:00
|
|
|
console.log({
|
|
|
|
suite_time: suite_time.toFixed(2),
|
|
|
|
suite_gc_time: suite_gc_time.toFixed(2)
|
|
|
|
});
|
2024-06-19 19:33:53 +02:00
|
|
|
}
|
2024-06-20 11:05:11 +02:00
|
|
|
} catch (e) {
|
2024-06-19 19:33:53 +02:00
|
|
|
// eslint-disable-next-line no-console
|
2024-11-19 19:06:32 +01:00
|
|
|
console.log('\x1b[1m', '\n-- Benchmarking Failed --\n', '\x1b[0m');
|
2024-06-20 10:47:35 +02:00
|
|
|
// eslint-disable-next-line no-console
|
2024-06-20 11:05:11 +02:00
|
|
|
console.error(e);
|
|
|
|
process.exit(1);
|
2024-06-19 19:33:53 +02:00
|
|
|
}
|
2024-06-20 11:05:11 +02:00
|
|
|
$.pop();
|
|
|
|
// eslint-disable-next-line no-console
|
2024-11-19 19:06:32 +01:00
|
|
|
console.log('\x1b[1m', '\n-- Benchmarking Complete --\n', '\x1b[0m');
|
2024-06-20 11:05:11 +02:00
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log({
|
|
|
|
total_time: total_time.toFixed(2),
|
|
|
|
total_gc_time: total_gc_time.toFixed(2)
|
|
|
|
});
|