storage/filestore: benchmark diskInfoFromPath

Change-Id: I996057b1c650aec7cec84b49877d1e184a12514e
This commit is contained in:
Egon Elbre 2020-06-02 16:00:33 +03:00
parent 18914e4d1a
commit fca4f43a04

View File

@ -3,7 +3,11 @@
package filestore
import "testing"
import (
"fmt"
"os"
"testing"
)
func TestDiskInfoFromPath(t *testing.T) {
info, err := diskInfoFromPath(".")
@ -19,3 +23,18 @@ func TestDiskInfoFromPath(t *testing.T) {
t.Logf("Got: %v %v", info.ID, info.AvailableSpace)
}
func BenchmarkDiskInfoFromPath(b *testing.B) {
homedir, err := os.UserHomeDir()
if err != nil {
b.Fatal(err)
}
b.Run(fmt.Sprintf("dir=%q", homedir), func(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err = diskInfoFromPath(homedir)
if err != nil {
b.Fatal(err)
}
}
})
}