MCPcopy
hub / github.com/rs/zerolog / BenchmarkAppendBytes

Function BenchmarkAppendBytes

internal/json/bytes_test.go:67–86  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

65}
66
67func BenchmarkAppendBytes(b *testing.B) {
68 tests := map[string]string{
69 "NoEncoding": `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`,
70 "EncodingFirst": `"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`,
71 "EncodingMiddle": `aaaaaaaaaaaaaaaaaaaaaaaaa"aaaaaaaaaaaaaaaaaaaaaaaa`,
72 "EncodingLast": `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"`,
73 "MultiBytesFirst": `❤️aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`,
74 "MultiBytesMiddle": `aaaaaaaaaaaaaaaaaaaaaaaaa❤️aaaaaaaaaaaaaaaaaaaaaaaa`,
75 "MultiBytesLast": `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa❤️`,
76 }
77 for name, str := range tests {
78 byt := []byte(str)
79 b.Run(name, func(b *testing.B) {
80 buf := make([]byte, 0, 100)
81 for i := 0; i < b.N; i++ {
82 _ = enc.AppendBytes(buf, byt)
83 }
84 })
85 }
86}

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65
AppendBytesMethod · 0.65

Tested by

no test coverage detected