mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
consensus: add benchmarks for mmap with/with lock
This commit is contained in:
parent
2b98d3c22c
commit
791c584042
1 changed files with 25 additions and 0 deletions
|
|
@ -787,3 +787,28 @@ func BenchmarkHashimotoFullSmall(b *testing.B) {
|
||||||
hashimotoFull(dataset, hash, 0)
|
hashimotoFull(dataset, hash, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func benchmarkHashimotoFullMmap(b *testing.B, name string, lock bool) {
|
||||||
|
b.Run(name, func(b *testing.B) {
|
||||||
|
tmpdir, err := ioutil.TempDir("", "ethash-test")
|
||||||
|
if err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
|
d := &dataset{epoch: 0}
|
||||||
|
d.generate(tmpdir, 1, lock, false)
|
||||||
|
var hash [common.HashLength]byte
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
binary.PutVarint(hash[:], int64(i))
|
||||||
|
hashimotoFull(d.dataset, hash[:], 0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Benchmarks the full verification performance for mmap
|
||||||
|
func BenchmarkHashimotoFullMmap(b *testing.B) {
|
||||||
|
benchmarkHashimotoFullMmap(b, "WithLock", true)
|
||||||
|
benchmarkHashimotoFullMmap(b, "WithoutLock", false)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue