Thanks to visit codestin.com
Credit goes to github.com

Skip to content

This project provides a comprehensive set of tools for testing the performance of key insertion operations in a database. Through various test scenarios, it enables the evaluation of database performance under different configurations and helps identify the optimal configuration parameters. 这个项目提供了一套全面的工具,用于测试数据库中键插入操作的性能。通过多种测试场景,可以评估不同配置下的数据库性

Notifications You must be signed in to change notification settings

FantasticDream/sql-ability-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL 插入性能测试工具

这个项目提供了一套全面的工具,用于测试数据库中键插入操作的性能。通过多种测试场景,可以评估不同配置下的数据库性能,并找出最佳配置参数。

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.

功能特点

  • 多线程测试:测试不同线程数对插入性能的影响
  • 批处理大小测试:测试不同批处理大小对插入性能的影响
  • 单线程与多线程对比:对比单线程和多线程下的插入性能差异
  • 自增主键与手动主键对比:对比自增主键和手动指定主键的性能差异
  • 灵活配置:通过配置文件或命令行参数灵活配置测试参数

Features

  • 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数据库实例

System Requirements

  • Java 8 or higher
  • Maven 3.6 or higher
  • Accessible PolarDB-X database instance

快速开始

1. 配置数据库连接

编辑src/main/resources/config.properties文件,设置数据库连接信息:

# 数据库连接配置
db.url=jdbc:mysql://localhost:3306/test_db?useSSL=false&serverTimezone=UTC
db.user=root
db.password=password

2. 编译项目

mvn clean package

3. 运行测试

java -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

Available Parameters

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

注意事项

  • 测试前请确保有足够的数据库权限(创建表、插入数据等)
  • 大量数据测试可能会占用较多系统资源,请在适当的环境中运行
  • 测试结果会受到网络、服务器配置等多种因素影响

Notes

  • 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

About

This project provides a comprehensive set of tools for testing the performance of key insertion operations in a database. Through various test scenarios, it enables the evaluation of database performance under different configurations and helps identify the optimal configuration parameters. 这个项目提供了一套全面的工具,用于测试数据库中键插入操作的性能。通过多种测试场景,可以评估不同配置下的数据库性

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published