#!/bin/bash
#循环10次测试cpu、内存性能,每次测量间隔30s,计算无负载时cpu、内存平均值
cpu_res_event=0
cpu_res_time=0.0
for ((m=1;m<=10;m++))
do
## 素数上限2万,默认10秒,2个线程
cmd=`sysbench cpu --cpu-max-prime=20000 --threads=2 run > tmp_cpu_result`
#cpu_res_event_total=`cat tmp_cpu_result | grep 'total number of events' | awk '{print $5}'`
##取总耗时带单位,需做处理
cpu_res_total_time_tmp=`cat tmp_cpu_result | grep 'total time' | awk '{print $3}'`
cpu_res_total_time=${cpu_res_total_time_tmp%s}
#cpu_res_event=`expr $cpu_res_event + $cpu_res_event_total`
cpu_res_time_tmp=`echo $cpu_res_total_time + $cpu_res_time | bc`
cpu_res_time=`printf "%2.4f\n" $cpu_res_time_tmp`
#echo $cpu_res_event
echo $cpu_res_time
done