今天笔者来测试使用sysbench性能测试工具。
笔者在树莓派上安装这个工具, apt search sysbench搜索sysbench,Cross-platform and multi-threaded benchmark tool。然后安装sudo apt install sysbench。安装完成后,使用 sysbench --help来查看工具使用说明:
1、磁盘IO测试, fileio - File I/O test
2、CPU性能测试, cpu - CPU performance test
3、内存速度测试, memory - Memory functions speed test
4、线程调度测试, threads - Threads subsystem performance test
5、POSIX线程性能测试, mutex - Mutex performance test
6、数据库性能测试, oltp - OLTP test
![](https://img.haomeiwen.com/i24447700/451da1b047862d9a.png)
针对具体的测试项目,可以使用sysbench --test=<name> help 来查看使用方法。接下里笔者根据说明的说明信息一个个来测试。
1、cpu性能测试
sysbench --test=cpu help可以查看参数信息,查看后只有一个: --cpu-max-prime=N , upper limit for primes generator [10000]。cpu测试主要是进行素数的加法运算,笔者指定最大素数是100,可以得到计算的报告。
sysbench --test=cpu --cpu-max-prime=100 run
![](https://img.haomeiwen.com/i24447700/7331c84f30cf1195.png)
2、内存性能测试
内存中传输 1G 的数据量,每个 block 大小为 100K。注意memory-block-size或者其他参数的容量,比如K,M,G都是大写,笔者写成了小写k后一直显示Memory block size: 0K,等待很长时间都不输出报告。
sysbench --test=memory --memory-block-size=100K --memory-total-size=1G run
![](https://img.haomeiwen.com/i24447700/2c2033c72b836d6c.png)
3、线程调度测试
发送4个测试线程请求,每个线程请求产生/生成100个数量,每个线程的锁数量为2。
sysbench --test=threads --num-threads=4 --thread-yields=100 --thread-locks=2 run
![](https://img.haomeiwen.com/i24447700/c596f303f061c001.png)
4、磁盘IO性能测试
进行磁盘IO测试,指定了最大创建4个线程,创建的文件总大小为512M,文件读写模式为随机读。测试分为三个步骤,数据准备,数据测试,数据删除。数据准备会生成128 files在本目录下。
sysbench --test=fileio --num-threads=4 --file-total-size=512M --file-test-mode=rndrw prepare
sysbench --test=fileio --num-threads=4 --file-total-size=512M --file-test-mode=rndrw run
sysbench --test=fileio --num-threads=4 --file-total-size=512M --file-test-mode=rndrw cleanup
笔者只截取部分测试报告截图:
![](https://img.haomeiwen.com/i24447700/7ecb8d1dbecb3093.png)
5、 数据库性能 OLTP 测试
这个部分有点复杂,笔者在下次使用树莓派、虚拟机、docker容器和windows平台下测试对比数据库的性能。
网友评论