API Documentation
Overview
Section titled “Overview”modestbench provides a programmatic API for advanced usage and custom integrations. The API allows you to:
- Execute benchmarks programmatically
- Create custom reporters
- Integrate with your own tooling
- Build performance testing frameworks
Basic Usage
Section titled “Basic Usage”import { modestbench, HumanReporter } from 'modestbench';
// Initialize the engineconst engine = modestbench();
// Register reportersengine.registerReporter('human', new HumanReporter());
// Execute benchmarksconst result = await engine.execute({ pattern: '**/*.bench.js', iterations: 1000, warmup: 50, reporters: ['human'],});
// Process resultsif (result.summary.failedTasks > 0) { console.error('Some benchmarks failed'); process.exit(1);}
console.log(`Completed ${result.summary.totalTasks} benchmarks`);Exports
Section titled “Exports”The main package exports:
modestbench()- Create a benchmark engine instanceHumanReporter- Color-coded terminal reporter (TTY with colors)SimpleReporter- Plain text reporter (non-TTY environments)JsonReporter- Structured JSON output reporterCsvReporter- Tabular CSV output reporter- Type definitions for TypeScript
Future Documentation
Section titled “Future Documentation”This API reference will be expanded to include:
- Engine API - Complete engine methods and configuration
- Reporter Interface - Creating custom reporters
- Type Definitions - Full TypeScript type reference
- Advanced Usage - Custom integrations and extensions
Documentation will be generated using TypeDoc to ensure accuracy and completeness.
Current Status
Section titled “Current Status”The programmatic API is functional and used internally by the CLI. However, comprehensive documentation is still being developed.
For now, refer to:
- Getting Started - Basic usage patterns
- Advanced Usage - Complex scenarios
- Source Code - Implementation reference
Contributing
Section titled “Contributing”If you’d like to help with API documentation, please see our Contributing Guide.
Questions?
Section titled “Questions?”For questions about the API:
- Check GitHub Discussions
- Open an Issue for bugs or feature requests
- Review examples in the repository