primitives: Add work calc benchmark.
The following is a comparison between the existing implementation in the blockchain/standalone module with big integers (old) and the new implementation (new) averaging 10 runs each: name old time/op new time/op delta --------------------------------------------------------------------- CalcWork 638ns ± 1% 59ns ± 1% -90.78% (p=0.000 n=10+10) name old allocs/op new allocs/op delta ---------------------------------------------------------------------- CalcWork 7.00 ± 0% 0.00 -100.00% (p=0.000 n=10+10)
This commit is contained in:
parent
ecf6c6313e
commit
44204ac2ff
@ -30,3 +30,13 @@ func BenchmarkUint256ToDiffBits(b *testing.B) {
|
||||
Uint256ToDiffBits(n)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkCalcWork benchmarks calculating a work value from difficulty bits.
|
||||
func BenchmarkCalcWork(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
const input = 0x1b01330e
|
||||
CalcWork(input)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user