这个项目提供了一套全面的工具,用于测试数据库中键插入操作的性能。通过多种测试场景,可以评估不同配置下的数据库性能,并找出最佳配置参数。
This project provides a comprehensive set of tools for testing the performance of key insertion operations in a database. Through various test scenarios, it allows for the evaluation of database performance under different configurations and helps identify the optimal configuration parameters.
- 多线程测试:测试不同线程数对插入性能的影响
- 批处理大小测试:测试不同批处理大小对插入性能的影响
- 单线程与多线程对比:对比单线程和多线程下的插入性能差异
- 自增主键与手动主键对比:对比自增主键和手动指定主键的性能差异
- 灵活配置:通过配置文件或命令行参数灵活配置测试参数
- Multithreaded Testing: Tests the impact of different thread counts on insertion performance
- Batch Size Testing: Evaluates how different batch sizes affect insertion performance
- Single vs. Multithreaded Comparison: Compares insertion performance between single-threaded and multithreaded modes
- Auto-Increment vs. Manual Primary Key Comparison: Compares the performance differences between auto-incremented and manually specified primary keys
- Flexible Configuration: Allows flexible test parameter configuration via config files or command-line arguments
- Java 8或更高版本
- Maven 3.6或更高版本
- 可访问的PolarDB-X数据库实例
- Java 8 or higher
- Maven 3.6 or higher
- Accessible PolarDB-X database instance
编辑src/main/resources/config.properties文件,设置数据库连接信息:
# 数据库连接配置
db.url=jdbc:mysql://localhost:3306/test_db?useSSL=false&serverTimezone=UTC
db.user=root
db.password=passwordmvn clean packagejava -jar target/testDatabaseability-1.0-SNAPSHOT-jar-with-dependencies.jar可以通过命令行参数覆盖配置文件中的设置:
java -jar target/testDatabaseability-1.0-SNAPSHOT-jar-with-dependencies.jar \
--db-url=jdbc:mysql://localhost:3306/test_db \
--db-user=root \
--db-password=password \
--thread-count=8 \
--batch-size=100 \
--total-records=100000 \
--test-type=advanced \
--generate-report=true| 参数 | 描述 | 默认值 |
|---|---|---|
--db-url |
数据库连接URL | 配置文件中的值 |
--db-user |
数据库用户名 | 配置文件中的值 |
--db-password |
数据库密码 | 配置文件中的值 |
--thread-count |
测试使用的线程数 | 8 |
--batch-size |
批处理大小 | 100 |
--total-records |
总记录数 | 100000 |
--test-type |
测试类型 (basic/advanced) | basic |
| Parameter | Description | Default Value |
|---|---|---|
--db-url |
Database connection URL | Value from config file |
--db-user |
Database username | Value from config file |
--db-password |
Database password | Value from config file |
--thread-count |
Number of threads to use for testing | 8 |
--batch-size |
Batch size for insert operations | 100 |
--total-records |
Total number of records to insert | 100000 |
--test-type |
Test type (basic or advanced) |
basic |
src/main/java/com/example/
├── PolarDBXPerformanceTester.java # 主类,程序入口
├── PolarDBXPerformanceTest.java # 基础性能测试类
├── AdvancedPolarDBXPerformanceTest.java # 高级性能测试类
├── DatabaseConfig.java # 数据库配置类
src/main/java/com/example/
├── PolarDBXPerformanceTester.java # Main class, entry point of the program
├── PolarDBXPerformanceTest.java # Basic performance test class
├── AdvancedPolarDBXPerformanceTest.java # Advanced performance test class
├── DatabaseConfig.java # Database configuration class
- 测试前请确保有足够的数据库权限(创建表、插入数据等)
- 大量数据测试可能会占用较多系统资源,请在适当的环境中运行
- 测试结果会受到网络、服务器配置等多种因素影响
- Ensure you have sufficient database permissions before running tests (e.g., creating tables, inserting data)
- Large-scale data tests may consume significant system resources; run them in an appropriate environment
- Test results may be affected by factors such as network conditions and server configuration
MIT