mysqlslap的运行有如下3个步骤:
1. 创建schema、table、test data 等 (在MySQL中,schema就是database);
2. 运行负载测试,可以使用多个并发客户端连接;
3. 测试环境清理(删除创建的数据、表等)。
案例:
[root@mysql ~]# mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --auto-generate-sql-add-autoincrement --number-char-cols=10 --number-int-cols=5 -pOracle
Warning: Using a password on the command line interface can be insecure.
Benchmark
Average number of seconds to run all queries: 0.775 seconds
Minimum number of seconds to run all queries: 0.775 seconds
Maximum number of seconds to run all queries: 0.775 seconds
Number of clients running queries: 50
Average number of queries per client: 20
Benchmark
Average number of seconds to run all queries: 0.984 seconds
Minimum number of seconds to run all queries: 0.984 seconds
Maximum number of seconds to run all queries: 0.984 seconds
Number of clients running queries: 100
Average number of queries per client: 10
[root@mysql ~]# mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --auto-generate-sql-add-autoincrement --number-char-cols=10 --number-int-cols=5 --engine=myisam,innodb -poracle
Warning: Using a password on the command line interface can be insecure.
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.117 seconds
Minimum number of seconds to run all queries: 0.117 seconds
Maximum number of seconds to run all queries: 0.117 seconds
Number of clients running queries: 50
Average number of queries per client: 20
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.129 seconds
Minimum number of seconds to run all queries: 0.129 seconds
Maximum number of seconds to run all queries: 0.129 seconds
Number of clients running queries: 100
Average number of queries per client: 10
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.665 seconds
Minimum number of seconds to run all queries: 1.665 seconds
Maximum number of seconds to run all queries: 1.665 seconds
Number of clients running queries: 50
Average number of queries per client: 20
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 1.480 seconds
Minimum number of seconds to run all queries: 1.480 seconds
Maximum number of seconds to run all queries: 1.480 seconds
Number of clients running queries: 100
Average number of queries per client: 10