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

Function BenchmarkDatabase

db/database_test.go:3149–3167  ·  view source on GitHub ↗

BENCHMARKS

(b *testing.B)

Source from the content-addressed store, hash-verified

3147// ////// BENCHMARKS
3148
3149func BenchmarkDatabase(b *testing.B) {
3150 base.DisableTestLogging(b)
3151
3152 for i := 0; i < b.N; i++ {
3153 ctx := base.TestCtx(b)
3154 bucket, _ := ConnectToBucket(ctx, base.BucketSpec{
3155 Server: base.UnitTestUrl(),
3156 BucketName: fmt.Sprintf("b-%d", i)},
3157 true)
3158 dbCtx, _ := NewDatabaseContext(ctx, "db", bucket, false, DatabaseContextOptions{})
3159 db, _ := CreateDatabase(dbCtx)
3160 collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, b, db)
3161
3162 body := Body{"key1": "value1", "key2": 1234}
3163 _, _, _ = collection.Put(ctx, fmt.Sprintf("doc%d", i), body)
3164
3165 db.Close(ctx)
3166 }
3167}
3168
3169func BenchmarkPut(b *testing.B) {
3170 base.DisableTestLogging(b)

Callers

nothing calls this directly

Calls 9

DisableTestLoggingFunction · 0.92
TestCtxFunction · 0.92
UnitTestUrlFunction · 0.92
ConnectToBucketFunction · 0.85
NewDatabaseContextFunction · 0.85
CreateDatabaseFunction · 0.85
PutMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected