(b *testing.B)
| 58 | } |
| 59 | |
| 60 | func BenchmarkBytePool_Get_Sync(b *testing.B) { |
| 61 | runtime.GOMAXPROCS(1) |
| 62 | |
| 63 | var pool = &sync.Pool{ |
| 64 | New: func() any { |
| 65 | return make([]byte, 1024) |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | b.ReportAllocs() |
| 70 | b.ResetTimer() |
| 71 | |
| 72 | b.RunParallel(func(pb *testing.PB) { |
| 73 | for pb.Next() { |
| 74 | var buf = pool.Get() |
| 75 | pool.Put(buf) |
| 76 | } |
| 77 | }) |
| 78 | } |
| 79 | |
| 80 | func BenchmarkBytePool_Get_Sync2(b *testing.B) { |
| 81 | runtime.GOMAXPROCS(1) |