#!/bin/bash for ((i=1; i<16; i++)); do sysbench cpu run --cpu-max-prime=10000 --threads=4 --time=60 > ${i}.sysbench done sb_result=sysbench_result touch ${sb_result} for ((i=1; i<16; i++)); do cat ${i}.sysbench |grep second|awk -F ':' '{print $2}'|sed 's/ //g' >>${sb_result} done
这里,计算10000之内的素数,使用4个线程cpu,运行时间60秒,连续运行16次。我只取了每秒处理event的数量作为对比。
每次完整输出如下:
sysbench 1.0.9 (using system LuaJIT 2.0.4) Running the test with following options: Number of threads: 4 Initializing random number generator from current time Prime numbers limit: 10000 Initializing worker threads... Threads started! CPU speed: events per second: 3407.83 General statistics: total time: 60.0010s total number of events: 204480 Latency (ms): min: 1.16 avg: 1.17 max: 5.19 95th percentile: 1.18 sum: 239863.00 Threads fairness: events (avg/stddev): 51120.0000/32.89 execution time (avg/stddev): 59.9657/0.00
跑完脚本,数据如下:
3409.49 3410.44 3410.96 3410.67 3410.14 3409.88 3409.03 3407.83 3412.97 3412.47 3410.60 3410.94 3410.71 3410.86 3409.40