From fcdeb52390b15b0d59015dbd238835b9a6f6b3ff Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 19 Apr 2020 21:34:45 +0200 Subject: 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 --- internal/inomap/inomap_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'internal') diff --git a/internal/inomap/inomap_test.go b/internal/inomap/inomap_test.go index 3c0ea7d..0349fd6 100644 --- a/internal/inomap/inomap_test.go +++ b/internal/inomap/inomap_test.go @@ -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) + } +} -- cgit v1.2.3