2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-03 17:40:53 +00:00

Add test and benchmark for Scanner

This commit is contained in:
Alexander Neumann 2015-02-16 23:13:23 +01:00
parent a5e13f1280
commit 0a164ad5e0
2 changed files with 29 additions and 9 deletions

View File

@ -121,15 +121,6 @@ func BenchmarkChunkEncryptParallel(b *testing.B) {
})
}
func BenchmarkScanner(b *testing.B) {
if *benchArchiveDirectory == "" {
b.Skip("benchdir not set, skipping BenchmarkScanner")
}
_, err := restic.NewScanner(nil).Scan(*benchArchiveDirectory)
ok(b, err)
}
func BenchmarkArchiveDirectory(b *testing.B) {
if *benchArchiveDirectory == "" {
b.Skip("benchdir not set, skipping BenchmarkArchiveDirectory")

29
scanner_test.go Normal file
View File

@ -0,0 +1,29 @@
package restic_test
import (
"flag"
"testing"
"github.com/restic/restic"
)
var scanDir = flag.String("test.scandir", ".", "test/benchmark scanning a real directory (default: .)")
func TestScanner(t *testing.T) {
sc := restic.NewScanner(nil)
tree, err := sc.Scan(*scanDir)
ok(t, err)
stats := tree.Stat()
assert(t, stats.Files > 0,
"no files in dir %v", *scanDir)
}
func BenchmarkScanner(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := restic.NewScanner(nil).Scan(*scanDir)
ok(b, err)
}
}