mirror of
https://github.com/octoleo/restic.git
synced 2025-01-11 18:18:45 +00:00
Add Benchmark for IndexSave
This commit is contained in:
parent
d40f566e41
commit
36276c41b2
@ -4,6 +4,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"restic"
|
"restic"
|
||||||
"restic/repository"
|
"restic/repository"
|
||||||
|
"restic/test"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -135,6 +136,26 @@ func BenchmarkIndexNew(b *testing.B) {
|
|||||||
if idx == nil {
|
if idx == nil {
|
||||||
b.Fatalf("New() returned nil index")
|
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)
|
t.Errorf("removed blob %v found in index", h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// example index serialization from doc/Design.md
|
// example index serialization from doc/Design.md
|
||||||
|
Loading…
Reference in New Issue
Block a user