メインコンテンツまでスキップ

Performance Baseline

Benchmark results measured on Apple M4 Pro (darwin/arm64), Go 1.25, make bench.

Invoice Generation (application/service/)

Benchmarkns/opB/opallocs/op
GenerateInvoice_Subscription1,5272,94084
GenerateInvoice_UsageBased13,1142,84549
GenerateInvoice_WithPlugins (3 discount)2,0914,141120
GenerateInvoice_WithCredits (10 entries)1,5173,00485

Event Replay (domain/contract/)

Benchmarkns/opB/opallocs/op
LoadFromHistory_10Events9,2354,643111
LoadFromHistory_100Events69,18135,623786
LoadFromHistory_1000Events642,212345,4457,536
MarshalSnapshot1,9441,38618
LoadFromSnapshot4,5682,17755
LoadFromSnapshot_Then100Events68,63636,600805

Pricing Models (domain/pricing/)

Benchmarkns/opB/opallocs/op
FlatPrice_CalculatePrice0.2500
TieredPrice_Graduated_10Tiers3,2195,019232
TieredPrice_Volume_10Tiers24534419
UsagePrice_Simple12521610
UsagePrice_WithMinMax21240814

Credit Consumption (domain/balance/)

Benchmarkns/opB/opallocs/op
Consume_Sequential (100 ops)22,28743,2061,500
Consume_FullyConsumed19640011
IsExpired1.400

Plugin Dispatch (plugin/)

Benchmarkns/opB/opallocs/op
GetDiscountHooks_10Plugins (parallel)1472484
Register_Sequential (20 plugins)1,6363,65614
GetDiscountHooks_ConcurrentReadWrite7451,8774

Event Store & Repository (infrastructure/inmemory/)

Benchmarkns/opB/opallocs/op
EventStore_Append3695602
EventStore_Append_Batch101,4497,1206
EventStore_Load_100Events2,94020,4801
EventStore_SaveSnapshot725710
EventStore_LoadSnapshot31961
BalanceRepository_FindAvailable_100Entries1,6052,22410

How to Run

make bench                    # Run all benchmarks
make bench | grep Benchmark # Summary only

For statistical comparison, use benchstat:

go test -bench=. -benchmem -count=5 ./... > old.txt
# ... make changes ...
go test -bench=. -benchmem -count=5 ./... > new.txt
benchstat old.txt new.txt