2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 12:55:18 +00:00

Add Benchmarks for Scanner and Archiver

This commit is contained in:
Alexander Neumann 2015-02-10 21:59:18 +01:00
parent 9fcd23bd38
commit 869ba83c6d

View File

@ -2,6 +2,7 @@ package restic_test
import (
"bytes"
"flag"
"io"
"math/rand"
"testing"
@ -10,6 +11,8 @@ import (
"github.com/restic/restic/chunker"
)
var benchArchiveDirectory = flag.String("test.benchdir", "", "benchmark archiving a real directory")
func get_random(seed, count int) []byte {
buf := make([]byte, count)
@ -117,3 +120,33 @@ 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")
}
be := setupBackend(b)
defer teardownBackend(b, be)
key := setupKey(b, be, "geheim")
server := restic.NewServerWithKey(be, key)
tree, err := restic.NewScanner(nil).Scan(*benchArchiveDirectory)
ok(b, err)
arch, err := restic.NewArchiver(server, nil)
ok(b, err)
_, id, err := arch.Snapshot(*benchArchiveDirectory, tree, nil)
b.Logf("snapshot archived as %v", id)
}