uint256: Add is odd benchmarks.
The following is a comparison between stdlib big integers (old) and the specialized type (new) averaging 10 runs each: name old time/op new time/op delta ------------------------------------------------------------------ IsOdd 3.62ns ± 4% 1.64ns ± 1% -54.65% (p=0.000 n=10+10) name old allocs/op new allocs/op delta --------------------------------------------------------- IsOdd 0.00 0.00 ~ (all equal) This is part of a series of commits to fully implement the uint256 package.
This commit is contained in:
parent
944a8889d6
commit
66e2409d9b
@ -257,6 +257,34 @@ func BenchmarkBigIntIsZero(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkUint256IsOdd benchmarks determining if an unsigned 256-bit integer
|
||||
// is odd with the specialized type.
|
||||
func BenchmarkUint256IsOdd(b *testing.B) {
|
||||
vals := randBenchVals
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i += len(vals) {
|
||||
for j := 0; j < len(vals); j++ {
|
||||
noElideBool = vals[j].n1.IsOdd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkBigIntIsOdd benchmarks determining if an unsigned 256-bit integer is
|
||||
// odd with stdlib big integers.
|
||||
func BenchmarkBigIntIsOdd(b *testing.B) {
|
||||
vals := randBenchVals
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i += len(vals) {
|
||||
for j := 0; j < len(vals); j++ {
|
||||
noElideBool = vals[j].bigN1.Bit(0) == 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkUint256Eq benchmarks determining equality between two unsigned
|
||||
// 256-bit integers with the specialized type.
|
||||
func BenchmarkUint256Eq(b *testing.B) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user