Home / File/ render.js — astro Source File

render.js — astro Source File

Architecture documentation for render.js, a javascript file in the astro codebase. 10 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d["render.js"]
  9a929f9c_5ccf_5833_23d6_90612b8c9d1d["render-default.js"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> 9a929f9c_5ccf_5833_23d6_90612b8c9d1d
  4265c711_d908_961d_b7f8_d10af2c1c59b["_util.js"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> 4265c711_d908_961d_b7f8_d10af2c1c59b
  726183f0_decf_6bca_ceb6_e7759e37fb91["calculateStat"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> 726183f0_decf_6bca_ceb6_e7759e37fb91
  5d6d1861_a18d_b246_cd94_08889ab7e74c["promises"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> 5d6d1861_a18d_b246_cd94_08889ab7e74c
  c2f6615e_96e9_c4eb_5f71_cf120e271705["node:http"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> c2f6615e_96e9_c4eb_5f71_cf120e271705
  c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> c52a5f83_66e3_37d7_9ebb_767f7129bc62
  d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> d9a92db9_c95e_9165_13ac_24b3d859d946
  50f71548_38c8_8ade_dfca_b84f78362dc4["markdown-table"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> 50f71548_38c8_8ade_dfca_b84f78362dc4
  d1b5b5e6_0e04_a09d_7faa_6b868fd077da["port-authority"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> d1b5b5e6_0e04_a09d_7faa_6b868fd077da
  015e2115_00b7_8619_a3f3_dc6eceb4c058["tinyexec"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> 015e2115_00b7_8619_a3f3_dc6eceb4c058
  style 3c790668_be1c_58e1_f783_4e3a5b4e3a0d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import fs from 'node:fs/promises';
import http from 'node:http';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { markdownTable } from 'markdown-table';
import { waitUntilBusy } from 'port-authority';
import { exec } from 'tinyexec';
import { renderPages } from '../make-project/render-default.js';
import { astroBin, calculateStat } from './_util.js';

const port = 4322;

export const defaultProject = 'render-default';

/**
 * @param {URL} projectDir
 * @param {URL} outputFile
 */
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!');
// ... (62 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does render.js do?
render.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 render.js?
render.js defines 4 function(s): benchmarkRenderTime, fetchRenderTime, printResult, run.
What does render.js depend on?
render.js imports 10 module(s): _util.js, calculateStat, markdown-table, node:http, node:path, node:url, port-authority, promises, and 2 more.
Where is render.js in the architecture?
render.js is located at benchmark/bench/render.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