2015-05-01 21:52:36 +00:00
|
|
|
package restic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkNodeFillUser(t *testing.B) {
|
|
|
|
tempfile, err := ioutil.TempFile("", "restic-test-temp-")
|
2015-05-01 22:26:32 +00:00
|
|
|
defer tempfile.Close()
|
2015-05-01 21:52:36 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fi, err := tempfile.Stat()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
node := &Node{}
|
|
|
|
path := tempfile.Name()
|
|
|
|
|
|
|
|
t.ResetTimer()
|
|
|
|
|
|
|
|
for i := 0; i < t.N; i++ {
|
|
|
|
node.fillExtra(path, fi)
|
|
|
|
}
|
|
|
|
}
|
2015-05-01 22:26:32 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|