MySQL性能测试工具 mysqlslap

1.使用自动生成脚本测试数据库性能

mysqlslap -uroot -p123 -a --debug-info --concurrency=50,100  --number-of-queries=200 --engine=myisam,innodb

参数介绍 

-u : 用户名

-p : 密码

-a (--auto-generate-sql) : 自动生成sql脚本测试数据库

--debug-info : 输出debug信息,包括内存,CPU等

--concurrency : 用户并发数,可填写多个

--number-of-queries : 每个用户的查询次数

--engine : 需要测试的数据库引擎

输出结果:

Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 0.029 seconds
        Minimum number of seconds to run all queries: 0.029 seconds
        Maximum number of seconds to run all queries: 0.029 seconds
        Number of clients running queries: 50
        Average number of queries per client: 4

Benchmark
        Running for engine myisam
        Average number of seconds to run all queries: 0.026 seconds
        Minimum number of seconds to run all queries: 0.026 seconds
        Maximum number of seconds to run all queries: 0.026 seconds
        Number of clients running queries: 100
        Average number of queries per client: 2

Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 0.037 seconds
        Minimum number of seconds to run all queries: 0.037 seconds
        Maximum number of seconds to run all queries: 0.037 seconds
        Number of clients running queries: 50
        Average number of queries per client: 4

Benchmark
        Running for engine innodb
        Average number of seconds to run all queries: 0.040 seconds
        Minimum number of seconds to run all queries: 0.040 seconds
        Maximum number of seconds to run all queries: 0.040 seconds
        Number of clients running queries: 100
        Average number of queries per client: 2

 

2.使用自定义SQL语句测试指定数据库

mysqlslap -uroot -plewis0913 --create-schema="test" --query="select * from user;" --concurrency=50,100 --debug-info

参数介绍

--create-schema : 需要测试的数据库

--query : 需要测试的sql语句

输出结果:

Benchmark
       Average number of seconds to run all queries: 2.029 seconds
       Minimum number of seconds to run all queries: 2.029 seconds
       Maximum number of seconds to run all queries: 2.029 seconds
       Number of clients running queries: 50
       Average number of queries per client: 1

Benchmark
       Average number of seconds to run all queries: 2.544 seconds
       Minimum number of seconds to run all queries: 2.544 seconds
       Maximum number of seconds to run all queries: 2.544 seconds
       Number of clients running queries: 100
       Average number of queries per client: 1

你可能感兴趣的:(mysqlslap,Mysql性能测试)