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

Function buildTestTree

query/outputnode_test.go:185–205  ·  view source on GitHub ↗
(b *testing.B, enc *encoder, level, maxlevel int, fj fastJsonNode)

Source from the content-addressed store, hash-verified

183)
184
185func buildTestTree(b *testing.B, enc *encoder, level, maxlevel int, fj fastJsonNode) {
186 if level >= maxlevel {
187 return
188 }
189
190 // Add only two children for now.
191 for range 2 {
192 var ch fastJsonNode
193 if level == maxlevel-1 {
194 val, err := valToBytes(testVal)
195 x.Panic(err)
196
197 ch, err = enc.makeScalarNode(enc.idForAttr(testAttr), val, false)
198 require.NoError(b, err)
199 } else {
200 ch := enc.newNode(enc.idForAttr(testAttr))
201 buildTestTree(b, enc, level+1, maxlevel, ch)
202 }
203 enc.appendAttrs(fj, ch)
204 }
205}
206
207func BenchmarkFastJsonNode2Chilren(b *testing.B) {
208 for i := 0; i < b.N; i++ {

Callers 1

Calls 6

PanicFunction · 0.92
valToBytesFunction · 0.85
makeScalarNodeMethod · 0.80
idForAttrMethod · 0.80
newNodeMethod · 0.80
appendAttrsMethod · 0.80

Tested by

no test coverage detected