Go sync.Pool Slice Benchmark
2017年7月2日 00:00
纠结于[]struct还是[]*struct
直接make([]struct,0) 后append 还是 用sync.Pool make([]struct,100)
写段代码跑个分, 结论是
[]*struct的要比[]struct多n次取指针的内存分配, 所有更慢, 如果不用修改结构体元素内的值, 没有必要用指针切片- append
[]*struct要比[]struct慢 sync.Pool效果明显
benchmark结果
剩余内容已隐藏
查看完整文章以阅读更多