test: add memory benchmarks and leak detection
Add comprehensive memory benchmarking suite using OCaml's Gc module:
bench/mem_bench.ml - Benchmark infrastructure:
- Allocation tracking (minor/major words, GC counts)
- Leak detection via repeated runs with heap monitoring
- Pretty-printed benchmark results
bench/bench_sqlite.ml - SQLite memory benchmarks
bench/bench_postgresql.ml - PostgreSQL memory benchmarks
Benchmarks cover:
- CRUD operations (insert, query, update, delete)
- Transactions
- Query DSL operations
- Complex queries (joins, grouping)
Leak detection runs 50 rounds of 100 operations each,
monitoring heap and live word growth between rounds.
Results (no leaks detected):
- SQLite: 0 word growth across all operations
- PostgreSQL: 0 word growth across all operations
Run with:
dune exec bench/bench_sqlite.exe
dune exec bench/bench_postgresql.exe