cli-startup.js — astro Source File
Architecture documentation for cli-startup.js, a javascript file in the astro codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 4f5ebd66_3fdf_8047_4c83_d856ee583eeb["cli-startup.js"] 4265c711_d908_961d_b7f8_d10af2c1c59b["_util.js"] 4f5ebd66_3fdf_8047_4c83_d856ee583eeb --> 4265c711_d908_961d_b7f8_d10af2c1c59b 726183f0_decf_6bca_ceb6_e7759e37fb91["calculateStat"] 4f5ebd66_3fdf_8047_4c83_d856ee583eeb --> 726183f0_decf_6bca_ceb6_e7759e37fb91 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] 4f5ebd66_3fdf_8047_4c83_d856ee583eeb --> d9a92db9_c95e_9165_13ac_24b3d859d946 50f71548_38c8_8ade_dfca_b84f78362dc4["markdown-table"] 4f5ebd66_3fdf_8047_4c83_d856ee583eeb --> 50f71548_38c8_8ade_dfca_b84f78362dc4 015e2115_00b7_8619_a3f3_dc6eceb4c058["tinyexec"] 4f5ebd66_3fdf_8047_4c83_d856ee583eeb --> 015e2115_00b7_8619_a3f3_dc6eceb4c058 style 4f5ebd66_3fdf_8047_4c83_d856ee583eeb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { fileURLToPath } from 'node:url';
import { markdownTable } from 'markdown-table';
import { exec } from 'tinyexec';
import { astroBin, calculateStat } from './_util.js';
/** Default project to run for this benchmark if not specified */
export const defaultProject = 'render-default';
/**
* @param {URL} projectDir
*/
export async function run(projectDir) {
const root = fileURLToPath(projectDir);
console.log('Benchmarking `astro --help`...');
const helpStat = await benchmarkCommand('node', [astroBin, '--help'], root);
console.log('Done');
console.log('Benchmarking `astro preferences list`...');
const infoStat = await benchmarkCommand('node', [astroBin, 'preferences', 'list'], root);
console.log('Done');
console.log('Result preview:');
console.log('='.repeat(10));
console.log(`#### CLI Startup\n\n`);
console.log(
printResult({
'astro --help': helpStat,
'astro info': infoStat,
}),
);
console.log('='.repeat(10));
}
/**
* @param {string} command
* @param {string[]} args
* @param {string} root
* @returns {Promise<import('./_util.js').Stat>}
*/
async function benchmarkCommand(command, args, root) {
/** @type {number[]} */
const durations = [];
for (let i = 0; i < 10; i++) {
const start = performance.now();
await exec(command, args, { nodeOptions: { cwd: root }, throwOnError: true });
durations.push(performance.now() - start);
}
// From the 10 durations, calculate average, standard deviation, and max value
return calculateStat(durations);
}
/**
* @param {Record<string, import('./_util.js').Stat>} result
*/
function printResult(result) {
return markdownTable(
[
['Command', 'Avg (ms)', 'Stdev (ms)', 'Max (ms)'],
...Object.entries(result).map(([command, { avg, stdev, max }]) => [
command,
avg.toFixed(2),
stdev.toFixed(2),
max.toFixed(2),
]),
],
{
align: ['l', 'r', 'r', 'r'],
},
);
}
Domain
Subdomains
Functions
Dependencies
- _util.js
- calculateStat
- markdown-table
- node:url
- tinyexec
Source
Frequently Asked Questions
What does cli-startup.js do?
cli-startup.js is a source file in the astro codebase, written in javascript. It belongs to the PerformanceBenchmarking domain, MetricsCalculator subdomain.
What functions are defined in cli-startup.js?
cli-startup.js defines 3 function(s): benchmarkCommand, printResult, run.
What does cli-startup.js depend on?
cli-startup.js imports 5 module(s): _util.js, calculateStat, markdown-table, node:url, tinyexec.
Where is cli-startup.js in the architecture?
cli-startup.js is located at benchmark/bench/cli-startup.js (domain: PerformanceBenchmarking, subdomain: MetricsCalculator, directory: benchmark/bench).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free