MCPcopy Create free account
hub / github.com/buger/jsonparser / BenchmarkSetPreAllocated

Function BenchmarkSetPreAllocated

issues_56_107_229_test.go:223–235  ·  view source on GitHub ↗

BenchmarkSetPreAllocated measures Set's calcAllocateSpace-backed component construction. Verifies: SYS-REQ-009 (Set)

(b *testing.B)

Source from the content-addressed store, hash-verified

221//
222// Verifies: SYS-REQ-009 (Set)
223func BenchmarkSetPreAllocated(b *testing.B) {
224 keys := make([]string, 100)
225 for i := range keys {
226 keys[i] = "key" + strconv.Itoa(i)
227 }
228 setValue := bytes.Repeat([]byte("value"), 100)
229
230 b.ReportAllocs()
231 b.ResetTimer()
232 for i := 0; i < b.N; i++ {
233 benchmarkSetInsertResult = createInsertComponent(keys, setValue, false, true)
234 }
235}
236
237func createInsertComponentBuffered(keys []string, setValue []byte, comma, object bool) []byte {
238 var buffer bytes.Buffer

Callers

nothing calls this directly

Calls 1

createInsertComponentFunction · 0.85

Tested by

no test coverage detected