Skip to content

Commit

Permalink
Merge pull request etcd-io#6602 from nekto0n/watchable_store_bench
Browse files Browse the repository at this point in the history
mvcc: add BenchmarkWatchableStoreTxnPut benchmark
  • Loading branch information
xiang90 authored Oct 7, 2016
2 parents e2bd6f2 + 9970ded commit 4e41400
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions mvcc/watchable_store_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4e41400

Please sign in to comment.