(b *testing.B)
| 1314 | } |
| 1315 | |
| 1316 | func BenchmarkDeltaSyncSingleClientCachePopulation(b *testing.B) { |
| 1317 | if !base.IsEnterpriseEdition() { |
| 1318 | b.Skip("Delta sync only supported in EE") |
| 1319 | } |
| 1320 | |
| 1321 | tests := []struct { |
| 1322 | name string |
| 1323 | docSize int |
| 1324 | }{ |
| 1325 | { |
| 1326 | name: "100KBDoc", |
| 1327 | docSize: 100 * 1024, |
| 1328 | }, |
| 1329 | //{ |
| 1330 | // name: "5MBDoc", |
| 1331 | // docSize: 5 * 1024 * 1024, |
| 1332 | //}, |
| 1333 | } |
| 1334 | |
| 1335 | for _, test := range tests { |
| 1336 | b.Run(test.name, func(b *testing.B) { |
| 1337 | db, ctx := SetupTestDBWithOptions(b, DatabaseContextOptions{DeltaSyncOptions: DeltaSyncOptions{Enabled: true, RevMaxAgeSeconds: 300}}) |
| 1338 | defer db.Close(ctx) |
| 1339 | collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, b, db) |
| 1340 | |
| 1341 | // run benchmark over 1000 non-cached deltas since repeated invocations of b.Loop would hit the cache |
| 1342 | const numDocs = 1000 |
| 1343 | benchDocs := make([]struct{ docID, rev1, rev2 string }, 0, numDocs) |
| 1344 | for i := range numDocs { |
| 1345 | docID := fmt.Sprintf("%s_doc_%d", test.name, i) |
| 1346 | rev1, _, err := collection.Put(ctx, docID, Body{"foo": "bar", "bar": "buzz", "quux": strings.Repeat("a", test.docSize)}) |
| 1347 | require.NoError(b, err) |
| 1348 | rev2, _, err := collection.Put(ctx, docID, Body{"foo": "bar", "quux": strings.Repeat("b", test.docSize), BodyRev: rev1}) |
| 1349 | require.NoError(b, err) |
| 1350 | benchDocs = append(benchDocs, struct{ docID, rev1, rev2 string }{docID: docID, rev1: rev1, rev2: rev2}) |
| 1351 | } |
| 1352 | |
| 1353 | for b.Loop() { |
| 1354 | for _, doc := range benchDocs { |
| 1355 | _, _, _ = collection.GetDelta(ctx, doc.docID, doc.rev1, doc.rev2) |
| 1356 | } |
| 1357 | } |
| 1358 | }) |
| 1359 | } |
| 1360 | } |
| 1361 | |
| 1362 | // Test delta sync behavior when the fromRevision is a channel removal. |
| 1363 | func TestDeltaSyncWhenFromRevIsChannelRemoval(t *testing.T) { |
nothing calls this directly
no test coverage detected