MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / BenchmarkJsonMarshal

Function BenchmarkJsonMarshal

query/outputnode_test.go:92–116  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

90}
91
92func BenchmarkJsonMarshal(b *testing.B) {
93 inputStrings := [][]string{
94 {"largestring", strings.Repeat("a", 1024)},
95 {"smallstring", "abcdef"},
96 {"specialchars", "<><>^)(*&(%*&%&^$*&%)(*&)^)"},
97 }
98
99 var result []byte
100
101 for _, input := range inputStrings {
102 b.Run(fmt.Sprintf("STDJsonMarshal-%s", input[0]), func(b *testing.B) {
103 for i := 0; i < b.N; i++ {
104 result, _ = json.Marshal(input[1])
105 }
106 })
107
108 b.Run(fmt.Sprintf("stringJsonMarshal-%s", input[0]), func(b *testing.B) {
109 for i := 0; i < b.N; i++ {
110 result = stringJsonMarshal(input[1])
111 }
112 })
113 }
114
115 _ = result
116}
117
118func TestStringJsonMarshal(t *testing.T) {
119 inputs := []string{

Callers

nothing calls this directly

Calls 2

stringJsonMarshalFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…