memory.js — astro Source File
Architecture documentation for memory.js, a javascript file in the astro codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR b65fc43f_6458_b0c9_e367_578ca2d1c391["memory.js"] 4265c711_d908_961d_b7f8_d10af2c1c59b["_util.js"] b65fc43f_6458_b0c9_e367_578ca2d1c391 --> 4265c711_d908_961d_b7f8_d10af2c1c59b 5d6d1861_a18d_b246_cd94_08889ab7e74c["promises"] b65fc43f_6458_b0c9_e367_578ca2d1c391 --> 5d6d1861_a18d_b246_cd94_08889ab7e74c d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] b65fc43f_6458_b0c9_e367_578ca2d1c391 --> d9a92db9_c95e_9165_13ac_24b3d859d946 50f71548_38c8_8ade_dfca_b84f78362dc4["markdown-table"] b65fc43f_6458_b0c9_e367_578ca2d1c391 --> 50f71548_38c8_8ade_dfca_b84f78362dc4 015e2115_00b7_8619_a3f3_dc6eceb4c058["tinyexec"] b65fc43f_6458_b0c9_e367_578ca2d1c391 --> 015e2115_00b7_8619_a3f3_dc6eceb4c058 style b65fc43f_6458_b0c9_e367_578ca2d1c391 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { markdownTable } from 'markdown-table';
import { exec } from 'tinyexec';
import { astroBin } from './_util.js';
/** @typedef {Record<string, import('../../packages/astro/src/core/config/timer').Stat>} AstroTimerStat */
/** Default project to run for this benchmark if not specified */
export const defaultProject = 'memory-default';
/**
* @param {URL} projectDir
* @param {URL} outputFile
*/
export async function run(projectDir, outputFile) {
const root = fileURLToPath(projectDir);
const outputFilePath = fileURLToPath(outputFile);
console.log('Building and benchmarking...');
await exec('node', ['--expose-gc', '--max_old_space_size=10000', astroBin, 'build'], {
nodeOptions: {
cwd: root,
stdio: 'inherit',
env: {
ASTRO_TIMER_PATH: outputFilePath,
},
},
throwOnError: true,
});
console.log('Raw results written to', outputFilePath);
console.log('Result preview:');
console.log('='.repeat(10));
console.log(`#### Memory\n\n`);
console.log(printResult(JSON.parse(await fs.readFile(outputFilePath, 'utf-8'))));
console.log('='.repeat(10));
console.log('Done!');
}
/**
* @param {AstroTimerStat} output
*/
function printResult(output) {
return markdownTable(
[
['', 'Elapsed time (s)', 'Memory used (MB)', 'Final memory (MB)'],
...Object.entries(output).map(([name, stat]) => [
name,
(stat.elapsedTime / 1000).toFixed(2),
(stat.heapUsedChange / 1024 / 1024).toFixed(2),
(stat.heapUsedTotal / 1024 / 1024).toFixed(2),
]),
],
{
align: ['l', 'r', 'r', 'r'],
},
);
}
Domain
Subdomains
Functions
Dependencies
- _util.js
- markdown-table
- node:url
- promises
- tinyexec
Source
Frequently Asked Questions
What does memory.js do?
memory.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 memory.js?
memory.js defines 2 function(s): printResult, run.
What does memory.js depend on?
memory.js imports 5 module(s): _util.js, markdown-table, node:url, promises, tinyexec.
Where is memory.js in the architecture?
memory.js is located at benchmark/bench/memory.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