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

Function BenchmarkAppendString

internal/cbor/string_test.go:199–217  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

197}
198
199func BenchmarkAppendString(b *testing.B) {
200 tests := map[string]string{
201 "NoEncoding": `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`,
202 "EncodingFirst": `"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`,
203 "EncodingMiddle": `aaaaaaaaaaaaaaaaaaaaaaaaa"aaaaaaaaaaaaaaaaaaaaaaaa`,
204 "EncodingLast": `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"`,
205 "MultiBytesFirst": `❤️aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`,
206 "MultiBytesMiddle": `aaaaaaaaaaaaaaaaaaaaaaaaa❤️aaaaaaaaaaaaaaaaaaaaaaaa`,
207 "MultiBytesLast": `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa❤️`,
208 }
209 for name, str := range tests {
210 b.Run(name, func(b *testing.B) {
211 buf := make([]byte, 0, 120)
212 for i := 0; i < b.N; i++ {
213 _ = enc.AppendString(buf, str)
214 }
215 })
216 }
217}
218
219func TestAppendEmbeddedJSON(t *testing.T) {
220 tests := []struct {

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65
AppendStringMethod · 0.65

Tested by

no test coverage detected