(b *testing.B)
| 78 | } |
| 79 | |
| 80 | func BenchmarkBytePool_Get_Sync2(b *testing.B) { |
| 81 | runtime.GOMAXPROCS(1) |
| 82 | |
| 83 | var pool = &sync.Pool{ |
| 84 | New: func() any { |
| 85 | return &utils.BytesBuf{ |
| 86 | Bytes: make([]byte, 1024), |
| 87 | } |
| 88 | }, |
| 89 | } |
| 90 | |
| 91 | b.ReportAllocs() |
| 92 | b.ResetTimer() |
| 93 | |
| 94 | b.RunParallel(func(pb *testing.PB) { |
| 95 | for pb.Next() { |
| 96 | var buf = pool.Get() |
| 97 | pool.Put(buf) |
| 98 | } |
| 99 | }) |
| 100 | } |
| 101 | |
| 102 | func BenchmarkBytePool_Copy_Bytes_4(b *testing.B) { |
| 103 | const size = 4 << 10 |