1
1
package org .babyfish .jimmer .benchmark ;
2
2
3
+ import apijson .RequestMethod ;
4
+ import apijson .framework .APIJSONCreator ;
5
+ import apijson .orm .Parser ;
3
6
import com .easy .query .core .api .client .EasyQueryClient ;
4
7
import com .easy .query .core .bootstrapper .EasyQueryBootstrapper ;
5
8
import com .easy .query .h2 .config .H2DatabaseConfiguration ;
12
15
import org .babyfish .jimmer .benchmark .jooq .JooqData ;
13
16
import org .babyfish .jimmer .benchmark .jooq .JooqDataTable ;
14
17
import org .babyfish .jimmer .benchmark .ktorm .KtormDataTable ;
18
+ import org .babyfish .jimmer .benchmark .mybatis .MyBatisDataMapper ;
19
+ import org .babyfish .jimmer .benchmark .mybatis .plus .MyBatisPlusDataBaseMapper ;
15
20
import org .babyfish .jimmer .benchmark .nutz .NutzData ;
16
21
import org .babyfish .jimmer .benchmark .objsql .FakeObjSqlLoggerFactory ;
17
22
import org .babyfish .jimmer .benchmark .objsql .ObjSqlData ;
18
23
import org .babyfish .jimmer .benchmark .springjdbc .SpringJdbcDataRepository ;
19
- import org .babyfish .jimmer .benchmark .mybatis .MyBatisDataMapper ;
20
24
import org .babyfish .jimmer .sql .JSqlClient ;
21
25
import org .babyfish .jimmer .sql .kt .KSqlClient ;
22
26
import org .jooq .DSLContext ;
@@ -51,6 +55,8 @@ public class OrmBenchmark {
51
55
52
56
private MyBatisDataMapper myBatisDataMapper ;
53
57
58
+ private MyBatisPlusDataBaseMapper myBatisPlusDataBaseMapper ;
59
+
54
60
private EntityManagerFactory hibernateEntityManagerFactory ;
55
61
56
62
private EntityManagerFactory eclipseLinkEntityManagerFactory ;
@@ -67,6 +73,8 @@ public class OrmBenchmark {
67
73
private EasyQueryTest easyQueryTest ;
68
74
private EasyQueryClient easyQueryClient ;
69
75
76
+ private APIJSONCreator <Long > apijsonCreator ;
77
+
70
78
@ Setup
71
79
public void initialize () throws SQLException , IOException {
72
80
ApplicationContext ctx = SpringApplication .run (BenchmarkApplication .class );
@@ -76,6 +84,7 @@ public void initialize() throws SQLException, IOException {
76
84
sqlClient = ctx .getBean (JSqlClient .class );
77
85
kSqlClient = ctx .getBean (KSqlClient .class );
78
86
myBatisDataMapper = ctx .getBean (MyBatisDataMapper .class );
87
+ myBatisPlusDataBaseMapper = ctx .getBean (MyBatisPlusDataBaseMapper .class );
79
88
hibernateEntityManagerFactory = ctx .getBean ("hibernateEntityManagerFactory" , EntityManagerFactory .class );
80
89
eclipseLinkEntityManagerFactory = ctx .getBean ("eclipseLinkEntityManagerFactory" , EntityManagerFactory .class );
81
90
dslContext = ctx .getBean (DSLContext .class );
@@ -86,15 +95,17 @@ public void initialize() throws SQLException, IOException {
86
95
ExposedJavaHelperKt .connect (transactionAwareDataSource );
87
96
nutDao = new NutDao (transactionAwareDataSource );
88
97
jdbcDao = new JdbcDao (transactionAwareDataSource );
89
- easyQueryClient = EasyQueryBootstrapper .defaultBuilderConfiguration ().setDefaultDataSource (ctx .getBean (DataSource .class ))
90
- .optionConfigure (op -> {
98
+ easyQueryClient = EasyQueryBootstrapper .defaultBuilderConfiguration ().setDefaultDataSource (ctx .getBean (DataSource .class ))
99
+ .optionConfigure (op -> {
91
100
op .setPrintSql (false );
92
101
})
93
102
.useDatabaseConfigure (new H2DatabaseConfiguration ())
94
103
.build ();
95
- easyQueryTest = new EasyQueryTest (easyQueryClient );
104
+ easyQueryTest = new EasyQueryTest (easyQueryClient );
96
105
97
106
FakeObjSqlLoggerFactory .init ();
107
+
108
+ apijsonCreator = ctx .getBean (APIJSONCreator .class );
98
109
}
99
110
100
111
/*
@@ -139,6 +150,11 @@ public void runMyBatis() {
139
150
myBatisDataMapper .findAll ();
140
151
}
141
152
153
+ @ Benchmark
154
+ public void runMyBatisPlus () {
155
+ myBatisPlusDataBaseMapper .selectList (null );
156
+ }
157
+
142
158
@ Benchmark
143
159
public void runJpaByHibernate () {
144
160
/*
@@ -208,13 +224,28 @@ public void runJdbcByColumnIndex() throws SQLException {
208
224
public void runJdbcByColumnName () throws SQLException {
209
225
jdbcDao .findAllByColumnName ();
210
226
}
227
+
211
228
@ Benchmark
212
- public void runEasyQuery (){
229
+ public void runEasyQuery () {
213
230
easyQueryTest .selectAll ();
214
231
}
215
232
233
+ @ Benchmark
234
+ public void runApiJson () {
235
+ final Parser <Long > parser = apijsonCreator .createParser ();
236
+ parser .setNeedVerify (false );
237
+ parser .setMethod (RequestMethod .GET );
238
+ parser .parse ("{\n " +
239
+ " \" []\" : {\n " +
240
+ " \" DATA\" : {\n " +
241
+ " \" @column\" : \" ID,VALUE_1,VALUE_2,VALUE_3,VALUE_4,VALUE_5,VALUE_6,VALUE_7,VALUE_8,VALUE_9\" \n " +
242
+ " }\n " +
243
+ " }\n " +
244
+ "}" );
245
+ }
246
+
216
247
@ TearDown
217
- public void shutdown (){
248
+ public void shutdown () {
218
249
easyQueryClient .getRuntimeContext ().getEasyTimeJobManager ().shutdown ();
219
250
}
220
251
}
0 commit comments