mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
mvcc : Added benchmark for store.resotre
This commit is contained in:
parent
f014cca644
commit
aa2b5aec1b
@ -463,6 +463,7 @@ func (s *store) restore() error {
|
|||||||
scheduledCompact = 0
|
scheduledCompact = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Unlock()
|
tx.Unlock()
|
||||||
|
|
||||||
if scheduledCompact != 0 {
|
if scheduledCompact != 0 {
|
||||||
|
@ -85,3 +85,40 @@ func BenchmarkStoreTxnPut(b *testing.B) {
|
|||||||
s.TxnEnd(id)
|
s.TxnEnd(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// benchmarkStoreRestore benchmarks the restore operation
|
||||||
|
func benchmarkStoreRestore(revsPerKey int, b *testing.B) {
|
||||||
|
var i fakeConsistentIndex
|
||||||
|
be, tmpPath := backend.NewDefaultTmpBackend()
|
||||||
|
s := NewStore(be, &lease.FakeLessor{}, &i)
|
||||||
|
defer cleanup(s, be, tmpPath)
|
||||||
|
|
||||||
|
// arbitrary number of bytes
|
||||||
|
bytesN := 64
|
||||||
|
keys := createBytesSlice(bytesN, b.N)
|
||||||
|
vals := createBytesSlice(bytesN, b.N)
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
for j := 0; j < revsPerKey; j++ {
|
||||||
|
id := s.TxnBegin()
|
||||||
|
if _, err := s.TxnPut(id, keys[i], vals[i], lease.NoLease); err != nil {
|
||||||
|
plog.Fatalf("txn put error: %v", err)
|
||||||
|
}
|
||||||
|
s.TxnEnd(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
b.ResetTimer()
|
||||||
|
s = NewStore(be, &lease.FakeLessor{}, &i)
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkStoreRestoreRevs1(b *testing.B) {
|
||||||
|
benchmarkStoreRestore(1, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkStoreRestoreRevs10(b *testing.B) {
|
||||||
|
benchmarkStoreRestore(10, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkStoreRestoreRevs20(b *testing.B) {
|
||||||
|
benchmarkStoreRestore(20, b)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user