MCPcopy
hub / github.com/tinylib/msgp / BenchmarkFastEncode

Function BenchmarkFastEncode

_generated/gen_test.go:17–34  ·  view source on GitHub ↗

benchmark encoding a small, "fast" type. the point here is to see how much garbage is generated intrinsically by the encoding/ decoding process as opposed to the nature of the struct.

(b *testing.B)

Source from the content-addressed store, hash-verified

15// decoding process as opposed to the nature
16// of the struct.
17func BenchmarkFastEncode(b *testing.B) {
18 v := &TestFast{
19 Lat: 40.12398,
20 Long: -41.9082,
21 Alt: 201.08290,
22 Data: []byte("whaaaaargharbl"),
23 }
24 var buf bytes.Buffer
25 msgp.Encode(&buf, v)
26 en := msgp.NewWriter(msgp.Nowhere)
27 b.SetBytes(int64(buf.Len()))
28 b.ReportAllocs()
29 b.ResetTimer()
30 for i := 0; i < b.N; i++ {
31 v.EncodeMsg(en)
32 }
33 en.Flush()
34}
35
36// benchmark decoding a small, "fast" type.
37// the point here is to see how much garbage

Callers

nothing calls this directly

Calls 5

FlushMethod · 0.95
EncodeFunction · 0.92
NewWriterFunction · 0.92
LenMethod · 0.65
EncodeMsgMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…