MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / BenchmarkBytePool_Copy_Bytes_4

Function BenchmarkBytePool_Copy_Bytes_4

internal/utils/byte_pool_test.go:102–121  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

100}
101
102func BenchmarkBytePool_Copy_Bytes_4(b *testing.B) {
103 const size = 4 << 10
104
105 var data = bytes.Repeat([]byte{'A'}, size)
106
107 var pool = &sync.Pool{
108 New: func() any {
109 return make([]byte, size)
110 },
111 }
112 b.ResetTimer()
113
114 b.RunParallel(func(pb *testing.PB) {
115 for pb.Next() {
116 var buf = pool.Get().([]byte)
117 copy(buf, data)
118 pool.Put(buf)
119 }
120 })
121}
122
123func BenchmarkBytePool_Copy_Wrapper_4(b *testing.B) {
124 const size = 4 << 10

Callers

nothing calls this directly

Calls 3

NextMethod · 0.80
GetMethod · 0.45
PutMethod · 0.45

Tested by

no test coverage detected