Add benchmark for NodeFromFileInfo

This commit is contained in:
Alexander Neumann 2015-05-02 00:26:32 +02:00
parent 9308f1493d
commit ccdbc80d5b
1 changed files with 25 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
func BenchmarkNodeFillUser(t *testing.B) {
tempfile, err := ioutil.TempFile("", "restic-test-temp-")
defer tempfile.Close()
if err != nil {
t.Fatal(err)
}
@ -25,3 +26,27 @@ func BenchmarkNodeFillUser(t *testing.B) {
node.fillExtra(path, fi)
}
}
func BenchmarkNodeFromFileInfo(t *testing.B) {
tempfile, err := ioutil.TempFile("", "restic-test-temp-")
defer tempfile.Close()
if err != nil {
t.Fatal(err)
}
fi, err := tempfile.Stat()
if err != nil {
t.Fatal(err)
}
path := tempfile.Name()
t.ResetTimer()
for i := 0; i < t.N; i++ {
_, err := NodeFromFileInfo(path, fi)
if err != nil {
t.Fatal(err)
}
}
}