Add Benchmark for IndexSave

This commit is contained in:
Alexander Neumann 2017-01-15 16:16:09 +01:00
parent d40f566e41
commit 36276c41b2

View file

@ -4,6 +4,7 @@ import (
"math/rand"
"restic"
"restic/repository"
"restic/test"
"testing"
"time"
)
@ -135,6 +136,26 @@ func BenchmarkIndexNew(b *testing.B) {
if idx == nil {
b.Fatalf("New() returned nil index")
}
b.Logf("idx %v packs", len(idx.Packs))
}
}
func BenchmarkIndexSave(b *testing.B) {
repo, cleanup := createFilledRepo(b, 3, 0)
defer cleanup()
idx, err := New(repo, nil)
test.OK(b, err)
b.ResetTimer()
for i := 0; i < b.N; i++ {
id, err := idx.Save(repo, nil)
if err != nil {
b.Fatalf("New() returned error %v", err)
}
b.Logf("saved as %v", id.Str())
}
}
@ -250,7 +271,6 @@ func TestIndexAddRemovePack(t *testing.T) {
t.Errorf("removed blob %v found in index", h)
}
}
}
// example index serialization from doc/Design.md