Measure the runtime performance impact of npm dependencies
npm install dep-perf-analyzerimport analyzeDep, {analyzeMultiple, formatReport} from 'dep-perf-analyzer';
// Analyze a single dependency
const result = await analyzeDep('express');
console.log(result.startupTime); // Startup time in ms
console.log(result.memoryDelta.heapUsed); // Heap memory delta in bytes
// Analyze multiple dependencies
const results = await analyzeMultiple(['express', 'koa', 'fastify']);
console.log(formatReport(results));Returns: Promise<{startupTime, memoryDelta, eventLoopBlock}>
Type: string
The package name or module specifier to analyze.
Type: object
Type: number
Default: 3
Number of measurement iterations. Median values are used for stability.
Type: boolean
Default: true
Whether to run a warmup iteration before measuring.
Each iteration runs in an isolated subprocess. Once metrics are collected, the subprocess exits even if the imported module keeps timers or other handles open. Module stdout is separate from the measurement result.
startupTime— Median startup time in millisecondsmemoryDelta.rss— RSS delta in bytesmemoryDelta.heapUsed— Used heap delta in bytesmemoryDelta.heapTotal— Total heap delta in byteseventLoopBlock— Median event loop blocking time in milliseconds
Returns: Promise<Map<string, AnalysisResult>>
Analyze multiple packages sequentially.
Returns: string
Format a results map as a human-readable table.
- import-cost — Display import size in your editor
MIT