测试环境
操作系统:Rocky Linux release 9.2 (Blue Onyx)
云主机:4核8G
测试工具-sysbench
sysbench是一个基于LuaJIT的可脚本多线程基准测试工具
常用于数据库基准测试,当然也是可以用来测试主机性能。
有了这个工具,就不需要再自己写程序,就可以进行主机的基准测试。
sysbench安装
在Rockylinux上可以直接通过epel源直接安装工具。
dnf update -y epel-release
dnf install -y sysbench
CPU测试
通过sysbench cpu help可以查看对应的参数。
--cpu-max-prime=N upper limit for primes generator [10000]
默认指定素数是10000
sysbench --threads=32 --time=30 --report-interval=2 --cpu-max-prime=10000 cpu run
--threads=32:测试线程数为32
--time=30:测试时间
--report-interval=2:显示输出统计是2s
Running the test with following options:
Number of threads: 32
Report intermediate results every 2 second(s)
Initializing random number generator from current time
Prime numbers limit: 10000
Initializing worker threads...
Threads started!
[ 2s ] thds: 32 eps: 28914.97 lat (ms,95%): 1.12
[ 4s ] thds: 32 eps: 28985.22 lat (ms,95%): 1.12
[ 6s ] thds: 32 eps: 28952.48 lat (ms,95%): 1.12
[ 8s ] thds: 32 eps: 28985.91 lat (ms,95%): 1.12
[ 10s ] thds: 32 eps: 28947.79 lat (ms,95%): 1.12
[ 12s ] thds: 32 eps: 28974.74 lat (ms,95%): 1.12
[ 14s ] thds: 32 eps: 28974.41 lat (ms,95%): 1.12
[ 16s ] thds: 32 eps: 28988.54 lat (ms,95%): 1.12
[ 18s ] thds: 32 eps: 28984.86 lat (ms,95%): 1.12
[ 20s ] thds: 32 eps: 28989.35 lat (ms,95%): 1.12
[ 22s ] thds: 32 eps: 28981.76 lat (ms,95%): 1.12
[ 24s ] thds: 32 eps: 28959.09 lat (ms,95%): 1.12
[ 26s ] thds: 32 eps: 28996.98 lat (ms,95%): 1.10
[ 28s ] thds: 32 eps: 28995.49 lat (ms,95%): 1.10
CPU speed:
events per second: 28972.84
General statistics:
total time: 30.0014s
total number of events: 869283
Latency (ms):
min: 1.10
avg: 1.10
max: 7.43
95th percentile: 1.12
sum: 959709.65
Threads fairness:
events (avg/stddev): 27165.0938/84.41
execution time (avg/stddev): 29.9909/0.00
内存测试
sysbench --threads=4 --time=30 --report-interval=1 memory --memory-block-size=8k --memory-total-size=2T --memory-access-mode=seq run
--memory-block-size=8k:指定块大小
--memory-total-size=2T:最大写入大小
--memory-access-mode=seq:seq顺序,rnd是随机
Running the test with following options:
Number of threads: 4
Report intermediate results every 1 second(s)
Initializing random number generator from current timeRunning memory speed test with the following options:
block size: 8KiB
total size: 102400MiB
operation: write
scope: globalInitializing worker threads...
Threads started!
[ 1s ] 2903.00 MiB/sec
[ 2s ] 2896.92 MiB/sec
[ 3s ] 2884.34 MiB/sec
[ 4s ] 2874.30 MiB/sec
[ 5s ] 2872.00 MiB/sec
[ 6s ] 2856.93 MiB/sec
[ 7s ] 2888.23 MiB/sec
[ 8s ] 2913.26 MiB/sec
[ 9s ] 2858.52 MiB/sec
[ 10s ] 2871.02 MiB/sec
[ 11s ] 2854.56 MiB/sec
[ 12s ] 2887.48 MiB/sec
[ 13s ] 2893.52 MiB/sec
[ 14s ] 2903.86 MiB/sec
[ 15s ] 2902.05 MiB/sec
[ 16s ] 2886.12 MiB/sec
[ 17s ] 2891.93 MiB/sec
[ 18s ] 2902.01 MiB/sec
[ 19s ] 2866.51 MiB/sec
[ 20s ] 2893.74 MiB/sec
[ 21s ] 2880.06 MiB/sec
[ 22s ] 2855.68 MiB/sec
[ 23s ] 2875.77 MiB/sec
[ 24s ] 2901.61 MiB/sec
[ 25s ] 2909.31 MiB/sec
[ 26s ] 2889.32 MiB/sec
[ 27s ] 2908.84 MiB/sec
[ 28s ] 2927.31 MiB/sec
[ 29s ] 2875.35 MiB/sec
Total operations: 11087394 (369556.82 per second)86620.27 MiB transferred (2887.16 MiB/sec)
General statistics:
total time: 30.0002s
total number of events: 11087394Latency (ms):
min: 0.00
avg: 0.01
max: 0.39
95th percentile: 0.02
sum: 114753.86Threads fairness:
events (avg/stddev): 2771848.5000/55556.57
execution time (avg/stddev): 28.6885/0.11
测试磁盘写入
sysbench --threads=8 --report-interval=1 fileio --file-num=200000 --file-total-size=20G --file-test-mode=seqwr prepare
生成20w个文件,总大小20G
22937600000 bytes written in 438.70 seconds (49.86 MiB/sec).
清理:
sysbench --threads=8 --report-interval=1 fileio --file-num=200000 --file-total-size=20G --file-test-mode=seqwr cleanup
总结
sysbench还有很多强大的工具,可以根据实际需要进行测试。
本文暂时没有评论,来添加一个吧(●'◡'●)