Home / Function/ run() — astro Function Reference

run() — astro Function Reference

Architecture documentation for the run() function in render.js from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  5859bb26_4e70_6d53_da16_27fa6a682cb2["run()"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d["render.js"]
  5859bb26_4e70_6d53_da16_27fa6a682cb2 -->|defined in| 3c790668_be1c_58e1_f783_4e3a5b4e3a0d
  b2305d92_79d3_ab8e_a353_3987d6f14929["run()"]
  5859bb26_4e70_6d53_da16_27fa6a682cb2 -->|calls| b2305d92_79d3_ab8e_a353_3987d6f14929
  0a0d5ca9_b005_f655_c7a6_9a56ad9a11e6["benchmarkRenderTime()"]
  5859bb26_4e70_6d53_da16_27fa6a682cb2 -->|calls| 0a0d5ca9_b005_f655_c7a6_9a56ad9a11e6
  ba74d45c_147c_f921_2c51_faf3d4a148e1["printResult()"]
  5859bb26_4e70_6d53_da16_27fa6a682cb2 -->|calls| ba74d45c_147c_f921_2c51_faf3d4a148e1
  style 5859bb26_4e70_6d53_da16_27fa6a682cb2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

benchmark/bench/render.js lines 19–61

export async function run(projectDir, outputFile) {
	const root = fileURLToPath(projectDir);

	console.log('Building...');
	await exec(astroBin, ['build'], {
		nodeOptions: {
			cwd: root,
			stdio: 'inherit',
		},
		throwOnError: true,
	});

	console.log('Previewing...');
	const previewProcess = exec(astroBin, ['preview', '--port', port], {
		nodeOptions: {
			cwd: root,
			stdio: 'inherit',
		},
		throwOnError: true,
	});

	console.log('Waiting for server ready...');
	await waitUntilBusy(port, { timeout: 5000 });

	console.log('Running benchmark...');
	const result = await benchmarkRenderTime();

	console.log('Killing server...');
	if (!previewProcess.kill('SIGTERM')) {
		console.warn('Failed to kill server process id:', previewProcess.pid);
	}

	console.log('Writing results to', fileURLToPath(outputFile));
	await fs.writeFile(outputFile, JSON.stringify(result, null, 2));

	console.log('Result preview:');
	console.log('='.repeat(10));
	console.log(`#### Render\n\n`);
	console.log(printResult(result));
	console.log('='.repeat(10));

	console.log('Done!');
}

Subdomains

Frequently Asked Questions

What does run() do?
run() is a function in the astro codebase, defined in benchmark/bench/render.js.
Where is run() defined?
run() is defined in benchmark/bench/render.js at line 19.
What does run() call?
run() calls 3 function(s): benchmarkRenderTime, printResult, run.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free