From 67fe4557e5225f5be1687aca3d1934ad1141a684 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 17 Sep 2015 22:08:49 +0200 Subject: Fix read benchmark --- main_test.go | 20 ++++++++++++++++++++ pathfs_frontend/fs.go | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/main_test.go b/main_test.go index 6157e5a..0dfa06a 100644 --- a/main_test.go +++ b/main_test.go @@ -129,11 +129,30 @@ func BenchmarkStreamWrite(t *testing.B) { t.FailNow() } } + file.Close() } func BenchmarkStreamRead(t *testing.B) { buf := make([]byte, 1024*1024) t.SetBytes(int64(len(buf))) + + if t.N > 100 { + // Grow file so we can satisfy the test + f2, err := os.OpenFile(plainDir + "BenchmarkWrite", os.O_WRONLY | os.O_APPEND, 0666) + if err != nil { + fmt.Println(err) + t.FailNow() + } + for h := 0; h < t.N - 100 ; h++ { + _, err = f2.Write(buf) + if err != nil { + fmt.Println(err) + t.FailNow() + } + } + f2.Close() + } + file, err := os.Open(plainDir + "BenchmarkWrite") if err != nil { t.FailNow() @@ -150,4 +169,5 @@ func BenchmarkStreamRead(t *testing.B) { t.FailNow() } } + file.Close() } diff --git a/pathfs_frontend/fs.go b/pathfs_frontend/fs.go index bf93766..2ae066f 100644 --- a/pathfs_frontend/fs.go +++ b/pathfs_frontend/fs.go @@ -38,7 +38,7 @@ func (fs *FS) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Stat cName := fs.EncryptPath(name) a, status := fs.FileSystem.GetAttr(cName, context) if a == nil { - cryptfs.Notice.Printf("FS.GetAttr failed: %s\n", status.String()) + cryptfs.Debug.Printf("FS.GetAttr failed: %s\n", status.String()) return a, status } if a.IsRegular() { -- cgit v1.2.3