bench-proto/¶
Early benchmark exploration using Tinybench. This component tests benchmarking libraries and approaches before the main React application is scaffolded.
Purpose¶
bench-proto/ serves as a sandbox for:
- Testing Tinybench as a potential benchmarking engine
- Exploring bun:sqlite for result storage
- Understanding browser benchmark methodology
- Informing library choices for the main React app
Early Stage
This is very early exploration. The benchmark library (Tinybench) is not final. Other libraries may be evaluated before the main app is built.
Current State¶
| Property | Value |
|---|---|
| Status | Early exploration |
| Runtime | Bun |
| Benchmark engine | Tinybench v6.0.1 |
| Storage | bun:sqlite (planned) |
| ML integration | Not yet implemented |
What's been explored¶
Tinybench API¶
import { Bench } from 'tinybench'
const bench = new Bench({ time: 1000 })
bench
.add('faster task', () => { /* ... */ })
.add('slower task', async () => { /* ... */ })
await bench.run()
console.table(bench.table())
Key findings¶
- Tinybench provides latency/throughput statistics (mean, median, p99, etc.)
- Supports async tasks and lifecycle hooks (beforeAll, afterAll)
- Lightweight (~10KB) with no dependencies
- Good integration with browser and Node.js environments
Planned improvements¶
- Test alternative benchmark libraries (benchmark.js, mitata)
- Integrate ML runtime adapters
- Add model load time measurement
- Implement result storage with bun:sqlite
- Create browser UI for running benchmarks
How to Run¶
Then open http://localhost:3456.
File structure¶
bench-proto/
├── index.html Browser benchmark UI
├── server.ts Bun static server
├── tinybench.js Benchmark script example
├── PLAN.md Implementation plan (now research/archive/plans/)
├── BRAINSTORM.md Design discussions (now research/archive/plans/)
├── package.json Dependencies
└── README.md Documentation
Library evaluation criteria¶
When evaluating benchmark libraries for the main app:
| Criterion | Weight | Notes |
|---|---|---|
| Browser support | High | Must work in Chrome, Firefox, Safari |
| Async task support | High | ML inference is async |
| Statistics output | High | Need mean, median, p99, std dev |
| Lifecycle hooks | Medium | beforeAll/afterAll for model load/unload |
| Bundle size | Low | Not critical for benchmark app |
| Maintenance | Medium | Active development, good docs |
Connection to thesis¶
The benchmark exploration in bench-proto/ informs:
- Chapter 3 (Methodology): Measurement procedure and iteration strategy
- Chapter 3a (Implementation): Metrics collection design
- Appendix: Benchmark result schema