| 165 | } |
| 166 | |
| 167 | func BenchmarkBytePool_Copy_Wrapper_16(b *testing.B) { |
| 168 | const size = 16 << 10 |
| 169 | |
| 170 | var data = bytes.Repeat([]byte{'A'}, size) |
| 171 | |
| 172 | var pool = &sync.Pool{ |
| 173 | New: func() any { |
| 174 | return &utils.BytesBuf{ |
| 175 | Bytes: make([]byte, size), |
| 176 | } |
| 177 | }, |
| 178 | } |
| 179 | b.ResetTimer() |
| 180 | |
| 181 | b.RunParallel(func(pb *testing.PB) { |
| 182 | for pb.Next() { |
| 183 | var buf = pool.Get().(*utils.BytesBuf) |
| 184 | copy(buf.Bytes, data) |
| 185 | pool.Put(buf) |
| 186 | } |
| 187 | }) |
| 188 | } |
| 189 | |
| 190 | func BenchmarkBytePool_Copy_Wrapper_Buf_16(b *testing.B) { |
| 191 | const size = 16 << 10 |