forked from TrueCloudLab/restic
Add BenchmarkLoadIndex
This commit is contained in:
parent
e463587bad
commit
73e7a2bea8
1 changed files with 27 additions and 4 deletions
|
@ -246,15 +246,38 @@ func TestRepositoryLoadIndex(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkLoadIndex(b *testing.B) {
|
func BenchmarkLoadIndex(b *testing.B) {
|
||||||
repodir, cleanup := Env(b, repoFixture)
|
repository.TestUseLowSecurityKDFParameters(b)
|
||||||
|
|
||||||
|
repo, cleanup := repository.TestRepository(b)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
repo := repository.TestOpenLocal(b, repodir)
|
idx := repository.NewIndex()
|
||||||
|
|
||||||
|
for i := 0; i < 5000; i++ {
|
||||||
|
idx.Store(restic.PackedBlob{
|
||||||
|
Blob: restic.Blob{
|
||||||
|
Type: restic.DataBlob,
|
||||||
|
Length: 1234,
|
||||||
|
ID: restic.NewRandomID(),
|
||||||
|
Offset: 1235,
|
||||||
|
},
|
||||||
|
PackID: restic.NewRandomID(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
id, err := repository.SaveIndex(repo, idx)
|
||||||
|
OK(b, err)
|
||||||
|
|
||||||
|
b.Logf("index saved as %v (%v entries)", id.Str(), idx.Count(restic.DataBlob))
|
||||||
|
fi, err := repo.Backend().Stat(restic.Handle{Type: restic.IndexFile, Name: id.String()})
|
||||||
|
OK(b, err)
|
||||||
|
b.Logf("filesize is %v", fi.Size)
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
repo.SetIndex(repository.NewMasterIndex())
|
_, err := repository.LoadIndex(repo, id)
|
||||||
OK(b, repo.LoadIndex())
|
OK(b, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue