BeetlSQL 性能
About 1490 wordsAbout 5 min
1984-01-24
BeetlSQL 3性能总体良好,性能测试采用JMH,有SpringData,MyBatis,JDBC,Weed3等,使用H2的内存模式测试,并且,尽量让Entity最为简单,以最大程度验证Dao自身的性能(实际上对复杂Bean的映射也能体现数据库访问工具性能,BeetlSQL在这方面更具备优势)
性能测试最新结果和测试代码在BeetlSQL3工程里,https://gitee.com/xiandafu/beetlsql/tree/master/sql-jmh
如果想自己测试,可以进入JMHMain,运行即可。如果你只关注某些ORM工具,可以屏蔽其他ORM测试方法
需要注意,最新测试增加了Beetl加速扩展包,因此性能比默认高处50%到200%,参考加速扩展包
PerformanceConfig perforanceConfig = new PerformanceConfig();
perforanceConfig.config(sqlManagaer)
测试方法
参考 BaseService ,测试了Dao的各个功能
public interface BaseService {
/**
* 简单增加一个实体
*/
public void addEntity();
/**
* 根据主键查询实体
* @return
*/
public Object getEntity();
/**
* 动态构造sql语句,并支持重构
* */
public void lambdaQuery();
/**
* 执行jdbc sql
*/
public void executeJdbcSql();
/**
* 执行sql模板或者HQL
*/
public void executeTemplateSql();
/**
* SQL放到文件管理
*/
public void sqlFile();
/**
* 一个一对多的例子
*/
public void one2Many();
/**
* 测试翻页查询
*/
public void pageQuery();
/**
* 通过配置文件来映射复杂的查询结果,目前只有mybatis和beetlsql支持
*/
public void complexMapping();
public void getAll();
最新
- 本次均使用了最新的ORM版本。
- 将数据库字段从2个字段增加到20个字段
- 增加getAll性能测试
- 增加mybatis-flex,easyquery的orm工具
JDBC作为基准测试,直接使用jdbc+无反射,是最快的。在不考虑JDBC的情况下,BeetlSQL性能比MyBatis和JPA都好很多
另外BeetlSQL支持全部9个场景的测试
有些dao并不支持一些特性,所以并未出现在下面列表,比如JDBC不支持自动翻页查询,MyBatis不支持one2Many等。
测试机器在这几年中使用了不同的机器,本次测试使用的Mac i7. 测试维度是ops/ms,每毫秒的调用次数。越高越好(Score,Error这里表示误差)。
Benchmark Mode Cnt Score Error Units
JMHMain.beetlsqlComplexMapping thrpt 5 255.458 ± 60.277 ops/ms
JMHMain.beetlsqlExecuteJdbc thrpt 5 310.825 ± 25.901 ops/ms
JMHMain.beetlsqlExecuteTemplate thrpt 5 272.615 ± 10.883 ops/ms
JMHMain.beetlsqlFile thrpt 5 265.682 ± 15.083 ops/ms
JMHMain.beetlsqlGetAll thrpt 5 13.869 ± 0.431 ops/ms
JMHMain.beetlsqlInsert thrpt 5 129.510 ± 73.525 ops/ms
JMHMain.beetlsqlLambdaQuery thrpt 5 194.066 ± 20.773 ops/ms
JMHMain.beetlsqlOne2Many thrpt 5 174.328 ± 18.469 ops/ms
JMHMain.beetlsqlPageQuery thrpt 5 153.528 ± 21.530 ops/ms
JMHMain.beetlsqlSelectById thrpt 5 261.294 ± 10.722 ops/ms
JMHMain.easyQueryComplexMapping thrpt 5 65.675 ± 24.593 ops/ms
JMHMain.easyQueryExecuteJdbc thrpt 5 247.011 ± 10.968 ops/ms
JMHMain.easyQueryGetAll thrpt 5 16.568 ± 1.000 ops/ms
JMHMain.easyQueryInsert thrpt 5 97.206 ± 13.522 ops/ms
JMHMain.easyQueryLambdaQuery thrpt 5 118.802 ± 8.587 ops/ms
JMHMain.easyQueryOne2Many thrpt 5 92.302 ± 11.150 ops/ms
JMHMain.easyQueryPageQuery thrpt 5 76.613 ± 6.511 ops/ms
JMHMain.easyQuerySelectById thrpt 5 112.608 ± 15.603 ops/ms
JMHMain.flexGetAll thrpt 5 2.512 ± 0.300 ops/ms
JMHMain.flexInsert thrpt 5 99.749 ± 13.610 ops/ms
JMHMain.flexPageQuery thrpt 5 34.197 ± 2.840 ops/ms
JMHMain.flexSelectById thrpt 5 69.624 ± 3.205 ops/ms
JMHMain.jdbcExecuteJdbc thrpt 5 678.643 ± 22.680 ops/ms
JMHMain.jdbcGetAll thrpt 5 40.712 ± 1.240 ops/ms
JMHMain.jdbcInsert thrpt 5 248.417 ± 157.517 ops/ms
JMHMain.jdbcSelectById thrpt 5 670.334 ± 41.391 ops/ms
JMHMain.jpaExecuteJdbc thrpt 5 64.450 ± 8.940 ops/ms
JMHMain.jpaExecuteTemplate thrpt 5 66.666 ± 6.162 ops/ms
JMHMain.jpaGetAll thrpt 5 5.061 ± 0.736 ops/ms
JMHMain.jpaInsert thrpt 5 59.919 ± 21.168 ops/ms
JMHMain.jpaOne2Many thrpt 5 102.370 ± 5.603 ops/ms
JMHMain.jpaPageQuery thrpt 5 59.366 ± 12.308 ops/ms
JMHMain.jpaSelectById thrpt 5 61.110 ± 11.092 ops/ms
JMHMain.mybatisComplexMapping thrpt 5 107.533 ± 21.488 ops/ms
JMHMain.mybatisExecuteTemplate thrpt 5 43.625 ± 3.022 ops/ms
JMHMain.mybatisFile thrpt 5 39.576 ± 6.700 ops/ms
JMHMain.mybatisGetAll thrpt 5 5.970 ± 0.584 ops/ms
JMHMain.mybatisInsert thrpt 5 42.409 ± 4.339 ops/ms
JMHMain.mybatisLambdaQuery thrpt 5 23.981 ± 6.069 ops/ms
JMHMain.mybatisPageQuery thrpt 5 16.313 ± 3.207 ops/ms
JMHMain.mybatisSelectById thrpt 5 44.626 ± 4.049 ops/ms
JMHMain.woodExecuteJdbc thrpt 5 124.015 ± 3.367 ops/ms
JMHMain.woodExecuteTemplate thrpt 5 123.251 ± 7.691 ops/ms
JMHMain.woodFile thrpt 5 124.088 ± 11.738 ops/ms
JMHMain.woodGetAll thrpt 5 1.882 ± 0.148 ops/ms
JMHMain.woodInsert thrpt 5 107.541 ± 9.479 ops/ms
JMHMain.woodLambdaQuery thrpt 5 121.923 ± 11.266 ops/ms
JMHMain.woodPageQuery thrpt 5 231.230 ± 16.197 ops/ms
JMHMain.woodSelectById thrpt 5 124.842 ± 10.048 ops/ms
2023-03-12
Benchmark Mode Cnt Score Error Units
JMHMain.beetlsqlComplexMapping thrpt 2 207.914 ops/ms
JMHMain.beetlsqlExecuteJdbc thrpt 2 496.413 ops/ms
JMHMain.beetlsqlExecuteTemplate thrpt 2 456.779 ops/ms
JMHMain.beetlsqlFile thrpt 2 424.703 ops/ms
JMHMain.beetlsqlInsert thrpt 2 254.596 ops/ms
JMHMain.beetlsqlLambdaQuery thrpt 2 230.682 ops/ms
JMHMain.beetlsqlOne2Many thrpt 2 122.058 ops/ms
JMHMain.beetlsqlPageQuery thrpt 2 193.937 ops/ms
JMHMain.beetlsqlSelectById thrpt 2 421.610 ops/ms
JMHMain.jdbcExecuteJdbc thrpt 2 1041.376 ops/ms
JMHMain.jdbcInsert thrpt 2 332.804 ops/ms
JMHMain.jdbcSelectById thrpt 2 1048.165 ops/ms
JMHMain.jpaExecuteJdbc thrpt 2 92.327 ops/ms
JMHMain.jpaExecuteTemplate thrpt 2 136.409 ops/ms
JMHMain.jpaInsert thrpt 2 61.157 ops/ms
JMHMain.jpaOne2Many thrpt 2 98.182 ops/ms
JMHMain.jpaPageQuery thrpt 2 124.133 ops/ms
JMHMain.jpaSelectById thrpt 2 295.552 ops/ms
JMHMain.mybatisComplexMapping thrpt 2 99.312 ops/ms
JMHMain.mybatisExecuteTemplate thrpt 2 212.699 ops/ms
JMHMain.mybatisFile thrpt 2 166.106 ops/ms
JMHMain.mybatisInsert thrpt 2 152.376 ops/ms
JMHMain.mybatisLambdaQuery thrpt 2 9.545 ops/ms
JMHMain.mybatisPageQuery thrpt 2 68.617 ops/ms
JMHMain.mybatisSelectById thrpt 2 251.361 ops/ms
JMHMain.weedExecuteJdbc thrpt 2 402.270 ops/ms
JMHMain.weedExecuteTemplate thrpt 2 426.764 ops/ms
JMHMain.weedFile thrpt 2 440.994 ops/ms
JMHMain.weedInsert thrpt 2 232.100 ops/ms
JMHMain.weedLambdaQuery thrpt 2 335.052 ops/ms
JMHMain.weedPageQuery thrpt 2 216.811 ops/ms
JMHMain.weedSelectById thrpt 2 359.930 ops/ms
2021-11-21
测试机器在这几年中使用了不同的机器,本次测试使用的Mac i5. 测试维度是ops/ms,每毫秒的调用次数(Score,Error这里表示误差)
Benchmark Mode Cnt Score Error Units
JMHMain.beetlsqlComplexMapping thrpt 2 226.834 ops/ms
JMHMain.beetlsqlExecuteJdbc thrpt 2 510.638 ops/ms
JMHMain.beetlsqlExecuteTemplate thrpt 2 461.694 ops/ms
JMHMain.beetlsqlFile thrpt 2 467.866 ops/ms
JMHMain.beetlsqlInsert thrpt 2 273.023 ops/ms
JMHMain.beetlsqlLambdaQuery thrpt 2 285.992 ops/ms
JMHMain.beetlsqlOne2Many thrpt 2 125.105 ops/ms
JMHMain.beetlsqlPageQuery thrpt 2 215.244 ops/ms
JMHMain.beetlsqlSelectById thrpt 2 447.269 ops/ms
JMHMain.jdbcExecuteJdbc thrpt 2 1120.869 ops/ms
JMHMain.jdbcInsert thrpt 2 355.742 ops/ms
JMHMain.jdbcSelectById thrpt 2 1153.968 ops/ms
JMHMain.jpaExecuteJdbc thrpt 2 109.625 ops/ms
JMHMain.jpaExecuteTemplate thrpt 2 138.528 ops/ms
JMHMain.jpaInsert thrpt 2 71.405 ops/ms
JMHMain.jpaOne2Many thrpt 2 103.901 ops/ms
JMHMain.jpaPageQuery thrpt 2 119.841 ops/ms
JMHMain.jpaSelectById thrpt 2 344.053 ops/ms
JMHMain.mybatisComplexMapping thrpt 2 101.239 ops/ms
JMHMain.mybatisExecuteTemplate thrpt 2 212.812 ops/ms
JMHMain.mybatisFile thrpt 2 137.140 ops/ms
JMHMain.mybatisInsert thrpt 2 150.837 ops/ms
JMHMain.mybatisLambdaQuery thrpt 2 14.421 ops/ms
JMHMain.mybatisPageQuery thrpt 2 64.915 ops/ms
JMHMain.mybatisSelectById thrpt 2 222.265 ops/ms
JMHMain.weedExecuteJdbc thrpt 2 430.943 ops/ms
JMHMain.weedExecuteTemplate thrpt 2 430.418 ops/ms
JMHMain.weedFile thrpt 2 493.588 ops/ms
JMHMain.weedInsert thrpt 2 241.865 ops/ms
JMHMain.weedLambdaQuery thrpt 2 441.746 ops/ms
JMHMain.weedPageQuery thrpt 2 252.932 ops/ms
JMHMain.weedSelectById thrpt 2 434.757 ops/ms
2020-9-28
测试机器在这几年中使用了不同的机器,本次测试使用的Mac i5. 测试维度是ops/ms,每毫秒的调用次数(Score,Error这里表示误差)
Benchmark Mode Cnt Score Error Units
JMHMain.beetlsqlComplexMapping thrpt 5 212.378 ± 26.222 ops/ms
JMHMain.beetlsqlExecuteJdbc thrpt 5 428.713 ± 66.192 ops/ms
JMHMain.beetlsqlExecuteTemplate thrpt 5 374.943 ± 20.214 ops/ms
JMHMain.beetlsqlFile thrpt 5 433.001 ± 65.448 ops/ms
JMHMain.beetlsqlInsert thrpt 5 236.244 ± 112.102 ops/ms
JMHMain.beetlsqlLambdaQuery thrpt 5 247.289 ± 19.310 ops/ms
JMHMain.beetlsqlOne2Many thrpt 5 108.132 ± 10.934 ops/ms
JMHMain.beetlsqlPageQuery thrpt 5 203.751 ± 9.395 ops/ms
JMHMain.beetlsqlSelectById thrpt 5 393.437 ± 15.685 ops/ms
JMHMain.jdbcExecuteJdbc thrpt 5 1083.310 ± 80.947 ops/ms
JMHMain.jdbcInsert thrpt 5 308.341 ± 231.163 ops/ms
JMHMain.jdbcSelectById thrpt 5 1019.370 ± 92.946 ops/ms
JMHMain.jpaExecuteJdbc thrpt 5 94.600 ± 15.624 ops/ms
JMHMain.jpaExecuteTemplate thrpt 5 133.017 ± 12.954 ops/ms
JMHMain.jpaInsert thrpt 5 81.232 ± 26.971 ops/ms
JMHMain.jpaOne2Many thrpt 5 101.506 ± 11.301 ops/ms
JMHMain.jpaPageQuery thrpt 5 117.748 ± 4.512 ops/ms
JMHMain.jpaSelectById thrpt 5 335.945 ± 27.186 ops/ms
JMHMain.mybatisComplexMapping thrpt 5 102.402 ± 11.129 ops/ms
JMHMain.mybatisExecuteTemplate thrpt 5 202.619 ± 16.978 ops/ms
JMHMain.mybatisFile thrpt 5 151.151 ± 4.251 ops/ms
JMHMain.mybatisInsert thrpt 5 141.469 ± 43.092 ops/ms
JMHMain.mybatisLambdaQuery thrpt 5 15.558 ± 1.481 ops/ms
JMHMain.mybatisPageQuery thrpt 5 63.705 ± 7.592 ops/ms
JMHMain.mybatisSelectById thrpt 5 197.130 ± 19.461 ops/ms
JMHMain.weedExecuteJdbc thrpt 5 416.941 ± 22.256 ops/ms
JMHMain.weedExecuteTemplate thrpt 5 439.266 ± 57.130 ops/ms
JMHMain.weedFile thrpt 5 477.561 ± 37.926 ops/ms
JMHMain.weedInsert thrpt 5 231.444 ± 92.598 ops/ms
JMHMain.weedLambdaQuery thrpt 5 422.707 ± 64.716 ops/ms
JMHMain.weedPageQuery thrpt 5 246.018 ± 18.724 ops/ms
JMHMain.weedSelectById thrpt 5 380.348 ± 20.968 ops/ms