码迷,mamicode.com
首页 > 其他好文 > 详细

sysbench安装及做性能测试

时间:2015-09-13 20:07:22      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:following   system   command   文件夹   number   

一、安装过程:

先下载依赖包
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、cpu性能测试:

[root@mysql5 ~]# sysbench --test=cpu --cpu-max-prime=20000 run


sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored


Primer numbers limit: 20000

Threads started!


Test execution summary:
    total time:                          25.0785s
    total number of events:              10000
    total time taken by event execution: 25.0757s
    per-request statistics:
         min:                                  2.28ms
         avg:                                  2.51ms
         max:                                  6.55ms
         approx.  95 percentile:               2.89ms

Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   25.0757/0.00

CPU性能测试有一个需要注意的地方,上面的测试只使用了一个线程,如果在两个cpu processor不同的电脑上做比较,这是不公平的。公平的做法是指定合理的线程数,如下所示:

[root@mysql5 lib]# sysbench --test=cpu --num-threads=`grep "processor" /proc/cpuinfo | wc -l` --cpu-max-prime=200000 run


[root@mysql5 data]# top

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                        

10029 root      20   0 18172 1220  884 S 99.9  0.1   7:49.94 sysbench                                                                                                        

    1 root      20   0 19232 1384 1088 S  0.0  0.1   0:01.27 init                                                                                                            

    2 root      20   0     0    0    0 S  0.0  0.0   0:00.01 kthreadd                                                                                                        

    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                                                                      

    4 root      20   0     0    0    0 S  0.0  0.0   0:02.08 ksoftirqd/0                                                                                                      

    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/0


[root@mysql5 lib]# sysbench --test=cpu --num-threads=`grep "processor" /proc/cpuinfo | wc -l` --cpu-max-prime=200000 run
sysbench 0.5:  multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored
Primer numbers limit: 200000
Threads started!
Test execution summary:
 
   total time:                          601.4066s
    total number of events:              10000
    total time taken by event execution: 601.3990s
    per-request statistics:
         min:                                 57.77ms
         avg:                                 60.14ms
         max:                                103.32ms
         approx.  95 percentile:              63.47ms
Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   601.3990/0.00



2、线程测试:

[root@mysql5 ~]# sysbench --test=threads --number-threads=64 --threads-yields=100 --threads-locks=2 run



sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored


Threads started!


Test execution summary:
    total time:                          2.1750s
    total number of events:              10000
    total time taken by event execution: 2.1741s
    per-request statistics:
         min:                                  0.17ms
         avg:                                  0.22ms
         max:                                  1.52ms
         approx.  95 percentile:               0.29ms

Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   2.1741/0.00


[root@mysql5 ~]# 



3、磁盘IO性能测试:


[root@mysql5 ~]# sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw prepare
sysbench 0.5:  multi-threaded system evaluation benchmark

[root@mysql5 ~]# sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw run    
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16
Random number generator seed is 0 and will be ignored


Threads started!

Operations performed:  6005 reads, 3995 writes, 12800 Other = 22800 Total
Read 93.828Mb  Written 62.422Mb  Total transferred 156.25Mb  (2.9214Mb/sec)
  186.97 Requests/sec executed

Test execution summary:
    total time:                          53.4846s
    total number of events:              10000
    total time taken by event execution: 546.8636s
    per-request statistics:
         min:                                  0.00ms
         avg:                                 54.69ms
         max:                                748.10ms
         approx.  95 percentile:             190.17ms

Threads fairness:
    events (avg/stddev):           625.0000/31.96
    execution time (avg/stddev):   34.1790/0.91

[root@mysql5 ~]# sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw cleanup
sysbench 0.5:  multi-threaded system evaluation benchmark

[root@mysql5 ~]# 

如果需要测试seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)6种模式,并且还可能需要测试不同的线程和不同的文件块下磁盘的性能表现,这时,可以使用如下脚本达到测试目的。



4、内存测试:

[root@mysql5 ~]# sysbench --test=memory --memory-block-size=8k --memory-total-size=4G run



sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored


Threads started!

Operations performed: 524288 (1031670.94 ops/sec)

4096.00 MB 
transferred (8059.93 MB/sec)


Test execution summary:
    total time:                          0.5082s
    total number of events:              524288
    total time taken by event execution: 0.4682s
    per-request statistics:
         min:                                  0.00ms
         avg:                                  0.00ms
         max:                                  0.47ms
         approx.  95 percentile:               0.00ms

