content-benchmark.mjs — astro Source File
Architecture documentation for content-benchmark.mjs, a javascript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR b92732a1_433f_7d78_4b70_e38568589f59["content-benchmark.mjs"] 0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"] b92732a1_433f_7d78_4b70_e38568589f59 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"] b92732a1_433f_7d78_4b70_e38568589f59 --> dd4f09ce_3fd7_8295_f616_8876cda4555c 0ae34de5_4ab6_7f40_1864_6596049615f5["generate-posts.mjs"] b92732a1_433f_7d78_4b70_e38568589f59 --> 0ae34de5_4ab6_7f40_1864_6596049615f5 2d88dc27_faa3_1ba8_2029_e9a5f69084d4["generatePosts"] b92732a1_433f_7d78_4b70_e38568589f59 --> 2d88dc27_faa3_1ba8_2029_e9a5f69084d4 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] b92732a1_433f_7d78_4b70_e38568589f59 --> d9a92db9_c95e_9165_13ac_24b3d859d946 b4a76fc8_3591_85b4_7b57_55ab21d1030d["node:util"] b92732a1_433f_7d78_4b70_e38568589f59 --> b4a76fc8_3591_85b4_7b57_55ab21d1030d 4f71d42c_7fce_565d_6d6c_4c86e2735feb["picocolors"] b92732a1_433f_7d78_4b70_e38568589f59 --> 4f71d42c_7fce_565d_6d6c_4c86e2735feb style b92732a1_433f_7d78_4b70_e38568589f59 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { fileURLToPath } from 'node:url';
import { parseArgs } from 'node:util';
import colors from 'picocolors';
import { loadFixture } from '../test/test-utils.js';
import { generatePosts } from './scripts/generate-posts.mjs';
// Skip nonessential remark / rehype plugins for a fair comparison.
// This includes heading ID generation, syntax highlighting, GFM, and Smartypants.
process.env.ASTRO_PERFORMANCE_BENCHMARK = true;
const extByFixture = {
md: '.md',
mdx: '.mdx',
mdoc: '.mdoc',
};
async function benchmark({ fixtures, templates, numPosts }) {
for (const fixture of fixtures) {
const root = new URL(`./fixtures/${fixture}/`, import.meta.url);
await generatePosts({
postsDir: fileURLToPath(new URL('./src/content/generated/', root)),
numPosts,
ext: extByFixture[fixture],
template: templates[fixture],
});
console.info(`[${fixture}] Generated posts`);
const { build } = await loadFixture({
root,
});
const now = performance.now();
console.info(`[${fixture}] Building...`);
await build();
console.info(
colors.cyan(`[${fixture}] Built in ${colors.bold(getTimeStat(now, performance.now()))}.`),
);
}
}
// Test the build performance for content collections across multiple file types (md, mdx, mdoc)
(async function benchmarkAll() {
try {
const { values: flags } = parseArgs({ strict: false });
const test = Array.isArray(flags.test)
? flags.test
: typeof flags.test === 'string'
? [flags.test]
: ['simple', 'with-astro-components', 'with-react-components'];
const formats = Array.isArray(flags.format)
? flags.format
: typeof flags.format === 'string'
? [flags.format]
: ['md', 'mdx', 'mdoc'];
const numPosts = flags.numPosts || 1000;
if (test.includes('simple')) {
const fixtures = formats;
console.info(
// ... (63 more lines)
Domain
Subdomains
Dependencies
- generate-posts.mjs
- generatePosts
- loadFixture
- node:url
- node:util
- picocolors
- test-utils.js
Source
Frequently Asked Questions
What does content-benchmark.mjs do?
content-benchmark.mjs is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in content-benchmark.mjs?
content-benchmark.mjs defines 3 function(s): benchmark, formatsToString, getTimeStat.
What does content-benchmark.mjs depend on?
content-benchmark.mjs imports 7 module(s): generate-posts.mjs, generatePosts, loadFixture, node:url, node:util, picocolors, test-utils.js.
Where is content-benchmark.mjs in the architecture?
content-benchmark.mjs is located at packages/astro/performance/content-benchmark.mjs (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/performance).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free