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

Function BenchmarkDerserialize

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

Source from the content-addressed store, hash-verified

48}
49
50func BenchmarkDerserialize(b *testing.B) {
51 const N = 12000
52 buf := make([]byte, N)
53 rand.Read(buf)
54
55 for i := 0; i < b.N; i++ {
56 reader := bytes.NewBuffer(buf)
57 for j := 0; j < N/100; j++ {
58 serialization.ReadUint16(reader)
59 serialization.ReadByte(reader)
60 serialization.ReadUint64(reader)
61 serialization.ReadVarUint(reader, 0)
62 serialization.ReadBytes(reader, 20)
63 }
64 }
65
66}
67
68func TestReadFromNil(t *testing.T) {
69 s := NewZeroCopySource(nil)

Callers

nothing calls this directly

Calls 5

ReadUint16Function · 0.92
ReadByteFunction · 0.92
ReadUint64Function · 0.92
ReadVarUintFunction · 0.92
ReadBytesFunction · 0.92

Tested by

no test coverage detected