Threads fairness:
    events (avg/stddev):           524288.0000/0.00
    execution time (avg/stddev):   0.4682/0.00

[root@mysql5 ~]# 



5、OLTP测试:

[root@mysql5 ~]# sysbench --test=oltp --mysql-table-engine=myisam --loltp-table-size=1000000 --mysql-socket=/tmp/mysql.sock --mysql-user=root --mysql-host=localhost --mysql-password=dongbo prepare
sysbench 0.5:  multi-threaded system evaluation benchmark

PANIC: unprotected error in call to Lua API (cannot open oltp: No such file or directory)
[root@mysql5 ~]# 

此步骤测试失败:0.5版本所有OLTP都是通过lua脚本进行测试的;

测试过程:


[root@mysql5 sysbench]# ./sysbench  --test=./tests/db/oltp.lua  --debug=yes --mysql-host=localhost --mysql-socket=/tmp/mysql.sock --mysql-db=test --mysql-user=root --mysql-password=dongbo --mysql-table-engine=innodb  --max-requests=0 --max-time=60 --num-threads=16 --oltp-table-size=100000 --report-interval=10 prepare


sysbench 0.5:  multi-threaded system evaluation benchmark

Creating table ‘sbtest1‘...
Inserting 100000 records into ‘sbtest1‘
[root@mysql5 sysbench]# ./sysbench  --test=./tests/db/oltp.lua  --debug=yes --mysql-host=localhost --mysql-socket=/tmp/mysql.sock --mysql-db=test --mysql-user=root --mysql-password=dongbo --mysql-table-engine=innodb  --max-requests=0 --max-time=60 --num-threads=16 --oltp-table-size=100000 --report-interval=10 run   

 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored
Threads started!

[  10s] threads: 16, tps: 266.12, reads/s: 3747.83, writes/s: 1067.69
[  20s] threads: 16, tps: 261.51, reads/s: 3660.58, writes/s: 1046.42
[  30s] threads: 16, tps: 253.20, reads/s: 3545.64, writes/s: 1015.61
[  40s] threads: 16, tps: 260.89, reads/s: 3647.35, writes/s: 1041.16
[  50s] threads: 16, tps: 229.60, reads/s: 3219.47, writes/s: 920.79
[  60s] threads: 16, tps: 266.11, reads/s: 3725.40, writes/s: 1059.66
OLTP test statistics:
    queries performed:
        read:                            215474
        write:                           61564
        other:                           30782
        total:                           307820
    transactions:                        15391  (256.46 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 277038 (4616.26 per sec.)
    other operations:                    30782  (512.92 per sec.)

Test execution summary:
    total time:                          60.0136s
    total number of events:              15391
    total time taken by event execution: 959.8978s
    per-request statistics:
         min:                                  8.79ms
         avg:                                 62.37ms
         max:                                727.83ms
         approx.  95 percentile:              99.97ms

Threads fairness:
    events (avg/stddev):           961.9375/8.31
    execution time (avg/stddev):   59.9936/0.00

[root@mysql5 sysbench]# ./sysbench  --test=./tests/db/oltp.lua  --debug=yes --mysql-host=localhost --mysql-socket=/tmp/mysql.sock --mysql-db=test --mysql-user=root --mysql-password=dongbo --mysql-table-engine=innodb  --max-requests=0 --max-time=60 --num-threads=16 --oltp-table-size=100000 --report-interval=10 cleanup


sysbench 0.5:  multi-threaded system evaluation benchmark

Dropping table ‘sbtest1‘...
[root@mysql5 sysbench]# 
[root@mysql5 sysbench]# 


6、互斥锁(mutex)


[root@mysql5 data]# sysbench --test=mutex  --num-threads=16 --mutex-num=2048 --mutex-locks=100000000 --mutex-loops=5000 run
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16
Random number generator seed is 0 and will be ignored
Threads started!


Test execution summary:
    total time:                          67.8070s
    total number of events:              16
    total time taken by event execution: 1081.9077s
    per-request statistics:
         min:                              67240.36ms
         avg:                              67619.23ms
         max:                              67802.58ms
         approx.  95 percentile:         10000000.00ms

Threads fairness:
    events (avg/stddev):           1.0000/0.00
    execution time (avg/stddev):   67.6192/0.17

[root@mysql5 data]# 





本文出自 “MySQL_db” 博客,请务必保留此出处http://mysqldb.blog.51cto.com/10264653/1694303

sysbench安装及做性能测试

标签:following   system   command   文件夹   number   

原文地址:http://mysqldb.blog.51cto.com/10264653/1694303

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!