diff --git a/node_test.go b/node_test.go index e82b35a18..4b0acd309 100644 --- a/node_test.go +++ b/node_test.go @@ -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) + } + } +}