howeyc / ledger

Command line double-entry accounting program
https://howeyc.github.io/ledger/
ISC License
461 stars 43 forks source link

Improve performance of ParseLedgerAsync #13

Closed bionoren closed 6 years ago

bionoren commented 6 years ago

This change significantly reduces the number of allocations during ledger parsing, requiring less garbage collection, and speeding up the application. As you can see below, this is approximately 3 times faster and performs 80% fewer allocations.

Before

go test -run=XXX -bench=. -benchmem ledger goos: darwin goarch: amd64 pkg: ledger BenchmarkParseLedger-8 100000 11386 ns/op 6376 B/op 29 allocs/op

After

go test -run=XXX -bench=. -benchmem ledger goos: darwin goarch: amd64 pkg: ledger BenchmarkParseLedger-8 300000 4305 ns/op 4336 B/op 6 allocs/op

howeyc commented 6 years ago

Thanks!