时间:2021-07-01 10:21:17 帮助过:29人阅读
-a, --auto-generate-sql 由系统自动生成SQL脚本进行测试
Generate SQL where not supplied by file or command line.
--auto-generate-sql-add-autoincrement 生成的表中增加自增的ID
Add an AUTO_INCREMENT column to auto-generated tables.--auto-generate-sql-load-type=name 制定测试过程中使用的查询类型
Specify test load type: mixed, update, write, key, or
read; default is mixed.--auto-generate-sql-write-number=# 制定所生成的初始化数据的条数
Number of row inserts to perform for each thread (default
is 100).-c, --concurrency=name 制定并发线程的数量
Number of clients to simulate for query to run.
--create=name File or string to use create tables.
--create-schema=name 创建一个测试数据库的schema名称
Schema to run tests in.-T, --debug-info This is a non-debug version. Catch this and exit.指定
输出额外的内存及CPU统计信息-e,其中,完整的运行脚本如下
mysqlslap -S /tmp/mysql3306.sock --concurrency=1,50,100,200 --iterations=3 --number-int-cols=5 --number-char-cols=5 --auto-generate-sql --auto-generate-sql-add-autoincrement --engine=innodb --number-of-queries=10 --create-schema=test -uroot -p
待输入密码后,测试信息如下
Enter password: Benchmark Running for engine innodb Average number of seconds to run all queries: 0.097 seconds Minimum number of seconds to run all queries: 0.093 seconds Maximum number of seconds to run all queries: 0.107 seconds Number of clients running queries: 1 Average number of queries per client: 10Benchmark Running for engine innodb Average number of seconds to run all queries: 0.506 seconds Minimum number of seconds to run all queries: 0.447 seconds Maximum number of seconds to run all queries: 0.570 seconds Number of clients running queries: 50 Average number of queries per client: 0Benchmark Running for engine innodb Average number of seconds to run all queries: 2.204 seconds Minimum number of seconds to run all queries: 1.595 seconds Maximum number of seconds to run all queries: 3.257 seconds Number of clients running queries: 100 Average number of queries per client: 0mysqlslap: Error when connecting to server: 1040 Too many connections mysqlslap: Error when connecting to server: 1040 Too many connections mysqlslap: Error when connecting to server: 1040 Too many connections mysqlslap: Error when connecting to server: 1040 Too many connections
此时可以看出来,当并发达到了200的时候,出现了Too many connections的异常,这是因为mysql默认配置的最大链接数为100,故需要对my.cnf做如下的修改
添加max_connections=1024,之后运行正常
Benchmark Running for engine innodb Average number of seconds to run all queries: 0.093 seconds Minimum number of seconds to run all queries: 0.087 seconds Maximum number of seconds to run all queries: 0.098 seconds Number of clients running queries: 1 Average number of queries per client: 10Benchmark Running for engine innodb Average number of seconds to run all queries: 0.514 seconds Minimum number of seconds to run all queries: 0.462 seconds Maximum number of seconds to run all queries: 0.545 seconds Number of clients running queries: 50 Average number of queries per client: 0Benchmark Running for engine innodb Average number of seconds to run all queries: 1.209 seconds Minimum number of seconds to run all queries: 1.173 seconds Maximum number of seconds to run all queries: 1.241 seconds Number of clients running queries: 100 Average number of queries per client: 0Benchmark Running for engine innodb Average number of seconds to run all queries: 2.174 seconds Minimum number of seconds to run all queries: 1.978 seconds Maximum number of seconds to run all queries: 2.402 seconds Number of clients running queries: 200 Average number of queries per client: 0
以上就是mysqlslap执行基准测试的代码详情介绍的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!