mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #6602 from nekto0n/watchable_store_bench
mvcc: add BenchmarkWatchableStoreTxnPut benchmark
This commit is contained in:
@@ -34,11 +34,37 @@ func BenchmarkWatchableStorePut(b *testing.B) {
|
||||
vals := createBytesSlice(bytesN, b.N)
|
||||
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
s.Put(keys[i], vals[i], lease.NoLease)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkWatchableStoreTxnPut benchmarks the Put operation
|
||||
// with transaction begin and end, where transaction involves
|
||||
// some synchronization operations, such as mutex locking.
|
||||
func BenchmarkWatchableStoreTxnPut(b *testing.B) {
|
||||
var i fakeConsistentIndex
|
||||
be, tmpPath := backend.NewDefaultTmpBackend()
|
||||
s := New(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)
|
||||
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkWatchableStoreWatchSyncPut benchmarks the case of
|
||||
// many synced watchers receiving a Put notification.
|
||||
func BenchmarkWatchableStoreWatchSyncPut(b *testing.B) {
|
||||
|
||||
Reference in New Issue
Block a user