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

Function benchmarkUidPackEncode

codec/codec_test.go:251–270  ·  view source on GitHub ↗
(b *testing.B, blockSize int)

Source from the content-addressed store, hash-verified

249}
250
251func benchmarkUidPackEncode(b *testing.B, blockSize int) {
252 uids := getUids(1e6)
253 sz := uint64(len(uids)) * 8
254 b.Logf("Dataset Len=%d. Size: %s", len(uids), humanize.Bytes(sz))
255 b.ResetTimer()
256
257 var data []byte
258 for i := 0; i < b.N; i++ {
259 pack := Encode(uids, blockSize)
260 out, err := proto.Marshal(pack)
261 FreePack(pack)
262 if err != nil {
263 b.Fatalf("Error marshaling uid pack: %s", err.Error())
264 }
265 data = out
266 }
267 b.Logf("Output size: %s. Compression: %.2f",
268 humanize.Bytes(uint64(len(data))),
269 float64(len(data))/float64(sz))
270}
271
272func BenchmarkUidPack(b *testing.B) {
273 b.Run("encode/128", func(b *testing.B) {

Callers 1

BenchmarkUidPackFunction · 0.85

Calls 5

getUidsFunction · 0.85
EncodeFunction · 0.85
FreePackFunction · 0.85
FatalfMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected