mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
Add Benchmarks for Scanner and Archiver
This commit is contained in:
parent
9fcd23bd38
commit
869ba83c6d
1 changed files with 33 additions and 0 deletions
|
@ -2,6 +2,7 @@ package restic_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"flag"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -10,6 +11,8 @@ import (
|
||||||
"github.com/restic/restic/chunker"
|
"github.com/restic/restic/chunker"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var benchArchiveDirectory = flag.String("test.benchdir", "", "benchmark archiving a real directory")
|
||||||
|
|
||||||
func get_random(seed, count int) []byte {
|
func get_random(seed, count int) []byte {
|
||||||
buf := make([]byte, count)
|
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 a new issue