uint256: Add bitwise not 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 ----------------------------------------------------------------- Not 25.4ns ± 2% 3.3ns ± 2% -86.79% (p=0.000 n=10+10) name old allocs/op new allocs/op delta -------------------------------------------------------- Not 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
a42b8c89bf
commit
3ce3e33056
@ -1016,3 +1016,35 @@ func BenchmarkBigIntRsh(b *testing.B) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkUint256Not benchmarks computing the bitwise not of an unsigned
|
||||
// 256-bit integer with the specialized type.
|
||||
func BenchmarkUint256Not(b *testing.B) {
|
||||
n := new(Uint256)
|
||||
vals := randBenchVals
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i += len(vals) {
|
||||
for j := 0; j < len(vals); j++ {
|
||||
n.Set(vals[j].n1)
|
||||
n.Not()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkBigIntNot benchmarks computing the bitwise not of an unsigned
|
||||
// 256-bit integer with stdlib big integers.
|
||||
func BenchmarkBigIntNot(b *testing.B) {
|
||||
n := new(big.Int)
|
||||
vals := randBenchVals
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i += len(vals) {
|
||||
for j := 0; j < len(vals); j++ {
|
||||
n.Set(vals[j].bigN1) // For fair comparison.
|
||||
n.Not(n)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user