This script benchmarks the opencode-dotenv plugin performance.
bun benchmark.tsLatest benchmark results (averaged over 10 iterations):
| Test Case | Avg Time | Notes |
|---|---|---|
| No config (default) | ~0.12 ms | Baseline performance |
| Single .env file (3 vars) | ~0.09 ms | Typical use case |
| 5 .env files (10 vars total) | ~0.20 ms | Multiple configs |
| Large .env file (100 vars) | ~0.25 ms | Large projects |
| With logging enabled | ~0.10 ms | Minimal overhead |
| Subsequent calls (load guard) | ~0.06 ms | Instant return |
Key Findings:
- ✅ All operations complete in <0.3ms (lightning fast)
- ✅ Load guard reduces subsequent calls to ~0.06ms
- ✅ Logging adds minimal overhead (<0.02ms)
- ✅ Performance is sub-millisecond for all common use cases
- Warm-up: 3 iterations (not measured)
- Measured iterations: 10 (or 100 for load guard test)
- Environment: macOS with Bun runtime
- Precision: JavaScript
performance.now()API
- No config (default): Plugin with no configuration files
- Single .env file: One .env file with 3 variables
- Multiple files: 5 .env files with 10 total variables
- Large file: Single .env file with 100 variables
- With logging: Same as single file but with logging enabled
- Load guard: Subsequent calls after first initialization