(b *testing.B)
| 1754 | } |
| 1755 | |
| 1756 | func 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 |
| 1785 | func createThenRemoveFromRevCache(t *testing.T, ctx context.Context, docID string, db *Database, collection *DatabaseCollectionWithUser) DocVersion { |
nothing calls this directly
no test coverage detected