Skip to content

Use apd primitives for faster comparisons#48

Merged
bojanz merged 3 commits intobojanz:mainfrom
bcremer:introduce-preallocated-zero-struct
Apr 23, 2026
Merged

Use apd primitives for faster comparisons#48
bojanz merged 3 commits intobojanz:mainfrom
bcremer:introduce-preallocated-zero-struct

Conversation

@bcremer
Copy link
Copy Markdown
Contributor

@bcremer bcremer commented Apr 22, 2026

before:

$ go test -bench='BenchmarkAmount_Is' -benchmem
goos: darwin
goarch: arm64
pkg: github.com/bojanz/currency
cpu: Apple M2 Max
BenchmarkAmount_IsPositive-12           187741496                6.244 ns/op           0 B/op          0 allocs/op
BenchmarkAmount_IsNegative-12           191502921                6.224 ns/op           0 B/op          0 allocs/op
BenchmarkAmount_IsZero-12               202620387                5.994 ns/op           0 B/op          0 allocs/op
PASS
ok      github.com/bojanz/currency      5.999s

after:

$ go test -bench='BenchmarkAmount_Is' -benchmem
goos: darwin
goarch: arm64
pkg: github.com/bojanz/currency
cpu: Apple M2 Max
BenchmarkAmount_IsPositive-12           620603521                1.753 ns/op           0 B/op          0 allocs/op
BenchmarkAmount_IsNegative-12           826252094                1.447 ns/op           0 B/op          0 allocs/op
BenchmarkAmount_IsZero-12               916716909                1.332 ns/op           0 B/op          0 allocs/op
PASS
ok      github.com/bojanz/currency      4.318s

@bcremer bcremer changed the title Introduce preallocated zeroDecimal for faster comparisons Use apd primitives for faster comparisons Apr 23, 2026
@bojanz bojanz merged commit f9b14ba into bojanz:main Apr 23, 2026
8 checks passed
@bojanz
Copy link
Copy Markdown
Owner

bojanz commented Apr 23, 2026

Great work, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants