Skip to content

Commit 791c584

Browse files
committed
consensus: add benchmarks for mmap with/with lock
1 parent 2b98d3c commit 791c584

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

consensus/ethash/algorithm_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,3 +787,28 @@ func BenchmarkHashimotoFullSmall(b *testing.B) {
787787
hashimotoFull(dataset, hash, 0)
788788
}
789789
}
790+
791+
func benchmarkHashimotoFullMmap(b *testing.B, name string, lock bool) {
792+
b.Run(name, func(b *testing.B) {
793+
tmpdir, err := ioutil.TempDir("", "ethash-test")
794+
if err != nil {
795+
b.Fatal(err)
796+
}
797+
defer os.RemoveAll(tmpdir)
798+
799+
d := &dataset{epoch: 0}
800+
d.generate(tmpdir, 1, lock, false)
801+
var hash [common.HashLength]byte
802+
b.ResetTimer()
803+
for i := 0; i < b.N; i++ {
804+
binary.PutVarint(hash[:], int64(i))
805+
hashimotoFull(d.dataset, hash[:], 0)
806+
}
807+
})
808+
}
809+
810+
// Benchmarks the full verification performance for mmap
811+
func BenchmarkHashimotoFullMmap(b *testing.B) {
812+
benchmarkHashimotoFullMmap(b, "WithLock", true)
813+
benchmarkHashimotoFullMmap(b, "WithoutLock", false)
814+
}

0 commit comments

Comments
 (0)