The package includes two separate tools:
- Runtime benchmarks for key
fint-i18nhot paths. - Bundle analysis to understand the composition of the built
dist.
To run:
yarn --cwd fint-i18n benchWhat the command does:
- Runs benchmark files from
bench/**/*.bench.tsviavitest bench. - Saves machine-readable results to
dist/analysis/bench-results.json. - Prints
ops/secfor each scenario to the console.
Current scenarios in bench/core.bench.ts:
- Cold compile for
compileTemplate(). - Steady-state translation via
i18n.t()after cache warmup. - Nested lookup for an already compiled key.
setLocale()with already registered used blocks.
What the console output means:
name— Name of the benchmark scenario.hz/ops/sec— Operations per second; higher is faster.min,max,mean— Minimum, maximum, and average time for a single operation in milliseconds; lower is better.p75,p99,p995,p999— Execution time percentiles; showing how expensive the "tails" are.rme— Relative margin of error; lower means more stable results.samples— Number of measurements collected for statistical calculation.
Important:
- Results should only be compared between runs on the same machine under similar conditions.
- This is not a microbenchmark of the entire Node runtime, but applied scenarios for
fint-i18nitself.
To run:
yarn --cwd fint-i18n build:analyzeWhat the command does:
- Builds the library as usual.
- Enables
rollup-plugin-visualizeronly during analysis. - Places reports in
dist/analysis/.
Artifacts:
dist/analysis/stats.html— Interactive treemap.dist/analysis/stats.md— Text summary for reading and code review.dist/analysis/stats.json— Raw data report for automated processing or comparison.
How to read the reports:
stats.htmlhelps quickly see which modules and chunks take up the most space.stats.mdis convenient for use in PRs or local audits when a text summary is needed.stats.jsonis useful for subsequent machine analysis or custom scripts.
Minimum cycle after changing the runtime:
yarn --cwd fint-i18n bench
yarn --cwd fint-i18n build:analyzeThis answers two different questions:
- Has the performance of the hot path degraded?
- Has the composition/size of the built bundle increased without reason?