use to determine whether it equals 0 or not. #299
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
r.Cmp(zeroInt) != 0 => r.Sign() != 0
func BenchmarkCmpZeroInt(b *testing.B) {
positiveVal := big.NewInt(314)
negtiveVal := big.NewInt(-314)
b.Run("cmpzero", func(b *testing.B) {
for i := 0; i < b.N; i++ {
zeroInt.Cmp(zeroInt)
}
})
}
goos: darwin
goarch: amd64
pkg: github.com/shopspring/decimal
cpu: Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
BenchmarkCmpZeroInt
BenchmarkCmpZeroInt/cmpzero
BenchmarkCmpZeroInt/cmpzero-8 729437467 1.714 ns/op 0 B/op 0 allocs/op
BenchmarkCmpZeroInt/cmppositive
BenchmarkCmpZeroInt/cmppositive-8 240192255 5.657 ns/op 0 B/op 0 allocs/op
BenchmarkCmpZeroInt/cmpnegtive
BenchmarkCmpZeroInt/cmpnegtive-8 463588371 2.386 ns/op 0 B/op 0 allocs/op
BenchmarkCmpZeroInt/signzero
BenchmarkCmpZeroInt/signzero-8 1000000000 0.4847 ns/op 0 B/op 0 allocs/op
BenchmarkCmpZeroInt/signpositive
BenchmarkCmpZeroInt/signpositive-8 1000000000 0.5291 ns/op 0 B/op 0 allocs/op
BenchmarkCmpZeroInt/signnegtive
BenchmarkCmpZeroInt/signnegtive-8 1000000000 0.5308 ns/op 0 B/op 0 allocs/op