| 121 | } |
| 122 | |
| 123 | func BenchmarkBytePool_Copy_Wrapper_4(b *testing.B) { |
| 124 | const size = 4 << 10 |
| 125 | |
| 126 | var data = bytes.Repeat([]byte{'A'}, size) |
| 127 | |
| 128 | var pool = &sync.Pool{ |
| 129 | New: func() any { |
| 130 | return &utils.BytesBuf{ |
| 131 | Bytes: make([]byte, size), |
| 132 | } |
| 133 | }, |
| 134 | } |
| 135 | b.ResetTimer() |
| 136 | |
| 137 | b.RunParallel(func(pb *testing.PB) { |
| 138 | for pb.Next() { |
| 139 | var buf = pool.Get().(*utils.BytesBuf) |
| 140 | copy(buf.Bytes, data) |
| 141 | pool.Put(buf) |
| 142 | } |
| 143 | }) |
| 144 | } |
| 145 | |
| 146 | func BenchmarkBytePool_Copy_Bytes_16(b *testing.B) { |
| 147 | const size = 16 << 10 |