關(guān)于他的選項(xiàng)手冊(cè)上以及--help介紹的很詳細(xì)。
我解釋一下一些常用的選項(xiàng)。
這里要注意的幾個(gè)選項(xiàng):
--concurrency代表并發(fā)數(shù)量,多個(gè)可以用逗號(hào)隔開(kāi),當(dāng)然你也可以用自己的分隔符隔開(kāi),這個(gè)時(shí)候要用到--delimiter開(kāi)關(guān)。--engines代表要測(cè)試的引擎,可以有多個(gè),用分隔符隔開(kāi)。--iterations代表要運(yùn)行這些測(cè)試多少次。--auto-generate-sql 代表用系統(tǒng)自己生成的SQL腳本來(lái)測(cè)試。--auto-generate-sql-load-type 代表要測(cè)試的是讀還是寫還是兩者混合的(read,write,update,mixed)--number-of-queries 代表總共要運(yùn)行多少次查詢。每個(gè)客戶運(yùn)行的查詢數(shù)量可以用查詢總數(shù)/并發(fā)數(shù)來(lái)計(jì)算。比如倒數(shù)第二個(gè)結(jié)果2=200/100。--debug-info 代表要額外輸出CPU以及內(nèi)存的相關(guān)信息。--number-int-cols 代表示例表中的INTEGER類型的屬性有幾個(gè)。--number-char-cols 意思同上。--create-schema 代表自己定義的模式(在MySQL中也是庫(kù))。--query 代表自己的SQL腳本。--only-print 如果只想打印看看SQL語(yǔ)句是什么,可以用這個(gè)選項(xiàng)。
現(xiàn)在來(lái)看一些我測(cè)試的例子。
1、用自帶的SQL腳本來(lái)測(cè)試。
MySQL版本為5.1.23
[root@localhost ~]# mysqlslap --defaults-file=/usr/local/mysql-maria/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 -uroot -p1 -S/tmp/mysql_3310.sock
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.063 seconds
Minimum number of seconds to run all queries: 0.063 seconds
Maximum number of seconds to run all queries: 0.063 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.070 seconds
Minimum number of seconds to run all queries: 0.070 seconds
Maximum number of seconds to run all queries: 0.070 seconds
Number of clients running queries: 100
Average number of queries per client: 2
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.092 seconds
Minimum number of seconds to run all queries: 0.092 seconds
Maximum number of seconds to run all queries: 0.092 seconds
Number of clients running queries: 200
Average number of queries per client: 1
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.115 seconds
Minimum number of seconds to run all queries: 0.115 seconds
Maximum number of seconds to run all queries: 0.115 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.134 seconds
Minimum number of seconds to run all queries: 0.134 seconds
Maximum number of seconds to run all queries: 0.134 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.192 seconds
Minimum number of seconds to run all queries: 0.192 seconds
Maximum number of seconds to run all queries: 0.192 seconds
Number of clients running queries: 200
Average number of queries per client: 1
User time 0.06, System time 0.15
Maximum resident set size 0, Integral resident set size 0
Non-physical pagefaults 5803, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 8173, Involuntary context switches 528
我來(lái)解釋一下結(jié)果的含義。拿每個(gè)引擎后一個(gè)Benchmark示例。對(duì)于INNODB引擎,200個(gè)客戶端同時(shí)運(yùn)行這些SQL語(yǔ)句平均要花0.192秒。相應(yīng)的MYISAM為0.092秒。
2、用我們自己定義的SQL 腳本來(lái)測(cè)試。
這些數(shù)據(jù)在另外一個(gè)MySQL實(shí)例上。版本為5.0.45先看一下這兩個(gè)表的相關(guān)數(shù)據(jù)。
1)、總記錄數(shù)。
mysql> select table_rows as rows from information_schema.tables where table_schema='t_girl' and table_name='article';
+--------+
| rows |
+--------+
| 296693 |
+--------+
1 row in set (0.01 sec)
mysql> select table_rows as rows from information_schema.tables where table_schema='t_girl' and table_name='category';
+------+
| rows |
+------+
| 113 |
+------+
1 row in set (0.00 sec)
2)、總列數(shù)。
mysql> select count(*) as column_total from information_schema.columns where table_schema = 't_girl' and table_name = 'article';
+--------------+
| column_total |
+--------------+
| 32 |
+--------------+
1 row in set (0.01 sec)
mysql> select count(*) as column_total from information_schema.columns where table_schema = 't_girl' and table_name = 'category';
+--------------+
| column_total |
+--------------+
| 9 |
+--------------+
1 row in set (0.01 sec)