对比测试
对目前可获得的几种对象池进行性能测试,测试场景如下:
对比测试结果
运行于 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
JVM
开启参数 -XX:-RestrictContended
一取一放场景
Benchmark Mode Cnt Score Error Units Compare001Benchmark.testBeeOP thrpt 5 17813.885 ± 1514.243 ops/ms Compare001Benchmark.testCommonsPool thrpt 5 2498.101 ± 64.911 ops/ms Compare001Benchmark.testFrogspawnPool thrpt 5 144598.931 ± 11889.548 ops/ms Compare001Benchmark.testGOPool thrpt 5 5794.308 ± 361.158 ops/ms Compare001Benchmark.testLitePool thrpt 5 452.887 ± 39.941 ops/ms Compare001Benchmark.testNew thrpt 5 287114.810 ± 29764.280 ops/ms Compare001Benchmark.testViburPool thrpt 5 4675.089 ± 466.321 ops/ms
|
多取多放场景
Benchmark Mode Cnt Score Error Units Compare002Benchmark.testBeeOPOneRequestMultiTimes thrpt 5 9667.946 ± 1277.391 ops/ms Compare002Benchmark.testFrogspawnPoolOneRequestMultiTimes thrpt 5 948.129 ± 76.413 ops/ms Compare002Benchmark.testGOPoolOneRequestMultiTimes thrpt 5 173.312 ± 12.269 ops/ms Compare002Benchmark.testLitePoolOneRequestMultiTimes thrpt 5 439.864 ± 63.803 ops/ms Compare002Benchmark.testNewOneRequestMultiTimes thrpt 5 8385.798 ± 720.384 ops/ms Compare002Benchmark.testViburPoolOneRequestMultiTimes thrpt 5 140.954 ± 6.561 ops/ms
|
分析
有如下结论:
- 一取一放场景下,
frogspawn
性能最好,接近 new
的 1/2
- 多取多放场景下,
beeop
性能最好,甚至超过 new
点评:
- 一取一放场景下,
frogspawn
性能最好
- 总体场景下,
beeop
性能综合都不错,可选择使用