#!/bin/bash
Pname=$1
ioppPATH=/usr/src/iopp/
Count=$2
if [ "$Pname" = "" ]
then
echo "请输入1个进程名,如qemu-kvm"
exit
fi
if [ "$Count" = "" ]
then
Count=5
fi
if [ -d $ioppPATH ]
then
if [ ! -f ${ioppPATH}iopp ]
then
cd $ioppPATH && wget http://download.ksyoulee.org/linux/iopp.c
gcc -o iopp iopp.c
fi
else
mkdir $ioppPATH
if [ ! -f ${ioppPATH}iopp ]
then
cd $ioppPATH && wget http://download.ksyoulee.org/linux/iopp.c
gcc -o iopp iopp.c
fi
fi
${ioppPATH}iopp -c -i 1 $Count > /tmp/iopstest
awk -***=$Pname '$0~pn{++i;b+=$4+$5}END{print b/i}' /tmp/iopstest