0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-21 19:38:58 +01:00
svelte/benchmarking/run.js
Rich Harris 331925356e
chore: add pnpm bench:compare script (#12099)
* WIP compare script

* WIP

* fix

* add script

* update

* fix

* tweak

* fix

* update

* add TODO

* compare

* tmp

* gah

* revert

* fix

* fix

* prevent div/0

* reenable benchmarks

---------

Co-authored-by: Dominic Gannaway <dg@domgan.com>
2024-06-20 10:05:11 +01:00

33 lines
897 B
JavaScript

import * as $ from '../packages/svelte/src/internal/client/index.js';
import { benchmarks } from './benchmarks.js';
let total_time = 0;
let total_gc_time = 0;
// eslint-disable-next-line no-console
console.log('-- Benchmarking Started --');
$.push({}, true);
try {
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);
}
} catch (e) {
// eslint-disable-next-line no-console
console.error('-- Benchmarking Failed --');
// eslint-disable-next-line no-console
console.error(e);
process.exit(1);
}
$.pop();
// eslint-disable-next-line no-console
console.log('-- Benchmarking Complete --');
// eslint-disable-next-line no-console
console.log({
total_time: total_time.toFixed(2),
total_gc_time: total_gc_time.toFixed(2)
});