MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / BenchmarkRevisionCacheRead

Function BenchmarkRevisionCacheRead

db/revision_cache_test.go:1756–1782  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

1754}
1755
1756func BenchmarkRevisionCacheRead(b *testing.B) {
1757 base.SetUpBenchmarkLogging(b, base.LevelDebug, base.KeyAll)
1758
1759 cacheHitCounter, cacheMissCounter, getDocumentCounter, getRevisionCounter, cacheNumItems, memoryBytesCounted := base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{}, base.SgwIntStat{}
1760 backingStoreMap := CreateTestSingleBackingStoreMap(&testBackingStore{nil, &getDocumentCounter, &getRevisionCounter}, testCollectionID)
1761 cacheOptions := &RevisionCacheOptions{
1762 MaxItemCount: DefaultRevisionCacheSize,
1763 MaxBytes: 0,
1764 }
1765 cache := NewLRURevisionCache(cacheOptions, backingStoreMap, &cacheHitCounter, &cacheMissCounter, &cacheNumItems, &memoryBytesCounted)
1766
1767 ctx := base.TestCtx(b)
1768
1769 // trigger load into cache
1770 for i := 0; i < 5000; i++ {
1771 _, _ = cache.GetWithRev(ctx, fmt.Sprintf("doc%d", i), "1-abc", testCollectionID, RevCacheOmitDelta)
1772 }
1773
1774 b.ResetTimer()
1775 b.RunParallel(func(pb *testing.PB) {
1776 // GET the document until test run has completed
1777 for pb.Next() {
1778 docId := fmt.Sprintf("doc%d", rand.Intn(5000))
1779 _, _ = cache.GetWithRev(ctx, docId, "1-abc", testCollectionID, RevCacheOmitDelta)
1780 }
1781 })
1782}
1783
1784// createThenRemoveFromRevCache will create a doc and then immediately remove it from the rev cache
1785func createThenRemoveFromRevCache(t *testing.T, ctx context.Context, docID string, db *Database, collection *DatabaseCollectionWithUser) DocVersion {

Callers

nothing calls this directly

Calls 6

GetWithRevMethod · 0.95
SetUpBenchmarkLoggingFunction · 0.92
TestCtxFunction · 0.92
NewLRURevisionCacheFunction · 0.85
NextMethod · 0.45

Tested by

no test coverage detected