shell脚本用sysbench测试cpu内存性能

#!/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
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值