测试 1、CPU测试
sysbench采用寻找最大素数的方式来测试CPU的性能
# sysbench --test=cpu --cpu-max-prime=20000 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Doing CPU performance benchmark
Threads started!
Done.
Maximum prime number checked in CPU test: 20000
Test execution summary:
total time: 27.3193s
total number of events: 10000
total time taken by event execution: 27.3180
per-request statistics:
min: 2.73ms
avg: 2.73ms
max: 3.09ms
approx. 95 percentile: 2.73ms
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 27.3180/0.00
2、线程数测试
thread-locks小于线程数除以2,lock越少,处理时间越长
# sysbench --test=threads --num-threads=512 --thread-yields=100 --thread-locks=2 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 512
Doing thread subsystem performance test
Thread yields per test: 100 Locks used: 2
Threads started!
Done.
Test execution summary:
total time: 0.2999s
total number of events: 10000
total time taken by event execution: 143.0588
per-request statistics:
min: 0.03ms
avg: 14.31ms
max: 290.74ms
approx. 95 percentile: 86.57ms
Threads fairness:
events (avg/stddev): 19.5312/15.16
execution time (avg/stddev): 0.2794/0.01
3、磁盘IO性能测试
文件的大小:测试文件的大小应该大于内存,如果测试数据过小,内存缓存文件数据,则不能表示为一种i/o密集型的工作负载;
测试模式:
rndrw:合并的随机读写
rndwr:随机写入
rndrd:随机读取
seqrewr:顺序重写
seqwr:顺序写
生成测试文件à
首先生成需要的测试文件,文件总大小18G(DELL 服务器内存为16G),16个并发线程,随机读写模式。执行完后会在当前目录下生成一堆小文件:
# sysbench --test=fileio --num-threads=16 --file-total-size=18G --file-test-mode=rndrw prepare
sysbench 0.4.12: multi-threaded system evaluation benchmark
128 files, 147456Kb each, 18432Mb total
Creating files for the test...
开始测试à
# sysbench --test=fileio --num-threads=16 --file-total-size=18G --file-test-mode=rndrw 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
128 files, 144Mb each
18Gb 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: 5999 Read, 4001 Write, 12800 Other = 22800 Total
Read 93.734Mb Written 62.516Mb Total transferred 156.25Mb (3.0139Mb/sec)
192.89 Requests/sec executed
Test execution summary:
total time: 51.8439s
total number of events: 10000
total time taken by event execution: 42.6517
per-request statistics:
min: 0.00ms
avg: 4.27ms
max: 1194.64ms
approx. 95 percentile: 18.29ms
Threads fairness:
events (avg/stddev): 625.0000/94.90
execution time (avg/stddev): 2.6657/0.45
i/o子系统调整的主要信息:每秒的请求数量和总体的吞吐量:每秒192.89 个请求,每秒3.0139Mb传输量。
清理现场à
# sysbench --test=fileio --num-threads=16--file-total-size=18G --file-test-mode=rndrw cleanup
sysbench 0.4.12: multi-threaded system evaluation benchmark
Removing test files...
4、内存测试
下面的参数指定了本次测试整个过程是在内存中传输 4G 的数据量,每个block大小为8K。
# sysbench --test=memory --num-threads=64 --memory-block-size=8192 --memory-total-size=4G run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 64
Doing memory operations speed test
Memory block size: 8K
Memory transfer size: 4096M
Memory operations type: write
Memory scope type: global
Threads started!
Done.
Operations performed: 524288 (942532.69 ops/sec)
4096.00 MB transferred (7363.54 MB/sec)
Test execution summary:
total time: 0.5563s
total number of events: 524288
total time taken by event execution: 21.2037
per-request statistics:
min: 0.00ms
avg: 0.04ms
max: 478.24ms
approx. 95 percentile: 0.00ms
Threads fairness:
events (avg/stddev): 8192.0000/6258.63
execution time (avg/stddev): 0.3313/0.06