mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #9796 from gyuho/watcher-benchmark
mvcc: separate synced/unsynced benchmarks
This commit is contained in:
commit
83abce0677
@ -65,9 +65,19 @@ func BenchmarkWatchableStoreTxnPut(b *testing.B) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BenchmarkWatchableStoreWatchSyncPut benchmarks the case of
|
// BenchmarkWatchableStoreWatchPutSync benchmarks the case of
|
||||||
// many synced watchers receiving a Put notification.
|
// many synced watchers receiving a Put notification.
|
||||||
func BenchmarkWatchableStoreWatchSyncPut(b *testing.B) {
|
func BenchmarkWatchableStoreWatchPutSync(b *testing.B) {
|
||||||
|
benchmarkWatchableStoreWatchPut(b, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BenchmarkWatchableStoreWatchPutUnsync benchmarks the case of
|
||||||
|
// many unsynced watchers receiving a Put notification.
|
||||||
|
func BenchmarkWatchableStoreWatchPutUnsync(b *testing.B) {
|
||||||
|
benchmarkWatchableStoreWatchPut(b, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func benchmarkWatchableStoreWatchPut(b *testing.B, synced bool) {
|
||||||
be, tmpPath := backend.NewDefaultTmpBackend()
|
be, tmpPath := backend.NewDefaultTmpBackend()
|
||||||
s := newWatchableStore(zap.NewExample(), be, &lease.FakeLessor{}, nil)
|
s := newWatchableStore(zap.NewExample(), be, &lease.FakeLessor{}, nil)
|
||||||
defer cleanup(s, be, tmpPath)
|
defer cleanup(s, be, tmpPath)
|
||||||
@ -75,12 +85,17 @@ func BenchmarkWatchableStoreWatchSyncPut(b *testing.B) {
|
|||||||
k := []byte("testkey")
|
k := []byte("testkey")
|
||||||
v := []byte("testval")
|
v := []byte("testval")
|
||||||
|
|
||||||
|
rev := int64(0)
|
||||||
|
if !synced {
|
||||||
|
// non-0 value to keep watchers in unsynced
|
||||||
|
rev = 1
|
||||||
|
}
|
||||||
|
|
||||||
w := s.NewWatchStream()
|
w := s.NewWatchStream()
|
||||||
defer w.Close()
|
defer w.Close()
|
||||||
watchIDs := make([]WatchID, b.N)
|
watchIDs := make([]WatchID, b.N)
|
||||||
for i := range watchIDs {
|
for i := range watchIDs {
|
||||||
// non-0 value to keep watchers in unsynced
|
watchIDs[i], _ = w.Watch(0, k, nil, rev)
|
||||||
watchIDs[i], _ = w.Watch(0, k, nil, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user