sysbench性能测试

xiaoxiao2021-04-16  94

sysbench的官网地址是:http://sysbench.sourceforge.net

Step 1: 下载安装: sysbench-0.5.tar.gz 解压后展开目录如下

[root@localhost mnt]# cd sysbench-0.5 [root@localhost sysbench-0.5]# ls aclocal.m4 autom4te.cache config config.status configure.ac doc libtool Makefile Makefile.in mkinstalldirs README-WIN.txt TODO autogen.sh ChangeLog config.log configure COPYING install-sh m4 Makefile.am missing README sysbench [root@localhost sysbench-0.5]#

查看README文件可以看到安装方法:

    ./autogen.sh     ./configure     make     make install  

Sysbench --help可以看到具有以下功能

Compiled-in tests:   fileio - File I/O test  IO性能测试   cpu - CPU performance test CPU性能测试   memory - Memory functions speed test 内存性能测试   threads - Threads subsystem performance test 线程子系统性能测试   mutex - Mutex performance test  互斥测试

Step2  Sysbench CPU性能测试:

Sysbench 测试CPU是通过计算素数的加法运算,它会自动生成素数,并进行相加;一般可以指定最大值,默认10000;

我们用命令:sysbench --test=cpu --cpu-max-prime=20000 run

[root@localhost sysbench-0.5]# 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 随机数生成素数0将会被忽略 Primer numbers limit: 20000 最大素数上线20000 Threads started! Test execution summary: total time: 29.5438s --总共花费时间 total number of events: 10000 --一共计算10000次 total time taken by event execution: 29.5402s --事件(一个素数计算做一个事件)执行时间 per-request statistics: min: 2.48ms --最小计算花费时间 avg: 2.95ms --平均 max: 56.82ms --最大 approx. 95 percentile: 3.85ms --95%的计算花费时间 Threads fairness: events (avg/stddev): 10000.0000/0.00 计算事件总数 execution time (avg/stddev): 29.5402/0.00 计算花费时间总数

可以看到压测的时候CPU被sysbench占满了;

Step3: IO测试:

sysbench --test=fileio help fileio options:   --file-num=N                  number of files to create [128] 创建文件数量,默认128   --file-block-size=N           block size to use in all IO operations [16384] 块儿大小,默认16384,即Innodb的存储引擎Page大小;如果要测试Innodb就用默认;   --file-total-size=SIZE        total size of files to create [2G] 生成测试文件的总大小   --file-test-mode=STRING       test mode {seqwr(顺序写)、seqrewr(顺序读写)、seqrd(顺序读)、rndrd(随机读)、rndwr(随机写)和rndrw(随机读写)}   --file-io-mode=STRING          文件IO模式,同步/异步/快速映射/慢映射{sync,async,fastmmap,slowmmap} [sync]。   --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]执行写入fsync()的频率,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] 合并改数量的IO请求   --file-rw-ratio=N             reads/writes ratio for combined test [1.5]。 写/读组合比测试,默认1:1.5

sysbench的fileio测试需要经过prepare、run和clean三个阶段。

prepare是准备阶段,生产我们需要的测试文件run是实际测试阶段cleanup是清理测试产生的文

sysbench --test=fileio --file-num=16 --file-total-size=2G prepare  生成16个测试文件,总大小2G

此时会生成测试文件,因为总大小2G,数量16个,所以每个文件约129M;

 sysbench --test=fileio --file-num=16 --file-total-size=2G  --file-test-mode=rndrw run 采用随机读写的方式测试:

[root@localhost mnt]# sysbench --test=fileio --file-num=16 --file-total-size=2G --file-test-mode=rndrw run --测试模式,随机读写 sysbench 0.5: multi-threaded system evaluation benchmark Running the test with following options: Number of threads: 1 --线程1个 Random number generator seed is 0 and will be ignored Threads started! Operations performed: 6000 reads, 4000 writes, 1600 Other = 11600 Total 6000次读,4000次写(因为默认1.5:1)1600次其他操作; Read 93.75Mb Written 62.5Mb Total transferred 156.25Mb (276.57Mb/sec) 随机读了93.75M数据,写了62.5M数据 总IO 156.25M 17700.40 Requests/sec executed 每秒执行17700次 Test execution summary: total time: 0.5650s 总耗费时间 total number of events: 10000 读写次数10000次 total time taken by event execution: 0.3961s 读写花费时间 per-request statistics: min: 0.00ms 最小时间 avg: 0.04ms 平均时间 max: 20.24ms 最大时间 approx. 95 percentile: 0.08ms 95%读写花费时间 Threads fairness: events (avg/stddev): 10000.0000/0.00 execution time (avg/stddev): 0.3961/0.00

sysbench --test=fileio --file-num=16 --file-total-size=2G  --file-test-mode=rndrw cleanup 最后执行clearnup清除测试数据

 

Step 4: 线程测试:

 sysbench --num-threads=64 --test=threads --thread-yields=2000 --thread-locks=2 run 

并发线程64,采用线程测试方法,每个请求产生2000个线程,每个线程锁2个;

[root@localhost sysbench-0.5]# sysbench --test=threads --num-threads=64 --thread-yields=2000 --thread-locks=2 run sysbench 0.5: multi-threaded system evaluation benchmark Running the test with following options: Number of threads: 64 --并发线程64个 Random number generator seed is 0 and will be ignored Threads started! Test execution summary: total time: 15.7261s total number of events: 10000 total time taken by event execution: 1004.5724s per-request statistics: min: 0.58ms avg: 100.46ms max: 1049.29ms approx. 95 percentile: 246.15ms Threads fairness: events (avg/stddev): 156.2500/7.99 execution time (avg/stddev): 15.6964/0.02

Step5: 内存测试

sysbench   --num-threads=64 --test=memory --memory-block-size=8k --memory-total-size=16G --memory-scope=global --memory-access-mode=rnd run

[root@localhost sysbench-0.5]# sysbench --num-threads=64 --test=memory --memory-block-size=8k --memory-total-size=16G --memory-scope=global --memory-access-mode=rnd run sysbench 0.5: multi-threaded system evaluation benchmark Running the test with following options: Number of threads: 64 Random number generator seed is 0 and will be ignored Threads started! Operations performed: 2097152 (3690132.19 ops/sec) 16384.00 MB transferred (28829.16 MB/sec) Test execution summary: total time: 0.5683s total number of events: 2097152 total time taken by event execution: 20.6291s per-request statistics: min: 0.00ms avg: 0.01ms max: 351.43ms approx. 95 percentile: 0.00ms Threads fairness: events (avg/stddev): 32768.0000/8682.67 execution time (avg/stddev): 0.3223/0.06 [root@localhost sysbench-0.5]#

 

转载请注明原文地址: https://www.6miu.com/read-4818078.html

最新回复(0)