mirror of https://github.com/restic/restic.git
Add Benchmarks for Scanner and Archiver
This commit is contained in:
parent
9fcd23bd38
commit
869ba83c6d
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue