MCPcopy Create free account
hub / github.com/dgraph-io/dgraph-benchmarks / BenchmarkCopyOnWrite

Function BenchmarkCopyOnWrite

bitmap/main_test.go:240–264  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

238}
239
240func BenchmarkCopyOnWrite(b *testing.B) {
241 bm := newBitmap()
242 max := int64(1000000) * 1000
243 b.Logf("Running with N = %d\n", b.N)
244 b.Logf("Copy on write: %v\n", bm.GetCopyOnWrite())
245
246 // Takes 345 ns/op.
247 b.Run("copy-on-write-false", func(b *testing.B) {
248 bm.SetCopyOnWrite(false)
249 b.Logf("Copy on write: %v\n", bm.GetCopyOnWrite())
250
251 for i := 0; i < b.N; i++ {
252 bm.Add(uint64(rand.Int63n(max)))
253 }
254 })
255 // Takes 524ns/op.
256 b.Run("copy-on-write-true", func(b *testing.B) {
257 // Copy on write does an extra copy which takes time.
258 bm.SetCopyOnWrite(true)
259 b.Logf("Copy on write: %v\n", bm.GetCopyOnWrite())
260 for i := 0; i < b.N; i++ {
261 bm.Add(uint64(rand.Int63n(max)))
262 }
263 })
264}
265
266// Bitmap runs in 177 ns/op.
267// List search in 252 ns/op.

Callers

nothing calls this directly

Calls 2

newBitmapFunction · 0.85
AddMethod · 0.80

Tested by

no test coverage detected