Sysbench基准测试的示例分析
这篇文章给大家分享的是有关Sysbench基准测试的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
创新互联公司专业为企业提供汉阴网站建设、汉阴做网站、汉阴网站设计、汉阴网站制作等企业网站建设、网页设计与制作、汉阴企业网站模板建站服务,10多年汉阴做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
Sysbench和TPCC-MySQL一样,也是一款基准测试的工具。
TPCC-MySQL
http://blog.itpub.net/29254281/viewspace-1195589/
相对于TPCC-MySQL,Sysbench不仅可以对MySQL,也可以对Oracle,PostgreSQL进行基准测试。
源码下载地址:
https://launchpad.net/sysbench
先下载依赖包
yum install automake autoconf -y
运行./configure && make 命令,可能有以下的报错
../libtool: line 5172: : command not found
修改configure.ac文件
将LIBTOOL注释,并增加AC_PROG_RANLIB
修改之后运行如下命令
./autogen.sh && ./configure && make
完成之后,进入sysbench文件夹,可以看到sysbench命令已经编译完成。
1.进行文件IO测试
准备文件
进行基准测试
[root@mysql1 sysbench]# ./sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrw --file-num=16 --num-threads=16 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 16
Extra file open flags: 0
16 files, 128Mb each
2Gb total file size
Block size 16Kb
Number of random requests for random IO: 10000
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Threads started!
Done.
Operations performed: 6006 Read, 3996 Write, 1600 Other = 11602 Total
Read 93.844Mb Written 62.438Mb Total transferred 156.28Mb (2.1231Mb/sec)
135.88 Requests/sec executed
Test execution summary:
total time: 73.6086s
total number of events: 10002
total time taken by event execution: 602.0152
per-request statistics:
min: 0.01ms
avg: 60.19ms
max: 1587.11ms
approx. 95 percentile: 290.98ms
Threads fairness:
events (avg/stddev): 625.1250/42.01
execution time (avg/stddev): 37.6259/2.94
其中主要参数和默认值
--file-num=N 创建测试的文件数量 [128]
--file-block-size=N 块的尺寸,默认是16K 用于测试Oracle一般改为8K[16384]
--file-total-size=SIZE 所有测试文件总的大小[2G]
--file-test-mode=STRING 测试模式 seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)
--file-io-mode=STRING 文件操作模式 sync(同步),async(异步),fastmmap,slowmmap(两种内存映射模式) [sync]
--file-rw-ratio=N 测试时的读写比例 [1.5]
--file-async-backlog=N number of asynchronous operatons to queue per thread [128]
--file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
--file-fsync-all=[on|off] do fsync() after each write operation [off]
--file-fsync-end=[on|off] do fsync() at the end of test [on]
--file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
测试完成之后清理生成的文件
[root@mysql1 sysbench]# ./sysbench --test=fileio --file-num=16 --file-total-size=2G cleanup
sysbench 0.4.12: multi-threaded system evaluation benchmark
Removing test files...
如果出现如下错误,则需要注意 指定的file-num能够被file-total-size 整除
FATAL: Too large position discovered in request!
2.进行CPU基准测试
[root@mysql1 sysbench]# ./sysbench --test=cpu --num-threads=16 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 16
Doing CPU performance benchmark
Threads started!
Done.
Maximum prime number checked in CPU test: 10000
Test execution summary:
total time: 2.5106s
total number of events: 10000
total time taken by event execution: 39.3201
per-request statistics:
min: 0.30ms
avg: 3.93ms
max: 43.80ms
approx. 95 percentile: 15.07ms
Threads fairness:
events (avg/stddev): 625.0000/50.60
execution time (avg/stddev): 2.4575/0.03
3.OLTP基准测试
进行准备
[root@mysql1 sysbench]# ./sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-host=127.0.0.1 --mysql-user=xx --mysql-password=xx --mysql-socket=/home/lihuilin/mysql-5.6.14/mysql.sock --num-threads=15 prepare
sysbench 0.4.12: multi-threaded system evaluation benchmark
No DB drivers specified, using mysql
Creating table 'sbtest'...
Creating 1000000 records in table 'sbtest'...
然后进行测试
[root@mysql1 sysbench]# ./sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-host=127.0.0.1 --mysql-user=xx --mysql-password=xx --mysql-socket=/home/lihuilin/mysql-5.6.14/mysql.sock --num-threads=15 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 15
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations, 1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.
OLTP test statistics:
queries performed:
read: 140000
write: 50000
other: 20000
total: 210000
transactions: 10000 (502.61 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 190000 (9549.53 per sec.)
other operations: 20000 (1005.21 per sec.)
Test execution summary:
total time: 19.8963s
total number of events: 10000
total time taken by event execution: 298.1265
per-request statistics:
min: 11.62ms
avg: 29.81ms
max: 185.70ms
approx. 95 percentile: 42.60ms
Threads fairness:
events (avg/stddev): 666.6667/5.69
execution time (avg/stddev): 19.8751/0.01
相对于TPCC-MySQL,sysbench的测试结果非常直观, 一目了然
感谢各位的阅读!关于“Sysbench基准测试的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
分享标题:Sysbench基准测试的示例分析
标题来源:http://myzitong.com/article/jogogg.html