index.js — svelte Source File
Architecture documentation for index.js, a javascript file in the svelte codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 61e57f81_1d4c_c9cd_8e0c_d9903848d207["index.js"] f596e027_a951_36c9_7695_83acc4f0d6b9["node:fs"] 61e57f81_1d4c_c9cd_8e0c_d9903848d207 --> f596e027_a951_36c9_7695_83acc4f0d6b9 f8929fbd_6327_2bb8_f43b_31a3db2e4d74["node:path"] 61e57f81_1d4c_c9cd_8e0c_d9903848d207 --> f8929fbd_6327_2bb8_f43b_31a3db2e4d74 e3192c44_2236_3f27_3156_57dc06a450bd["node:child_process"] 61e57f81_1d4c_c9cd_8e0c_d9903848d207 --> e3192c44_2236_3f27_3156_57dc06a450bd 1cb33a46_d09d_1289_a578_521205c56653["node:url"] 61e57f81_1d4c_c9cd_8e0c_d9903848d207 --> 1cb33a46_d09d_1289_a578_521205c56653 style 61e57f81_1d4c_c9cd_8e0c_d9903848d207 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import fs from 'node:fs';
import path from 'node:path';
import { execSync, fork } from 'node:child_process';
import { fileURLToPath } from 'node:url';
// if (execSync('git status --porcelain').toString().trim()) {
// console.error('Working directory is not clean');
// process.exit(1);
// }
const filename = fileURLToPath(import.meta.url);
const runner = path.resolve(filename, '../runner.js');
const outdir = path.resolve(filename, '../.results');
if (fs.existsSync(outdir)) fs.rmSync(outdir, { recursive: true });
fs.mkdirSync(outdir);
const branches = [];
for (const arg of process.argv.slice(2)) {
if (arg.startsWith('--')) continue;
if (arg === filename) continue;
branches.push(arg);
}
if (branches.length === 0) {
branches.push(
execSync('git symbolic-ref --short -q HEAD || git rev-parse --short HEAD').toString().trim()
);
}
if (branches.length === 1) {
branches.push('main');
}
process.on('exit', () => {
execSync(`git checkout ${branches[0]}`);
});
for (const branch of branches) {
console.group(`Benchmarking ${branch}`);
execSync(`git checkout ${branch}`);
await new Promise((fulfil, reject) => {
const child = fork(runner);
child.on('message', (results) => {
fs.writeFileSync(`${outdir}/${branch}.json`, JSON.stringify(results, null, ' '));
fulfil();
});
child.on('error', reject);
});
console.groupEnd();
}
const results = branches.map((branch) => {
return JSON.parse(fs.readFileSync(`${outdir}/${branch}.json`, 'utf-8'));
});
for (let i = 0; i < results[0].length; i += 1) {
console.group(`${results[0][i].benchmark}`);
for (const metric of ['time', 'gc_time']) {
const times = results.map((result) => +result[i][metric]);
let min = Infinity;
let max = -Infinity;
let min_index = -1;
for (let b = 0; b < times.length; b += 1) {
const time = times[b];
if (time < min) {
min = time;
min_index = b;
}
if (time > max) {
max = time;
}
}
if (min !== 0) {
console.group(`${metric}: fastest is ${char(min_index)} (${branches[min_index]})`);
times.forEach((time, b) => {
const SIZE = 20;
const n = Math.round(SIZE * (time / max));
console.log(`${char(b)}: ${'◼'.repeat(n)}${' '.repeat(SIZE - n)} ${time.toFixed(2)}ms`);
});
console.groupEnd();
}
}
console.groupEnd();
}
function char(i) {
return String.fromCharCode(97 + i);
}
Domain
Subdomains
Dependencies
- node:child_process
- node:fs
- node:path
- node:url
Source
Frequently Asked Questions
What does index.js do?
index.js is a source file in the svelte codebase, written in javascript. It belongs to the ReactivityBenchmarks domain, Runner subdomain.
What functions are defined in index.js?
index.js defines 3 function(s): char, results, times.
What does index.js depend on?
index.js imports 4 module(s): node:child_process, node:fs, node:path, node:url.
Where is index.js in the architecture?
index.js is located at benchmarking/compare/index.js (domain: ReactivityBenchmarks, subdomain: Runner, directory: benchmarking/compare).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free