inomap: add benchmark

$ go test -bench=.
goos: linux
goarch: amd64
pkg: github.com/rfjakob/gocryptfs/internal/inomap
BenchmarkTranslateSingleDev-4   	202479382	         5.88 ns/op
BenchmarkTranslateManyDevs-4    	16095795	        71.9 ns/op
PASS
ok  	github.com/rfjakob/gocryptfs/internal/inomap	3.039s
This commit is contained in:
Jakob Unterwurzacher 2020-04-19 21:34:45 +02:00
parent 1c169ac55e
commit fcdeb52390

View File

@ -79,3 +79,22 @@ func TestTranslateStress(t *testing.T) {
t.Fail()
}
}
func BenchmarkTranslateSingleDev(b *testing.B) {
m := New(0)
var q QIno
for n := 0; n < b.N; n++ {
q.Ino = uint64(n % 1000)
m.Translate(q)
}
}
func BenchmarkTranslateManyDevs(b *testing.B) {
m := New(0)
var q QIno
for n := 0; n < b.N; n++ {
q.Dev = uint64(n % 10)
q.Ino = uint64(n % 1000)
m.Translate(q)
}
}