MCPcopy Create free account
hub / github.com/DNAProject/DNA / BenchmarkZeroCopySource

Function BenchmarkZeroCopySource

common/zero_copy_source_test.go:32–48  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

30)
31
32func BenchmarkZeroCopySource(b *testing.B) {
33 const N = 12000
34 buf := make([]byte, N)
35 rand.Read(buf)
36
37 for i := 0; i < b.N; i++ {
38 source := NewZeroCopySource(buf)
39 for j := 0; j < N/100; j++ {
40 source.NextUint16()
41 source.NextByte()
42 source.NextUint64()
43 source.NextVarUint()
44 source.NextBytes(20)
45 }
46 }
47
48}
49
50func BenchmarkDerserialize(b *testing.B) {
51 const N = 12000

Callers

nothing calls this directly

Calls 6

NextUint16Method · 0.95
NextByteMethod · 0.95
NextUint64Method · 0.95
NextVarUintMethod · 0.95
NextBytesMethod · 0.95
NewZeroCopySourceFunction · 0.85

Tested by

no test coverage detected