This is a monorepo containing CodSpeed plugins for various Node.js benchmarking frameworks.
package.json- Root package configurationpnpm-workspace.yaml- PNPM workspace configurationlerna.json- Lerna monorepo configurationtsconfig.base.json- Base TypeScript configurationrollup.options.js- Rollup bundler configurationscripts/- Build and release scriptsdocs/- Documentation filesexamples/- Example projects using the plugins
- Purpose: Core measurement and instrumentation functionality
- Key files:
src/index.ts- Main exports, setupCore/teardownCore functionssrc/mongoMeasurement.ts- MongoDB measurement handlingsrc/optimization.ts- Function optimization utilitiessrc/native_core/- Native C++ bindings for performance measurementsrc/introspection.ts- V8 flags and runtime introspection
- Purpose: CodSpeed integration for tinybench framework
- Key files:
src/index.ts- Main plugin implementation withwithCodSpeed()functiontests/index.integ.test.ts- Integration testsbenches/- Benchmark examples
- Purpose: CodSpeed integration for benchmark.js framework
- Key files:
src/index.ts- Main plugin implementationsrc/buildSuiteAdd.ts- Suite building utilities
- Purpose: CodSpeed integration for Vitest framework
- Key files:
src/index.ts- Main plugin implementationsrc/runner.ts- Custom test runnersrc/globalSetup.ts- Global setup configuration
with-javascript-cjs/- CommonJS JavaScript exampleswith-javascript-esm/- ESM JavaScript exampleswith-typescript-cjs/- CommonJS TypeScript exampleswith-typescript-esm/- ESM TypeScript exampleswith-typescript-simple-cjs/- Simple CommonJS TypeScript exampleswith-typescript-simple-esm/- Simple ESM TypeScript examples
The tinybench plugin currently has limited stats exposure:
- No direct stats API: The
withCodSpeed()function wraps a tinybench instance but doesn't expose measurement results - Console-only output: Results are only printed to console via
console.log() - Core measurement: Uses
@codspeed/corefor actual measurement via:mongoMeasurement.start(uri)/mongoMeasurement.stop(uri)Measurement.startInstrumentation()/Measurement.stopInstrumentation(uri)
- User calls
withCodSpeed(new Bench())to wrap their tinybench instance - Plugin intercepts
bench.run()to add CodSpeed instrumentation - Each benchmark task runs with measurement instrumentation
- Results are logged to console but not returned as structured data
withCodSpeed(bench: Bench): Bench- Main wrapper functionsetupInstruments(body)- Dynamic instrument setupgetCallingFile()- Helper to generate unique URIs for benchmarks
Based on the codebase analysis, to add stats access features:
- Extend return value: Modify
bench.run()to return structured measurement data - Add stats methods: Add methods like
getStats(),getResults(),getLastRunStats() - Integrate with core: Leverage
@codspeed/coremeasurement data - Maintain tinybench compatibility: Ensure existing
bench.table()still works
- Use pnpm instead of npm
- To run tests in a package use moon :test