MySQL-Mysqlslap
测试环境:
测试版本:5.6.22
服务器:Centos5
官方说明:
http://dev.mysql.com/doc/refman/5.6/en/mysqlslap.html
-
[root@localhost ~]# mysqlslap -u root -p -c 100 -i 100 --create-schema='test' --query='insert into q1 values('default')' --debug-info
说明:
mysqlslap 一共执行了3个阶段:
1.创建schema,table,并建立一个single client connection;
2.执行测试,这个阶段可以是多个client ;
3.关闭connection;如果有必要删除多余的测试表;
-c 并发量
-i 迭代次数
-create-schema 使用的schema
-query 执行的sql
-debug-info 当运行结束,打印CPU,和内存的使用情况
-
[root@localhost ~]# mysqlslap -u root -p -c 100 -i 100 --debug-info --create='create table test1(name varchar(20))' --query='insert into test1 (name)values(123)' --create-schema='test1'
在test1创建一个test1表;100个并发重复插入100次;执行完成后删除test1这个schema;
执行结果:
-
Benchmark
-
Average number of seconds to run all queries: 0.040 seconds
-
Minimum number of seconds to run all queries: 0.029 seconds
-
Maximum number of seconds to run all queries: 0.602 seconds
-
Number of clients running queries: 100
-
Average number of queries per client: 1
-
-
-
User time 0.22, System time 0.65
-
Maximum resident set size 5896, Integral resident set size 0
-
Non-physical pagefaults 58104, Physical pagefaults 0, Swaps 0
-
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
-
Voluntary context switches 52899, Involuntary context switches 9932
当然加入--no-drop 就可以阻止mysqlslap删除schema