Skip to content

Commit 85a0ca1

Browse files
committed
2 parents 52c514a + 7d87ee5 commit 85a0ca1

File tree

5 files changed

+109
-3
lines changed

5 files changed

+109
-3
lines changed

benchmark/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies {
3636
implementation(libs.easyquery)
3737
implementation(libs.apijson)
3838
implementation(libs.apijson.framework)
39+
implementation(libs.mug.safesql)
3940
implementation(libs.jmh.core)
4041
annotationProcessor(libs.jmh.generator.annprocess)
4142

benchmark/gradle/libs.versions.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[versions]
2-
kotlin = "1.9.25"
3-
ksp = "1.9.25-1.0.20"
2+
kotlin = "2.2.0"
3+
ksp = "2.2.0+"
44
springboot = "2.7.0"
55
spring-dependency-management = "1.1.6"
6-
jimmer = "0.9.10"
6+
jimmer = "0.9.104"
77
eclipselink = "3.78.0"
88
jooq = "3.16.6"
99
mybatis = "2.2.2"
@@ -16,6 +16,7 @@ easyquery = "2.0.102"
1616
jmh = "1.37"
1717
h2 = "2.3.232"
1818
apijson = "6.3.0"
19+
mug = "9.1"
1920

2021
[libraries]
2122
spring-boot-jdbc = { module = "org.springframework.boot:spring-boot-starter-jdbc", version.ref = "springboot" }
@@ -40,6 +41,7 @@ jmh-generator-annprocess = { module = "org.openjdk.jmh:jmh-generator-annprocess"
4041
h2 = { module = "com.h2database:h2", version.ref = "h2" }
4142
apijson = { module = "com.github.Tencent:APIJSON", version.ref = "apijson" }
4243
apijson-framework = { module = "com.github.APIJSON:apijson-framework", version.ref = "apijson" }
44+
mug-safesql = { module = "com.google.mug:mug-safesql", version.ref = "mug" }
4345

4446
[plugins]
4547
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

benchmark/src/main/java/org/babyfish/jimmer/benchmark/OrmBenchmark.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.babyfish.jimmer.benchmark.jooq.JooqData;
1616
import org.babyfish.jimmer.benchmark.jooq.JooqDataTable;
1717
import org.babyfish.jimmer.benchmark.ktorm.KtormDataTable;
18+
import org.babyfish.jimmer.benchmark.mug.MugSafeSql;
1819
import org.babyfish.jimmer.benchmark.mybatis.MyBatisDataMapper;
1920
import org.babyfish.jimmer.benchmark.mybatis.plus.MyBatisPlusDataBaseMapper;
2021
import org.babyfish.jimmer.benchmark.nutz.NutzData;
@@ -75,6 +76,8 @@ public class OrmBenchmark {
7576

7677
private APIJSONCreator<Long> apijsonCreator;
7778

79+
private MugSafeSql mug;
80+
7881
@Setup
7982
public void initialize() throws SQLException, IOException {
8083
ApplicationContext ctx = SpringApplication.run(BenchmarkApplication.class);
@@ -106,6 +109,7 @@ public void initialize() throws SQLException, IOException {
106109
FakeObjSqlLoggerFactory.init();
107110

108111
apijsonCreator = ctx.getBean(APIJSONCreator.class);
112+
mug = ctx.getBean(MugSafeSql.class);
109113
}
110114

111115
/*
@@ -244,6 +248,11 @@ public void runApiJson() {
244248
"}");
245249
}
246250

251+
@Benchmark
252+
public void runMug() {
253+
mug.execute();
254+
}
255+
247256
@TearDown
248257
public void shutdown() {
249258
easyQueryClient.getRuntimeContext().getEasyTimeJobManager().shutdown();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.babyfish.jimmer.benchmark.mug;
2+
3+
import com.google.mu.safesql.SafeSql;
4+
import org.springframework.stereotype.Component;
5+
6+
import javax.sql.DataSource;
7+
8+
@Component
9+
public class MugSafeSql {
10+
11+
private final DataSource dataSource;
12+
13+
public MugSafeSql(DataSource dataSource) {
14+
this.dataSource = dataSource;
15+
}
16+
17+
18+
public void execute() {
19+
SafeSql.of("SELECT ID, VALUE_1, VALUE_2, VALUE_3, VALUE_4, VALUE_5, VALUE_6, VALUE_7, VALUE_8, VALUE_9 FROM DATA").query(dataSource, MugSafeSqlData.class);
20+
}
21+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.babyfish.jimmer.benchmark.mug;
2+
3+
import com.google.mu.safesql.SqlName;
4+
5+
/**
6+
* @author Enaium
7+
*/
8+
public class MugSafeSqlData {
9+
10+
private final long id;
11+
private final String value1;
12+
private final String value2;
13+
private final String value3;
14+
private final String value4;
15+
private final String value5;
16+
private final String value6;
17+
private final String value7;
18+
private final String value8;
19+
private final String value9;
20+
21+
public MugSafeSqlData(@SqlName("ID") long id, @SqlName("VALUE_1") String value1, @SqlName("VALUE_2") String value2, @SqlName("VALUE_3") String value3, @SqlName("VALUE_4") String value4, @SqlName("VALUE_5") String value5, @SqlName("VALUE_6") String value6, @SqlName("VALUE_7") String value7, @SqlName("VALUE_8") String value8, @SqlName("VALUE_9") String value9) {
22+
this.id = id;
23+
this.value1 = value1;
24+
this.value2 = value2;
25+
this.value3 = value3;
26+
this.value4 = value4;
27+
this.value5 = value5;
28+
this.value6 = value6;
29+
this.value7 = value7;
30+
this.value8 = value8;
31+
this.value9 = value9;
32+
}
33+
34+
public long getId() {
35+
return id;
36+
}
37+
38+
public String getValue1() {
39+
return value1;
40+
}
41+
42+
public String getValue2() {
43+
return value2;
44+
}
45+
46+
public String getValue3() {
47+
return value3;
48+
}
49+
50+
public String getValue4() {
51+
return value4;
52+
}
53+
54+
public String getValue5() {
55+
return value5;
56+
}
57+
58+
public String getValue6() {
59+
return value6;
60+
}
61+
62+
public String getValue7() {
63+
return value7;
64+
}
65+
66+
public String getValue8() {
67+
return value8;
68+
}
69+
70+
public String getValue9() {
71+
return value9;
72+
}
73+
}

0 commit comments

Comments
 (0)