2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-25 22:27:35 +00:00

Add benchmark for NodeFromFileInfo

This commit is contained in:
Alexander Neumann 2015-05-02 00:26:32 +02:00
parent 9308f1493d
commit ccdbc80d5b

View File

@ -7,6 +7,7 @@ import (
func BenchmarkNodeFillUser(t *testing.B) { func BenchmarkNodeFillUser(t *testing.B) {
tempfile, err := ioutil.TempFile("", "restic-test-temp-") tempfile, err := ioutil.TempFile("", "restic-test-temp-")
defer tempfile.Close()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -25,3 +26,27 @@ func BenchmarkNodeFillUser(t *testing.B) {
node.fillExtra(path, fi) 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)
}
}
}