Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Commit f7d23f2

Browse files
yn-tadpoletadpole@hometadpole
authored
Update Tad.x Framework (#10796)
* [Java/Tad.x] Create Tad.x Framework test * Add Forwarded Port. Used for debugging during the development and testing of code * [Java/Tad.x] Build the test package (as the relevant dependencies of Tad.x have not yet been uploaded to the Maven repository, local packaging is temporarily used. In the future, it will be changed to rely on the Maven repository) * [Java/Tad.x] Update README.md * [Java/Tad.x] Create multi-language RADMME file. * [Java/Tad.x] Change Db Test * [Java/Tad.x] Change DbStorage API * ... * ... * [Java/Tad.x] Change PB Pool Options, fixed bugs * [Java/Tad.x] Change Docker file options * [Java/Tad.x] Update Tad.x. Join plaintext/json with the database tests, and add maintainers. --------- Co-authored-by: tadpole@home <tadpole@home> Co-authored-by: tadpole <tadpole@lenovo-laptop>
1 parent 92907d3 commit f7d23f2

25 files changed

Lines changed: 379 additions & 241 deletions

frameworks/Java/tadx/README.cn.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Tad.x (tadx) 基准测试
2+
3+
## 项目概述
4+
Tad.x 是一个用于基准测试的 Java Web 框架项目,是 [FrameworkBenchmarks](https://github.com/TechEmpower/FrameworkBenchmarks) 的一部分,主要用于测试不同 Web 框架的性能表现。
5+
6+
## 技术栈
7+
- **Java 21**:项目的主要开发语言
8+
- **Spring Boot**:当前使用的主要框架(从代码中可以看到之前可能使用过 Vert.x,现已注释)
9+
- **Vert.x**:用于异步事件处理和数据库操作
10+
- **PostgreSQL**:基准测试使用的数据库
11+
- **Thymeleaf & FreeMarker**:模板引擎,用于Fortunes测试
12+
- **Gradle**:项目构建工具
13+
14+
## 项目结构
15+
```yaml
16+
tadx/
17+
├── src/main/java/io/tadx/benchmark/
18+
│ ├── Application.java # Project entry point
19+
│ ├── controller/ # Controller classes
20+
│ ├── entity/ # Database entity classes
21+
│ └── route_mapper/ # Route mapping implementations
22+
├── src/main/resources/ # Resource files
23+
│ ├── application.yaml # Configuration file
24+
│ └── templates/ # Template files
25+
├── build.gradle # Gradle build configuration
26+
├── settings.gradle # Gradle settings
27+
└── tadx.dockerfile # Docker deployment configuration
28+
```
29+
30+
## 核心功能
31+
项目实现了以下基准测试类型:
32+
33+
| 测试类型 | 路由 | 实现类 | 功能描述 |
34+
|---------|------|-------|----------|
35+
| JSON | /json | JsonRouteMapper.java | 返回简单JSON响应 |
36+
| 文本 | /plaintext | PlainTextRouteMapper.java | 返回简单文本响应 |
37+
| 数据库 | /db | DbRouteMapper_Postgresql.java | 单条数据库查询 |
38+
| 多查询 | /query | QueriesRouteMapper1_Postgresql.java | 多条数据库查询 |
39+
| 缓存查询 | /cached_query | CachedQueriesMapper3.java | 缓存查询结果 |
40+
| 更新 | /update | UpdateMapper.java | 数据库更新操作 |
41+
| 幸运饼干 | /fortunes | FortunesRouteMapper1.java | 模板渲染测试 |
42+
43+
## 实现特点
44+
45+
### 路由机制
46+
- 使用自定义的 `@RouteMapping` 注解定义路由
47+
- 每个测试类型对应一个 `RouteMapper` 接口实现
48+
- 路由处理直接操作 Vert.x 的响应对象,减少中间层开销
49+
50+
### 数据库操作
51+
- 使用 Vert.x 的 PostgreSQL 客户端进行异步数据库操作
52+
- 配置了数据库连接池,最大连接数为 2000
53+
- 支持 prepared statements 缓存,提高性能
54+
- 定义了 `World``Fortune` 两个实体类映射数据库表
55+
56+
### 性能优化
57+
- 直接设置 HTTP 响应头和状态码,减少框架开销
58+
- 使用预编译语句和连接池提高数据库性能
59+
- 缓存常用的响应头和日期字符串
60+
61+
## 运行方式
62+
1. **直接运行**:通过 `Application.java` 的 main 方法启动 Spring Boot 应用
63+
2. **构建运行**:使用 Gradle 构建 JAR 文件后运行
64+
3. **Docker部署**:使用提供的 tadx.dockerfile 构建镜像并运行
65+
66+
## 配置文件
67+
- `application.yaml`:Spring Boot 应用配置
68+
- `benchmark_config.json`:基准测试配置
69+
70+
## 测试类型实现源代码
71+
72+
* [JSON](src/main/java/io/tadx/benchmark/route_mapper/JsonRouteMapper.java)
73+
* [PLAINTEXT](src/main/java/io/tadx/benchmark/route_mapper/PlainTextRouteMapper.java)
74+
* [DB](src/main/java/io/tadx/benchmark/route_mapper/DbRouteMapper_Postgresql.java)
75+
* [QUERY](src/main/java/io/tadx/benchmark/route_mapper/QueriesRouteMapper1_Postgresql.java)
76+
* [CACHED QUERY](src/main/java/io/tadx/benchmark/route_mapper/CachedQueriesMapper3.java)
77+
* [UPDATE](src/main/java/io/tadx/benchmark/route_mapper/UpdateMapper.java)
78+
* [FORTUNES](src/main/java/io/tadx/benchmark/route_mapper/FortunesRouteMapper1.java)
79+
80+
81+
## 测试URLs
82+
### JSON
83+
84+
http://localhost:8000/json
85+
86+
### PLAINTEXT
87+
88+
http://localhost:8000/plaintext
89+
90+
### DB
91+
92+
http://localhost:8000/db
93+
94+
### QUERY
95+
96+
http://localhost:8000/query?queries=
97+
98+
### CACHED QUERY
99+
100+
http://localhost:8000/cached_query?queries=
101+
102+
### UPDATE
103+
104+
http://localhost:8000/update?queries=
105+
106+
### FORTUNES
107+
108+
http://localhost:8000/fortunes

frameworks/Java/tadx/README.en.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Tad.x (tadx) Benchmarking Test
2+
3+
## Project Overview
4+
Tad.x is a Java web framework project for benchmarking, part of the [FrameworkBenchmarks](https://github.com/TechEmpower/FrameworkBenchmarks) project, designed to test the performance of different web frameworks.
5+
6+
## Technology Stack
7+
- **Java 21**: The primary development language
8+
- **Spring Boot**: The main framework currently used (previously used Vert.x, now commented out)
9+
- **Vert.x**: For asynchronous event handling and database operations
10+
- **PostgreSQL**: Database used for benchmarking
11+
- **Thymeleaf & FreeMarker**: Template engines for the Fortunes test
12+
- **Gradle**: Project build tool
13+
14+
## Project Structure
15+
```yaml
16+
tadx/
17+
├── src/main/java/io/tadx/benchmark/
18+
│ ├── Application.java # Project entry point
19+
│ ├── controller/ # Controller classes
20+
│ ├── entity/ # Database entity classes
21+
│ └── route_mapper/ # Route mapping implementations
22+
├── src/main/resources/ # Resource files
23+
│ ├── application.yaml # Configuration file
24+
│ └── templates/ # Template files
25+
├── build.gradle # Gradle build configuration
26+
├── settings.gradle # Gradle settings
27+
└── tadx.dockerfile # Docker deployment configuration
28+
```
29+
30+
31+
plainText
32+
33+
## Core Features
34+
The project implements the following benchmark test types:
35+
36+
| Test Type | Route | Implementation Class | Description |
37+
|---------|------|-------|----------|
38+
| JSON | /json | JsonRouteMapper.java | Returns a simple JSON response |
39+
| PLAINTEXT | /plaintext | PlainTextRouteMapper.java | Returns a simple text response |
40+
| DB | /db | DbRouteMapper_Postgresql.java | Single database query |
41+
| QUERY | /query | QueriesRouteMapper1_Postgresql.java | Multiple database queries |
42+
| CACHED QUERY | /cached_query | CachedQueriesMapper3.java | Caches query results |
43+
| UPDATE | /update | UpdateMapper.java | Database update operations |
44+
| FORTUNES | /fortunes | FortunesRouteMapper1.java | Template rendering test |
45+
46+
## Implementation Features
47+
48+
### Routing Mechanism
49+
- Uses custom `@RouteMapping` annotation to define routes
50+
- Each test type corresponds to a `RouteMapper` interface implementation
51+
- Route handling directly manipulates Vert.x response objects to reduce overhead
52+
53+
### Database Operations
54+
- Uses Vert.x PostgreSQL client for asynchronous database operations
55+
- Configures database connection pool with maximum 2000 connections
56+
- Supports prepared statements caching for improved performance
57+
- Defines `World` and `Fortune` entity classes mapping to database tables
58+
59+
### Performance Optimization
60+
- Directly sets HTTP response headers and status codes to reduce framework overhead
61+
- Uses precompiled statements and connection pooling to improve database performance
62+
- Caches commonly used response headers and date strings
63+
64+
## Running Methods
65+
1. **Direct Run**: Start the Spring Boot application through the main method in `Application.java`
66+
2. **Build and Run**: Build JAR file using Gradle and run it
67+
3. **Docker Deployment**: Build image using the provided tadx.dockerfile and run it
68+
69+
## Configuration Files
70+
- `application.yaml`: Spring Boot application configuration
71+
- `benchmark_config.json`: Benchmark configuration
72+
73+
## Test Type Implementation Source Code
74+
75+
* [JSON](src/main/java/io/tadx/benchmark/route_mapper/JsonRouteMapper.java)
76+
* [PLAINTEXT](src/main/java/io/tadx/benchmark/route_mapper/PlainTextRouteMapper.java)
77+
* [DB](src/main/java/io/tadx/benchmark/route_mapper/DbRouteMapper_Postgresql.java)
78+
* [QUERY](src/main/java/io/tadx/benchmark/route_mapper/QueriesRouteMapper1_Postgresql.java)
79+
* [CACHED QUERY](src/main/java/io/tadx/benchmark/route_mapper/CachedQueriesMapper3.java)
80+
* [UPDATE](src/main/java/io/tadx/benchmark/route_mapper/UpdateMapper.java)
81+
* [FORTUNES](src/main/java/io/tadx/benchmark/route_mapper/FortunesRouteMapper1.java)
82+
83+
84+
## Test URLs
85+
### JSON
86+
87+
http://localhost:8000/json
88+
89+
### PLAINTEXT
90+
91+
http://localhost:8000/plaintext
92+
93+
### DB
94+
95+
http://localhost:8000/db
96+
97+
### QUERY
98+
99+
http://localhost:8000/query?queries=
100+
101+
### CACHED QUERY
102+
103+
http://localhost:8000/cached_query?queries=
104+
105+
### UPDATE
106+
107+
http://localhost:8000/update?queries=
108+
109+
### FORTUNES
110+
111+
http://localhost:8000/fortunes

frameworks/Java/tadx/README.md

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,11 @@
1-
# Tad.x (tadx) Benchmarking Test
1+
# Tad.x (tadx) Benchmarking Test / Tad.x (tadx) 基准测试
22

3-
### Test Type Implementation Source Code
3+
## Project Overview / 项目概述
4+
Tad.x is a Java web framework project for benchmarking, part of the [FrameworkBenchmarks](https://github.com/TechEmpower/FrameworkBenchmarks) project, designed to test the performance of different web frameworks.
45

5-
* [JSON](src/main/java/io/tadx/benchmark/route_mapper/JsonRouteMapper.java)
6-
* [PLAINTEXT](src/main/java/io/tadx/benchmark/route_mapper/PlainTextRouteMapper.java)
7-
* [DB](src/main/java/io/tadx/benchmark/route_mapper/DbRouteMapper_Postgresql.java)
8-
* [QUERY](src/main/java/io/tadx/benchmark/route_mapper/QueriesRouteMapper1_Postgresql.java)
9-
* [CACHED QUERY](src/main/java/io/tadx/benchmark/route_mapper/CachedQueriesMapper3.java)
10-
* [UPDATE](src/main/java/io/tadx/benchmark/route_mapper/UpdateMapper.java)
11-
* [FORTUNES](src/main/java/io/tadx/benchmark/route_mapper/FortunesRouteMapper1.java)
6+
Tad.x 是一个用于基准测试的 Java Web 框架项目,是 [FrameworkBenchmarks](https://github.com/TechEmpower/FrameworkBenchmarks) 的一部分,主要用于测试不同 Web 框架的性能表现。
127

138

14-
15-
## Test URLs
16-
### JSON
17-
18-
http://localhost:8000/json
19-
20-
### PLAINTEXT
21-
22-
http://localhost:8000/plaintext
23-
24-
### DB
25-
26-
http://localhost:8000/db
27-
28-
### QUERY
29-
30-
http://localhost:8000/query?queries=
31-
32-
### CACHED QUERY
33-
34-
http://localhost:8000/cached_query?queries=
35-
36-
### UPDATE
37-
38-
http://localhost:8000/update?queries=
39-
40-
### FORTUNES
41-
42-
http://localhost:8000/fortunes
9+
## Detailed Documentation / 详细文档
10+
- [English Version](README.en.md) / [英文版本](README.en.md)
11+
- [Chinese Version](README.cn.md) / [中文版本](README.cn.md)

frameworks/Java/tadx/benchmark_config.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"framework": "tadx",
3+
"maintainers": ["yn-tadpole"],
34
"tests": [
45
{
56
"default": {
@@ -10,21 +11,21 @@
1011
"fortune_url": "/fortunes",
1112
"update_url": "/update?queries=",
1213
"cached_query_url" : "/cached_queries?count=",
13-
"port": 8000,
14+
"port": 8080,
1415
"approach": "Realistic",
1516
"classification": "Fullstack",
1617
"database": "Postgres",
17-
"framework": "tadx",
18+
"framework": "Tad.x",
1819
"language": "Java",
1920
"flavor": "None",
2021
"orm": "Micro",
21-
"platform": "None",
22+
"platform": "Tad.x",
2223
"webserver": "None",
2324
"os": "Linux",
2425
"database_os": "Linux",
2526
"display_name": "tadx",
2627
"notes": "",
27-
"versus": "None"
28+
"versus": ""
2829
}
2930
}
3031
]
Binary file not shown.

frameworks/Java/tadx/src/main/java/io/tadx/benchmark/controller/CachedQueries.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.tadx.data.DbStorage;
55
import io.tadx.web.HttpMethod;
66
import io.tadx.web.annotation.*;
7+
import io.vertx.sqlclient.Tuple;
78

89
import java.util.SplittableRandom;
910
import java.util.concurrent.ConcurrentHashMap;
@@ -36,7 +37,7 @@ public World[] execute(int count) {
3637
World[] worlds = new World[count];
3738
for (int i = 0; i < count; i++) {
3839
int id = randomWorld();
39-
worlds[i] = cache.computeIfAbsent(id, k -> dbStorage.findEntity(World.class, id));
40+
worlds[i] = cache.computeIfAbsent(id, k -> dbStorage.findEntity(World.class, Tuple.of(id)));
4041
}
4142
return worlds;
4243
}

frameworks/Java/tadx/src/main/java/io/tadx/benchmark/controller/Db1.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.tadx.web.annotation.*;
88
import io.vertx.core.Future;
99
import io.vertx.core.Promise;
10+
import io.vertx.sqlclient.Tuple;
1011

1112
import java.util.SplittableRandom;
1213

@@ -28,14 +29,14 @@ public Db1(DbStorage dbStorage) {
2829
//@RestFunction(method = HttpMethod.GET)
2930
public Future<World> execute() {
3031
Promise<World> promise = Promise.promise();
31-
World world = dbStorage.findEntity(World.class, randomWorld());
32+
World world = dbStorage.findEntity(World.class, Tuple.of(randomWorld()));
3233
promise.complete(world);
3334
return promise.future();
3435
}
3536

3637
@RestFunction(method = HttpMethod.GET)
3738
public DataMap executeSQL() {
38-
return dbStorage.queryRow("SELECT id, randomnumber FROM world WHERE id = ?", randomWorld());
39+
return dbStorage.queryRow("SELECT id, randomnumber FROM world WHERE id = ?", Tuple.of(randomWorld()));
3940
}
4041

4142

frameworks/Java/tadx/src/main/java/io/tadx/benchmark/controller/Db2.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package io.tadx.benchmark.controller;
22

3+
import io.tadx.benchmark.db.PgConnPool;
34
import io.tadx.benchmark.entity.World;
4-
import io.tadx.core.TadxApplication;
55
import io.tadx.web.HttpMethod;
66
import io.tadx.web.annotation.RestController;
77
import io.tadx.web.annotation.RestFunction;
88
import io.vertx.core.Future;
99
import io.vertx.core.Promise;
10-
import io.vertx.core.json.JsonObject;
11-
import io.vertx.pgclient.PgBuilder;
12-
import io.vertx.pgclient.PgConnectOptions;
1310
import io.vertx.sqlclient.*;
1411

1512
import java.util.SplittableRandom;
@@ -18,23 +15,14 @@
1815
* EN: The entry point of the application.
1916
*/
2017

21-
@RestController(mapping = "/db_rest_reactive")
18+
@RestController(mapping = "/db2")
2219
public class Db2 {
2320
private static final SplittableRandom RANDOM = new SplittableRandom();
2421
private static final String SELECT_WORLD = "SELECT id, randomnumber from WORLD where id=$1";
2522
private final PreparedQuery<RowSet<Row>> SELECT_WORLD_QUERY;
2623

2724
public Db2() {
28-
PgConnectOptions connectOptions = new PgConnectOptions().
29-
setPort(5432).setHost("tfb-database").
30-
setDatabase("hello_world").
31-
setUser("benchmarkdbuser").
32-
setPassword("benchmarkdbpass").
33-
setCachePreparedStatements(true).
34-
setPreparedStatementCacheMaxSize(1024).
35-
setPipeliningLimit(100000);
36-
PoolOptions poolOptions = new PoolOptions().setMaxSize(2000);
37-
SqlClient client = PgBuilder.client().with(poolOptions).connectingTo(connectOptions).using(TadxApplication.vertx()).build();
25+
SqlClient client = PgConnPool.client();
3826
SELECT_WORLD_QUERY = client.preparedQuery(SELECT_WORLD);
3927
}
4028

0 commit comments

Comments
 (0)