Browse Source

mvcc: benchmark ConsistentIndex

Anthony Romano 8 years ago
parent
commit
ac4855e911
1 changed files with 18 additions and 0 deletions
  1. 18 0
      mvcc/kvstore_bench_test.go

+ 18 - 0
mvcc/kvstore_bench_test.go

@@ -45,6 +45,24 @@ func BenchmarkStorePut(b *testing.B) {
 	}
 }
 
+func BenchmarkConsistentIndex(b *testing.B) {
+	fci := fakeConsistentIndex(10)
+	be, tmpPath := backend.NewDefaultTmpBackend()
+	s := NewStore(be, &lease.FakeLessor{}, &fci)
+	defer cleanup(s, be, tmpPath)
+
+	tx := s.b.BatchTx()
+	tx.Lock()
+	s.saveIndex(tx)
+	tx.Unlock()
+
+	b.ReportAllocs()
+	b.ResetTimer()
+	for i := 0; i < b.N; i++ {
+		s.ConsistentIndex()
+	}
+}
+
 // BenchmarkStoreTxnPutUpdate is same as above, but instead updates single key
 func BenchmarkStorePutUpdate(b *testing.B) {
 	var i fakeConsistentIndex