feat(bench): add ORM showdown benchmark harness#29
Conversation
Greptile SummaryThis PR introduces a new benchmark harness at Key changes and observations:
Confidence Score: 4/5Safe to merge after addressing the GORM pre-allocation inconsistency, which currently inflates GORM's allocs/op numbers across five workloads. The two previously flagged P1 issues (prepared statement per iteration, and ORM builder bypass) are both resolved. One new P1 remains: GORM's missing slice pre-allocation will systematically overstate its allocation cost relative to Bun and Rain in all slice-returning workloads. The fix is a one-line change per affected method. benchmarks/ormshowdown/harness_test.go — specifically the five GORM adapter methods that use Important Files Changed
|
Motivation
database/sqlon identical schema, dataset sizes, and workloads.benchstat.Description
benchmarks/ormshowdown/harness_test.gothat defines a canonical schema (users,categories,posts), deterministic seeding, and a standardized set of workloads run for each adapter (insert single, lookup by PK, filtered slice scan, join scan, grouped aggregate, subquery/join report, eager-load equivalent, prepared lookup).raw(database/sql),rain(native),bun,gorm, and placeholders forsqlc/entimplemented as nearest-equivalent typed layers to preserve SQL shape parity.benchmarks/ormshowdown/README.md(examples such asgo test -run '^$' -bench . -benchmem ./benchmarks/ormshowdown/... > before.txt).bench-ormshowdownto theMakefileand add Bun/GORM (and related) dependencies togo.mod/go.sumso the harness builds and runs.Testing
make fmt,make lint, andmake test, all of which completed successfully.go test ./benchmarks/ormshowdown -run '^$' -bench BenchmarkORMShowdown/raw/small/lookup_by_pk -benchtime=1xandgo test ./benchmarks/ormshowdown -run '^$' -bench BenchmarkORMShowdown/rain/small/prepared_point_lookup -benchtime=1xboth passed, andgo test ./benchmarks/ormshowdown -run '^$' -bench 'BenchmarkORMShowdown/(bun|gorm|sqlc|ent)/small/lookup_by_pk' -benchtime=1xproduced successful benchmark runs for Bun, GORM, SQLC-style and Ent-style adapters.Codex Task