mysqlslap 使用总结
mysqlslap 可以用于模拟服务器的负载,并输出计时信息。其被包含在 MySQL 5.1 的发行包中。测试时,可以指定并发连接数,可以指定 SQL 语句。如果没有指定 SQL 语句,mysqlslap 会自动生成查询 schema 的 SELECT 语句。
1. 查看帮助信息
1 [root@davy libmysql]# mysqlslap --help 2 mysqlslap Ver 1.0 Distrib 5.6.10, for Linux (x86_64) 3 Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 4 5 Oracle is a registered trademark of Oracle Corporation and/or its 6 affiliates. Other names may be trademarks of their respective 7 owners. 8 9 Run a query multiple times against the server. 10 11 Usage: mysqlslap [OPTIONS] 12 13 Default options are read from the following files in the given order: 14 /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 15 The following groups are read: mysqlslap client 16 The following options may be given as the first argument: 17 --print-defaults Print the program argument list and exit. 18 --no-defaults Don't read default options from any option file, 19 except for login file. 20 --defaults-file=# Only read default options from the given file #. 21 --defaults-extra-file=# Read this file after the global files are read. 22 --defaults-group-suffix=# 23 Also read groups with concat(group, suffix) 24 --login-path=# Read this path from the login file. 25 -?, --help Display this help and exit. 26 -a, --auto-generate-sql 自动生成测试表和数据 27 Generate SQL where not supplied by file or command line. 28 --auto-generate-sql-add-autoincrement 增加auto_increment一列 29 Add an AUTO_INCREMENT column to auto-generated tables. 30 --auto-generate-sql-execute-number=# 自动生成的查询的个数 31 Set this number to generate a set number of queries to 32 run. 33 --auto-generate-sql-guid-primary 增加基于GUID的主键 34 Add GUID based primary keys to auto-generated tables. 35 --auto-generate-sql-load-type=name 测试语句的类型。取值包括:read,key,write,update和mixed(默认) 36 read:查询 write:插入 key:读主键 update:更新主键 mixed:一半插入一半查询 37 Specify test load type: mixed, update, write, key, or 38 read; default is mixed. 39 --auto-generate-sql-secondary-indexes=# 增加二级索引的个数,默认是0 40 Number of secondary indexes to add to auto-generated 41 tables. 42 --auto-generate-sql-unique-query-number=# 不同查询的数量,默认值是10 43 Number of unique queries to generate for automatic tests. 44 --auto-generate-sql-unique-write-number=# 不同插入的数量,默认是100 45 Number of unique queries to generate for 46 auto-generate-sql-write-number. 47 --auto-generate-sql-write-number=# 48 Number of row inserts to perform for each thread (default 49 is 100). 50 --commit=# 多少条DML后提交一次 51 Commit records every X number of statements. 52 -C, --compress 如果服务器和客户端支持都压缩,则压缩信息传递 53 Use compression in server/client protocol. 54 -c, --concurrency=name 模拟N个客户端并发执行select。可指定多个值,以逗号或者 --delimiter 参数指定的值做为分隔符 55 Number of clients to simulate for query to run. 56 --create=name 指定用于创建表的.sql文件或者字串 57 File or string to use create tables. 58 --create-schema=name 指定待测试的数据库名,MySQL中schema也就是database,默认是mysqlslap 59 Schema to run tests in. 60 --csv[=name] Generate CSV output to named file or to stdout if no file 61 is named. 62 -#, --debug[=#] This is a non-debug version. Catch this and exit. 63 --debug-check Check memory and open file usage at exit. 64 -T, --debug-info 打印内存和CPU的信息 65 Print some debug info at exit. 66 --default-auth=name Default authentication client-side plugin to use. 67 -F, --delimiter=name 文件中的SQL语句使用分割符号 68 Delimiter to use in SQL statements supplied in file or 69 command line. 70 --detach=# 每执行完N个语句,先断开再重新打开连接 71 Detach (close and reopen) connections after X number of 72 requests. 73 --enable-cleartext-plugin 74 Enable/disable the clear text authentication plugin. 75 -e, --engine=name 创建测试表所使用的存储引擎,可指定多个 76 Storage engine to use for creating the table. 77 -h, --host=name Connect to host. 78 -i, --iterations=# 迭代执行的次数 79 Number of times to run the tests. 80 --no-drop Do not drop the schema after the test. 81 -x, --number-char-cols=name 自动生成的测试表中包含多少个字符类型的列,默认1 82 Number of VARCHAR columns to create in table if 83 specifying --auto-generate-sql. 84 -y, --number-int-cols=name 自动生成的测试表中包含多少个数字类型的列,默认1 85 Number of INT columns to create in table if specifying 86 --auto-generate-sql. 87 --number-of-queries=# 总的测试查询次数(并发客户数×每客户查询次数) 88 Limit each client to this number of queries (this is not 89 exact). 90 --only-print 只输出模拟执行的结果,不实际执行 91 Do not connect to the databases, but instead print out 92 what would have been done. 93 -p, --password[=name] 94 Password to use when connecting to server. If password is 95 not given it's asked from the tty. 96 --plugin-dir=name Directory for client-side plugins. 97 -P, --port=# Port number to use for connection. 98 --post-query=name 测试完成以后执行的SQL语句的文件或者字符串 这个过程不影响时间计算 99 Query to run or file containing query to execute after 100 tests have completed. 101 --post-system=name 测试完成以后执行的系统语句 这个过程不影响时间计算 102 system() string to execute after tests have completed. 103 --pre-query=name 测试执行之前执行的SQL语句的文件或者字符串 这个过程不影响时间计算 104 Query to run or file containing query to execute before 105 running tests. 106 --pre-system=name 测试执行之前执行的系统语句 这个过程不影响时间计算 107 system() string to execute before running tests. 108 --protocol=name The protocol to use for connection (tcp, socket, pipe, 109 memory). 110 -q, --query=name 指定自定义.sql脚本执行测试。例如可以调用自定义的一个存储过程或者sql语句来执行测试 111 Query to run or file containing query to run. 112 -s, --silent 不输出 113 Run program in silent mode - no output. 114 -S, --socket=name The socket file to use for connection. 115 --ssl Enable SSL for connection (automatically enabled with 116 other flags). 117 --ssl-ca=name CA file in PEM format (check OpenSSL docs, implies 118 --ssl). 119 --ssl-capath=name CA directory (check OpenSSL docs, implies --ssl). 120 --ssl-cert=name X509 cert in PEM format (implies --ssl). 121 --ssl-cipher=name SSL cipher to use (implies --ssl). 122 --ssl-key=name X509 key in PEM format (implies --ssl). 123 --ssl-crl=name Certificate revocation list (implies --ssl). 124 --ssl-crlpath=name Certificate revocation list path (implies --ssl). 125 --ssl-verify-server-cert 126 Verify server's "Common Name" in its cert against 127 hostname used when connecting. This option is disabled by 128 default. 129 -u, --user=name User for login if not current user. 130 -v, --verbose 输出更多的信息 131 More verbose output; you can use this multiple times to 132 get even more verbose output. 133 -V, --version Output version information and exit.
2. 以自动生成测试表和数据的形式,分别模拟 50 和 100 个客户端并发连接处理 1000 个 query 的情况
1 [root@davy libmysql]# mysqlslap -a --concurrency=50,100 --number-of-queries=1000 2 Benchmark 3 Average number of seconds to run all queries: 0.148 seconds 4 Minimum number of seconds to run all queries: 0.148 seconds 5 Maximum number of seconds to run all queries: 0.148 seconds 6 Number of clients running queries: 50 7 Average number of queries per client: 20 8 9 Benchmark 10 Average number of seconds to run all queries: 0.246 seconds 11 Minimum number of seconds to run all queries: 0.246 seconds 12 Maximum number of seconds to run all queries: 0.246 seconds 13 Number of clients running queries: 100 14 Average number of queries per client: 10 15 16 [root@Betty libmysql]#
3. 增加 --debug-info 选项,可以输出内存和CPU信息
1 [root@davy libmysql]# mysqlslap -a --concurrency=50,100 --number-of-queries=1000 --debug-info 2 Benchmark 3 Average number of seconds to run all queries: 0.202 seconds 4 Minimum number of seconds to run all queries: 0.202 seconds 5 Maximum number of seconds to run all queries: 0.202 seconds 6 Number of clients running queries: 50 7 Average number of queries per client: 20 8 9 Benchmark 10 Average number of seconds to run all queries: 0.193 seconds 11 Minimum number of seconds to run all queries: 0.193 seconds 12 Maximum number of seconds to run all queries: 0.193 seconds 13 Number of clients running queries: 100 14 Average number of queries per client: 10 15 16 17 User time 0.09, System time 0.05 18 Maximum resident set size 7848, Integral resident set size 0 19 Non-physical pagefaults 4221, Physical pagefaults 0, Swaps 0 20 Blocks in 0 out 0, Messages in 0 out 0, Signals 0 21 Voluntary context switches 7314, Involuntary context switches 1400
4. 增加 --iterations 选项,可以 重复执行 5 次
1 [root@davy libmysql]# mysqlslap -a --concurrency=50,100 --number-of-queries=1000 --iterations=5 --debug-info 2 Benchmark 3 Average number of seconds to run all queries: 0.168 seconds 4 Minimum number of seconds to run all queries: 0.147 seconds 5 Maximum number of seconds to run all queries: 0.217 seconds 6 Number of clients running queries: 50 7 Average number of queries per client: 20 8 9 Benchmark 10 Average number of seconds to run all queries: 0.209 seconds 11 Minimum number of seconds to run all queries: 0.156 seconds 12 Maximum number of seconds to run all queries: 0.280 seconds 13 Number of clients running queries: 100 14 Average number of queries per client: 10 15 16 17 User time 0.47, System time 0.25 18 Maximum resident set size 9848, Integral resident set size 0 19 Non-physical pagefaults 16880, Physical pagefaults 0, Swaps 0 20 Blocks in 0 out 0, Messages in 0 out 0, Signals 0 21 Voluntary context switches 35954, Involuntary context switches 6583
5. 可以 针对远程主机上的 mysql 进行测试
1 [root@davy Shell]# mysqlslap -a --concurrency=50,100 --number-of-queries=1000 -h 172.18.121.99 -P 3306 -p 2 Enter password: 3 Benchmark 4 Average number of seconds to run all queries: 2.009 seconds 5 Minimum number of seconds to run all queries: 2.009 seconds 6 Maximum number of seconds to run all queries: 2.009 seconds 7 Number of clients running queries: 50 8 Average number of queries per client: 20 9 10 Benchmark 11 Average number of seconds to run all queries: 4.519 seconds 12 Minimum number of seconds to run all queries: 4.519 seconds 13 Maximum number of seconds to run all queries: 4.519 seconds 14 Number of clients running queries: 100 15 Average number of queries per client: 10
6. 使用 --only-print 选项,可以查看 mysqlslap 在测试过程中如何执行的 sql 语句。在这种方式下,仅会对数据库进行模拟操作。如下显示的自动产生测试表和数据的情况下,mysqlslap 的执行过程: 创建一个临时的库 mysqlslap ,并在测试结束是会将其删除。
1 [root@davy libmysql]# mysqlslap -a --only-print 2 DROP SCHEMA IF EXISTS `mysqlslap`; 3 CREATE SCHEMA `mysqlslap`; 4 use mysqlslap; 5 CREATE TABLE `t1` (intcol1 INT(32) ,charcol1 VARCHAR(128)); 6 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 7 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 8 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 9 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 10 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 11 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 12 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 13 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 14 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 15 INSERT INTO t1 VALUES (1348361729,'i8X2EnycNH7sDHMltxcILtQE0ZPoPq9zyg24J0hiAgQNpg8jedtrWK5WtXIALR9B03FJ4ou6TCTAtWtN7fETzBzkiAmvTv6LrEZn2RtNfMaOkJfjytCp54ZfEJbb7Z'); 16 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 17 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 18 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 19 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 20 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 21 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 22 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 23 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 24 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 25 INSERT INTO t1 VALUES (1348361729,'i8X2EnycNH7sDHMltxcILtQE0ZPoPq9zyg24J0hiAgQNpg8jedtrWK5WtXIALR9B03FJ4ou6TCTAtWtN7fETzBzkiAmvTv6LrEZn2RtNfMaOkJfjytCp54ZfEJbb7Z'); 26 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 27 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 28 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 29 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 30 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 31 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 32 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 33 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 34 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 35 INSERT INTO t1 VALUES (1348361729,'i8X2EnycNH7sDHMltxcILtQE0ZPoPq9zyg24J0hiAgQNpg8jedtrWK5WtXIALR9B03FJ4ou6TCTAtWtN7fETzBzkiAmvTv6LrEZn2RtNfMaOkJfjytCp54ZfEJbb7Z'); 36 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 37 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 38 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 39 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 40 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 41 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 42 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 43 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 44 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 45 INSERT INTO t1 VALUES (1348361729,'i8X2EnycNH7sDHMltxcILtQE0ZPoPq9zyg24J0hiAgQNpg8jedtrWK5WtXIALR9B03FJ4ou6TCTAtWtN7fETzBzkiAmvTv6LrEZn2RtNfMaOkJfjytCp54ZfEJbb7Z'); 46 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 47 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 48 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 49 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 50 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 51 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 52 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 53 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 54 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 55 INSERT INTO t1 VALUES (1348361729,'i8X2EnycNH7sDHMltxcILtQE0ZPoPq9zyg24J0hiAgQNpg8jedtrWK5WtXIALR9B03FJ4ou6TCTAtWtN7fETzBzkiAmvTv6LrEZn2RtNfMaOkJfjytCp54ZfEJbb7Z'); 56 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 57 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 58 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 59 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 60 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 61 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 62 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 63 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 64 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 65 INSERT INTO t1 VALUES (1348361729,'i8X2EnycNH7sDHMltxcILtQE0ZPoPq9zyg24J0hiAgQNpg8jedtrWK5WtXIALR9B03FJ4ou6TCTAtWtN7fETzBzkiAmvTv6LrEZn2RtNfMaOkJfjytCp54ZfEJbb7Z'); 66 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 67 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 68 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 69 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 70 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 71 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 72 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 73 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 74 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 75 INSERT INTO t1 VALUES (1348361729,'i8X2EnycNH7sDHMltxcILtQE0ZPoPq9zyg24J0hiAgQNpg8jedtrWK5WtXIALR9B03FJ4ou6TCTAtWtN7fETzBzkiAmvTv6LrEZn2RtNfMaOkJfjytCp54ZfEJbb7Z'); 76 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 77 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 78 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 79 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 80 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 81 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 82 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 83 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 84 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 85 INSERT INTO t1 VALUES (1348361729,'i8X2EnycNH7sDHMltxcILtQE0ZPoPq9zyg24J0hiAgQNpg8jedtrWK5WtXIALR9B03FJ4ou6TCTAtWtN7fETzBzkiAmvTv6LrEZn2RtNfMaOkJfjytCp54ZfEJbb7Z'); 86 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 87 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 88 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 89 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 90 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 91 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 92 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 93 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 94 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 95 INSERT INTO t1 VALUES (1348361729,'i8X2EnycNH7sDHMltxcILtQE0ZPoPq9zyg24J0hiAgQNpg8jedtrWK5WtXIALR9B03FJ4ou6TCTAtWtN7fETzBzkiAmvTv6LrEZn2RtNfMaOkJfjytCp54ZfEJbb7Z'); 96 INSERT INTO t1 VALUES (1804289383,'mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkdekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxBL'); 97 INSERT INTO t1 VALUES (822890675,'97RGHZ65mNzkSrYT3zWoSbg9cNePQr1bzSk81qDgE4Oanw3rnPfGsBHSbnu1evTdFDe83ro9w4jjteQg4yoo9xHck3WNqzs54W5zEm92ikdRF48B2oz3m8gMBAl11W'); 98 INSERT INTO t1 VALUES (1308044878,'50w46i58Giekxik0cYzfA8BZBLADEg3JhzGfZDoqvQQk0Akcic7lcJInYSsf9wqin6LDC1vzJLkJXKn5onqOy04MTw1WksCYqPl2Jg2eteqOqTLfGCvE4zTZwWvgMz'); 99 INSERT INTO t1 VALUES (964445884,'DPh7kD1E6f4MMQk1ioopsoIIcoD83DD8Wu7689K6oHTAjD3Hts6lYGv8x9G0EL0k87q8G2ExJjz2o3KhnIJBbEJYFROTpO5pNvxgyBT9nSCbNO9AiKL9QYhi0x3hL9'); 100 INSERT INTO t1 VALUES (1586903190,'lwRHuWm4HE8leYmg66uGYIp6AnAr0BDd7YmuvYqCfqp9EbhKZRSymA4wx6gpHlJHI53DetH9j7Ixar90Jey5outd1ZIAJdJTjMaD7rMiqYXHFhHaB7Xr1HKuqe51GG'); 101 INSERT INTO t1 VALUES (962033002,'rfw4egILWisfxPwOc3nJx4frnAwgI539kr5EXFbupSZelM2MHqZEmD6ZNuEZzHib8fqYuHQbdrDND8lXqIdcNbAeWOBLZlpZOX5AoNlQFzpK7QjxcLP0wbWIriYGJL'); 102 INSERT INTO t1 VALUES (1910858270,'ksnug3YyANnWWDEJiRkiFC4a3e6KyJ2i3hSjksiuFLHlRXw9yhjDtnfoQd0OouyrcIbCB9zQWG4pf0yTZhaIT67nj7BY21FWJqaWrZxEh13Kt2hRbGl4MsrxsuLmvd'); 103 INSERT INTO t1 VALUES (63299708,'FJid3GaHpRC2L6jgirPm5AW3uGGgCloJ5Ww0eNHSiLWvS5bAxto23AxxR6TXr9qofeoAtxWcJsXnxzxmsdhvoekFc5mSES8tyxvsuPK5Hjs7ihtaJaLz5xEh2s1GCA'); 104 INSERT INTO t1 VALUES (737703662,'2zxutF6rOqjXYHHzSrKRwAhWCPXTdhNXYKQIRO9sEkFf1YeTGqw40Ta5u6QNfpvC1DWTTXDkFSFHtte9bbDSwgZjmryHglLhqjAKEF4MkJfT49eXcjzZNOG1F6BnsY'); 105 INSERT INTO t1 VALUES (100669,'qnMdipW5KkXdTjGCh2PNzLoeR0527frpQDQ8uw67Ydk1K06uuNHtkxYBxT5w8plb2BbpzhwYBgPNYX9RmICWGkZD6fAESvhMzH3yqzMtXoH4BQNylbK1CmEIPGYlC6'); 106 SELECT intcol1,charcol1 FROM t1; 107 INSERT INTO t1 VALUES (73673339,'BN3152Gza4GW7atxJKACYwJqDbFynLxqc0kh30YTwgz3FktQ43XTrqJ4PQ25frn7kXhfXD8RuzN1j8Rf3y8ugKy6es3IbqPJM6ylCyD6xS7YcQCfHKZxYNvB7yTahm'); 108 SELECT intcol1,charcol1 FROM t1; 109 INSERT INTO t1 VALUES (1759592334,'3lkoxjtvgLu5xKHSTTtJuGE5F5QqmCcppCTmvFZScRZQgim93gSxwb24gKmIPEzEQStMjQiCu7WapGbkw4ilXch3xRLMhKSzgLDOovSi2qGj6rKvnuYAWDDJgaZDu2'); 110 SELECT intcol1,charcol1 FROM t1; 111 INSERT INTO t1 VALUES (95275444,'bNIrBDBl81tjzdvuOpQRCXgX37xGtzLKEXBIcE3k7xK7aFtqxC99jqYnpTviK83bf6lGDgsKd4R3KLmHPnI8TqnIKj1gjw7N2sXFZNS2Svyg8cpZN7atxL39w4igsp'); 112 SELECT intcol1,charcol1 FROM t1; 113 INSERT INTO t1 VALUES (866596855,'naQuzhMt1IrZIJMkbLAKBNNKKK2sCknzI5uHeGAgQuDd5SLgpN0smODyc7qorTo1QaI5qLl97qmCIzl0Mds81x7TxpIoJyqlY0iEDRNKA1PS0AKEn5NhuMAr3KgEIM'); 114 SELECT intcol1,charcol1 FROM t1; 115 INSERT INTO t1 VALUES (364531492,'qMa5SuKo4M5OM7ldvisSc6WK9rsG9E8sSixocHdgfa5uiiNTGFxkDJ4EAwWC2e4NL1BpAgWiFRcp1zIH6F1BayPdmwphatwnmzdwgzWnQ6SRxmcvtd6JRYwEKdvuWr'); 116 DROP SCHEMA IF EXISTS `mysqlslap`;
7. 实际测试中的复杂情况。
使用 --defaults-file 选项,指定从配置文件中读取选项配置。
使用 --number-int-cols 选项,指定表中会包含 4 个 int 型的列。
使用 --number-char-cols 选项,指定表中会包含 35 个 char 型的列。
使用 --engine 选项,指定针对何种存储引擎进行测试。
1 [root@davy ~]# mysqlslap --defaults-file=/etc/my.cnf --concurrency=50,100,200 --iterations=1 --number-int-cols=4 --number-char-cols=35 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=myisam,innodb --number-of-queries=200 --debug-info -S /tmp/mysql.sock 2 Benchmark 3 Running for engine myisam 4 Average number of seconds to run all queries: 0.015 seconds 5 Minimum number of seconds to run all queries: 0.015 seconds 6 Maximum number of seconds to run all queries: 0.015 seconds 7 Number of clients running queries: 50 8 Average number of queries per client: 4 9 10 Benchmark 11 Running for engine myisam 12 Average number of seconds to run all queries: 0.024 seconds 13 Minimum number of seconds to run all queries: 0.024 seconds 14 Maximum number of seconds to run all queries: 0.024 seconds 15 Number of clients running queries: 100 16 Average number of queries per client: 2 17 18 Benchmark 19 Running for engine myisam 20 Average number of seconds to run all queries: 0.028 seconds 21 Minimum number of seconds to run all queries: 0.028 seconds 22 Maximum number of seconds to run all queries: 0.028 seconds 23 Number of clients running queries: 200 24 Average number of queries per client: 1 25 26 Benchmark 27 Running for engine innodb 28 Average number of seconds to run all queries: 0.112 seconds 29 Minimum number of seconds to run all queries: 0.112 seconds 30 Maximum number of seconds to run all queries: 0.112 seconds 31 Number of clients running queries: 50 32 Average number of queries per client: 4 33 34 Benchmark 35 Running for engine innodb 36 Average number of seconds to run all queries: 0.042 seconds 37 Minimum number of seconds to run all queries: 0.042 seconds 38 Maximum number of seconds to run all queries: 0.042 seconds 39 Number of clients running queries: 100 40 Average number of queries per client: 2 41 42 Benchmark 43 Running for engine innodb 44 Average number of seconds to run all queries: 0.105 seconds 45 Minimum number of seconds to run all queries: 0.105 seconds 46 Maximum number of seconds to run all queries: 0.105 seconds 47 Number of clients running queries: 200 48 Average number of queries per client: 1 49 50 51 User time 0.05, System time 0.06 52 Maximum resident set size 8332, Integral resident set size 0 53 Non-physical pagefaults 5388, Physical pagefaults 0, Swaps 0 54 Blocks in 0 out 0, Messages in 0 out 0, Signals 0 55 Voluntary context switches 7484, Involuntary context switches 2839
mysqlslap 运行分三个阶段:
创建 schema,table 和任何用来测试的已经存储了的程序和数据。这个阶段使用单客户端连接;
进行负载测试。这个阶段使用多客户端连接;
清除(断开连接,删除指定表)。这个阶段使用单客户端连接。
例子:
a. 提供你自己的创建 SQL 语句和查询 SQL 语句,有 50 个客户端查询,每个查询 200 次(在单行上输入命令):
1 [root@davy ~]# mysqlslap --delimiter=";" --create="CREATE TABLE a (b int);INSERT INTO a VALUES (23)" --query="SELECT * FROM a" --concurrency=50 --iterations=200 2 Benchmark 3 Average number of seconds to run all queries: 0.005 seconds 4 Minimum number of seconds to run all queries: 0.003 seconds 5 Maximum number of seconds to run all queries: 0.007 seconds 6 Number of clients running queries: 50 7 Average number of queries per client: 1
b. 让 mysqlslap 创建查询的 SQL 语句,使用的表有 2 个 INT 行和 3 个 VARCHAR 行。使用 5 个客户端,每一个查询 20 次!不要创建表或插入数据。(换言之,用之前测试的模式和数据):
1 [root@davy ~]# mysqlslap --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql 2 3 Benchmark 4 Average number of seconds to run all queries: 0.025 seconds 5 Minimum number of seconds to run all queries: 0.012 seconds 6 Maximum number of seconds to run all queries: 0.084 seconds 7 Number of clients running queries: 5 8 Average number of queries per client: 0
c. 告诉程序从指定的 create.sql 文件去加载 create,insert 和查询等 SQL 语句。该文件有多个表的 create 和insert 语句, 它们都是通过“;”分隔开的。query.sql 文件则有 多个查询语句, 分隔符也是“;”。执行所有的加载语句,然后通过查询文件执行所有的查询语句,分别在 5 个客户端上每个执行 5 次:
1 [root@Betty ~]# mysqlslap --concurrency=5 --iterations=5 --query=query.sql --create=create.sql --delimiter=";"
mysqlslap 对于模拟多个用户同时对 MySQL 发起“进攻”提供了方便。同时详细的提供了“高负荷攻击 MySQL”的详细数据报告。