Closed thinkeridea closed 3 years ago
SyncPool
Buffer
Reset
在完善测试用例后,以下测试结果并没有相较 sync.Pool 有明显优势,且可能对性能产生影响。
goos: darwin goarch: amd64 pkg: github.com/thinkeridea/go-extend/pool/benchmark BenchmarkBufferPool BenchmarkBufferPool-8 943312 1065 ns/op 1 B/op 0 allocs/op BenchmarkBufferSyncPool BenchmarkBufferSyncPool-8 1000000 1032 ns/op 0 B/op 0 allocs/op BenchmarkBufferFixedSizePool BenchmarkBufferFixedSizePool-8 29174670 44.1 ns/op 0 B/op 0 allocs/op BenchmarkBufferFixedSizeSyncPool BenchmarkBufferFixedSizeSyncPool-8 38488425 28.1 ns/op 0 B/op 0 allocs/op PASS ok github.com/thinkeridea/go-extend/pool/benchmark 5.236s
16 在性能测试时,对
SyncPool
测试时并没有对Buffer
进行Reset
操作,导致大量内存分配,测试结果没有参考性。在完善测试用例后,以下测试结果并没有相较 sync.Pool 有明显优势,且可能对性能产生影响。