(b *testing.B)
| 100 | } |
| 101 | |
| 102 | func 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 | |
| 123 | func BenchmarkBytePool_Copy_Wrapper_4(b *testing.B) { |
| 124 | const size = 4 << 10 |