forked from TrueCloudLab/restic
tests: Add benchmark for Save
This commit is contained in:
parent
8fc25cc567
commit
5b8131e2d3
2 changed files with 30 additions and 0 deletions
|
@ -144,3 +144,32 @@ func BackendBenchmarkLoadPartialFileOffset(t *testing.B, s *Suite) {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
func BackendBenchmarkSave(t *testing.B, s *Suite) {
|
||||
be := s.open(t)
|
||||
defer s.close(t, be)
|
||||
|
||||
length := 1<<24 + 2123
|
||||
data := test.Random(23, length)
|
||||
id := restic.Hash(data)
|
||||
handle := restic.Handle{Type: restic.DataFile, Name: id.String()}
|
||||
|
||||
rd := bytes.NewReader(data)
|
||||
|
||||
t.SetBytes(int64(length))
|
||||
t.ResetTimer()
|
||||
|
||||
for i := 0; i < t.N; i++ {
|
||||
if _, err := rd.Seek(0, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := be.Save(handle, rd); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := be.Remove(handle); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,5 @@ var benchmarkFunctions = []struct {
|
|||
{"LoadFile", BackendBenchmarkLoadFile},
|
||||
{"LoadPartialFile", BackendBenchmarkLoadPartialFile},
|
||||
{"LoadPartialFileOffset", BackendBenchmarkLoadPartialFileOffset},
|
||||
{"Save", BackendBenchmarkSave},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue