mirror of https://github.com/sveltejs/svelte
parent
c7f6805c37
commit
198692ebac
@ -0,0 +1,24 @@
|
||||
import { kairo_avoidable } from './benchmarks/kairo/kairo_avoidable.js';
|
||||
import { kairo_broad } from './benchmarks/kairo/kairo_broad.js';
|
||||
import { kairo_deep } from './benchmarks/kairo/kairo_deep.js';
|
||||
import { kairo_diamond } from './benchmarks/kairo/kairo_diamond.js';
|
||||
import { kairo_mux } from './benchmarks/kairo/kairo_mux.js';
|
||||
import { kairo_repeated } from './benchmarks/kairo/kairo_repeated.js';
|
||||
import { kairo_triangle } from './benchmarks/kairo/kairo_triangle.js';
|
||||
import { kairo_unstable } from './benchmarks/kairo/kairo_unstable.js';
|
||||
import { mol_bench } from './benchmarks/mol_bench.js';
|
||||
|
||||
// This benchmark has been adapted from the js-reactivity-benchmark (https://github.com/milomg/js-reactivity-benchmark)
|
||||
// Not all tests are the same, and many parts have been tweaked to capture different data.
|
||||
|
||||
export const benchmarks = [
|
||||
kairo_avoidable,
|
||||
kairo_broad,
|
||||
kairo_deep,
|
||||
kairo_diamond,
|
||||
kairo_triangle,
|
||||
kairo_mux,
|
||||
kairo_repeated,
|
||||
kairo_unstable,
|
||||
mol_bench
|
||||
];
|
||||
@ -0,0 +1,58 @@
|
||||
import fs from 'node:fs';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { benchmarks } from './benchmarks.js';
|
||||
|
||||
const results = fileURLToPath(new URL('./.results', import.meta.url));
|
||||
|
||||
console.log(results);
|
||||
|
||||
const [
|
||||
a = execSync('git symbolic-ref --short -q HEAD || git rev-parse --short HEAD').toString().trim(),
|
||||
b = 'main'
|
||||
] = process.argv.slice(2);
|
||||
|
||||
const a_hash = execSync(`git rev-parse ${a}`).toString().trim();
|
||||
const b_hash = execSync(`git rev-parse ${b}`).toString().trim();
|
||||
|
||||
if (a_hash === b_hash) {
|
||||
console.log('Branches are the same');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
/** @type {TODO[]} */
|
||||
let a_results;
|
||||
|
||||
/** @type {TODO[]} */
|
||||
let b_results;
|
||||
|
||||
async function run() {
|
||||
const results = [];
|
||||
for (const benchmark of benchmarks) {
|
||||
const result = await benchmark();
|
||||
console.log(result.name);
|
||||
results.push(result);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
// step 1 — run the benchmark on the current branch
|
||||
{
|
||||
a_results = await run();
|
||||
console.log(a_results);
|
||||
|
||||
fs.writeFileSync(`${results}/${a_hash.slice(0, 8)}.json`, JSON.stringify(a_results, null, ' '));
|
||||
}
|
||||
|
||||
// step 2 — run the benchmark on the comparison branch (usually main)
|
||||
{
|
||||
b_results = await run();
|
||||
console.log(b_results);
|
||||
|
||||
fs.writeFileSync(`${results}/${b_hash.slice(0, 8)}.json`, JSON.stringify(b_results, null, ' '));
|
||||
}
|
||||
|
||||
// step 3 — compare the results
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
Loading…
Reference in new issue