MCPcopy
hub / github.com/dgraph-io/dgraph / BenchmarkXidmapReadsRandom

Function BenchmarkXidmapReadsRandom

xidmap/xidmap_test.go:218–241  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

216}
217
218func BenchmarkXidmapReadsRandom(b *testing.B) {
219 conn, err := x.SetupConnection(testutil.GetSockAddrZero(), nil, false)
220 if err != nil {
221 b.Fatalf("Error setting up connection: %s", err.Error())
222 }
223
224 var N = 1000000
225 buf := make([]byte, 32)
226 var list [][]byte
227 xidmap := New(getTestXidmapOpts(conn, nil))
228 defer xidmap.Flush()
229 for i := 0; i < N; i++ {
230 rand.Read(buf)
231 list = append(list, buf)
232 xidmap.AssignUid(string(buf))
233 }
234 b.ResetTimer()
235
236 b.RunParallel(func(pb *testing.PB) {
237 for pb.Next() {
238 xidmap.AssignUid(string(list[rand.Intn(len(list))]))
239 }
240 })
241}

Callers

nothing calls this directly

Calls 10

SetupConnectionFunction · 0.92
GetSockAddrZeroFunction · 0.92
getTestXidmapOptsFunction · 0.85
FatalfMethod · 0.80
AssignUidMethod · 0.80
NewFunction · 0.70
FlushMethod · 0.65
ReadMethod · 0.65
ErrorMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected