在系统优化-内存优化分析过程中针对不同策略需要统计内存变化,检验是否有效。修改一些策略可能影响系统性能,因此需要多方面对比评估,如cpu占有率、io变化情况、长时间运行内存变化情况等。
如果一个策略实施后,通过一次两次去查看各方面数据,显然是不准确和繁琐的。需要在一定时间内连续检查个方便性能的变化,并统计数据,对比采取具体措施前后性能的变化,也可以排除长时间运行,该策略导致运行一段时间后,整体性能较差。
采集的性能数据主要来自命令如下:
性能影响分析,涉及两个方面的脚本实现
使用方式
mkdir /data/log
chmod 777 /data/log
// 改权限
chmod 777 cpu_mem.sh
// 命令根据实际需求选择
// usage: ./cpu_mem.sh 间隔时间(单位秒) 抓取时间(单位分) 停止抓取时间(单位分)
// usage: ./cpu_mem.sh interval_time capture_time sleep_time
// 有些命令需要循环执行才能抓取道数据,间隔时间就是循环的间隔;抓取时间为持续抓取时间;停止抓取时间是停止抓log一段时间后再开始新的一轮抓取,新的一轮log产生新的文件,方便统计系统持续运行不同时间段,性能是否有变化
// 命令1:间隔3秒抓取一次,抓取10分钟体停止
./cpu_mem.sh 3 10
// 命令2:间隔4秒抓取一次 抓取20分钟 停止10分钟后再开始抓取
./cpu_mem.sh 4 20 10
// 命令3:间隔5秒,一直抓取
./cpu_mem.sh 5
抓取的log文件,如
20190520_opted$ tree
.
├── analyze_result.txt
├── analyze_result - 副本.txt
├── cpu_201905061206.txt
├── cpu_201905061216.txt
├── kernel_201905061206.txt
├── kernel_201905061216.txt
├── logcat_201905061206.txt
├── logcat_201905061216.txt
├── mem_201905061206.txt
├── mem_201905061216.txt
├── top_201905061206.txt
└── top_201905061216.txt
analyze_result.txt是分析统计的结果数据。部分统计数据如下:
可用内存 206.30 235.41 223.54 231.19 233.53 225.79 228.36
PSS缓存 21.51 21.51 21.51 21.51 21.51 21.51 21.51 21.51 21.51
kernel缓存 2.43 46.79 24.65 2.43 2.76 3.43 3.77 4.11 4.49 4.84
实际剩余 139.76 209.26 177.37 207.26 209.26 200.85 203.08
Native 69.21 70.06 69.51 69.47 69.47 69.48 69.51 69.39
System 70.48 71.59 71.06 71.05 71.31 71.00 70.48 70.52
iandos 133.83 158.17 144.89 138.11 136.66 134.76 139.88
TOTAL 63.00 69.00 65.28 68.00 65.00 66.00 65.00 67.00 65.00
iandos 32.00 43.00 38.32 43.00 34.00 37.00 41.00 35.00
cameraserver 6.00 8.00 6.99 8.00 7.00 7.00 7.00 7.00 7.00
surfaceflinger 5.00 7.00 5.15 7.00 5.00 5.00 5.00 5.00
system_server 0.00 19.00 10.22 6.00 17.00 6.00 12.00 13.00
每一个统计项的前三项数据分别为:最小值、最大值、平局值,后面的数据为实际性能数据
可以把该数据使用execl导入txt文档数据的方法导入excel,输出曲线图,清晰的展现长时间运行性能变化
延伸使用
有些问题是频繁开关机导致,因此开机需要抓取log,该脚本可以通过vbs脚本结合CRT工具,系统开机运行该脚本,并统计开关机次数,vbs脚本如下
#$language="VBScript"
#$interface="1.0"
Sub main
While 1
crt.Screen.WaitForString "Starting kernel"
crt.Sleep 1000
crt.Screen.Send vbCr
do Until crt.Screen.WaitForStrings("shell@rk3288:/ $",1)
crt.Screen.Send vbCr
loop
crt.Screen.Send "su;echo 0 > /proc/sys/kernel/printk" & vbCr
crt.Sleep 1000
crt.Screen.Send "./data/log/cpu_mem.sh&" & vbCr
crt.Sleep 1000
crt.Screen.Send "logcat -v time" & vbCr
crt.Sleep 60000
crt.Screen.SendKeys "^C" & vbCr
do Until crt.Screen.WaitForStrings("root@rk3288:/ #",1)
crt.Screen.SendKeys "^C" & vbCr
loop
crt.Screen.Send "reboot" & vbCr
WEnd
End Sub
分析log,抓取数据,需要根据实际需要自行定制脚本,在固定的应用场景,脚本实现完成后,可以延续使用
把设备上抓取的log数据拿出来,放在linux服务器上(samba映射目录),使用各方面脚本分析或者使用总脚本全面分析。
summary_cpu.sh使用方式
./summary_cpu.sh cpu_201905061206.txt
或者
./summary_cpu.sh top_201905061206.txt
都可以分析出cpu\top的结果。
目前脚本分析了以下字段:TOTAL(总的cpu使用率变化)、cameraserver等cpu使用率变化
calc_cpu_item $file TOTAL
......
calc_top_item $file iandos
calc_top_item $file cameraserver
calc_top_item $file surfaceflinger
calc_top_item $file system_server
代码详见附件
其他方面统计方式同理
使用summary.sh分析统计各方面的log数据,给脚本传递的参数可以需要统计的任一方面的log文件,如
./summary.sh cpu_201905061206.txt
或
./summary.sh mem_201905061206.txt
或
./summary.sh logcat_201905061206.txt
注意: kernel log没有做分析,主要用来记录在抓取数据阶段是否出现严重问题,或者出现严重问题,方便配合其他log分析问题
代码如下
if [ x"$1" = x -o ! -f "$1" ];then
echo error:file:$1 is not exist!
exit -1
fi
if [ -f ./analyze_result.txt ];then
rm ./analyze_result.txt
fi
file=$(echo $1 | sed -e 's/.*_\([0-9]*\)\.txt/mem_\1.txt/')
echo file: $file
echo ------------------------
./summary_mem.sh $file
echo
file=$(echo $1 | sed -e 's/.*_\([0-9]*\)\.txt/top_\1.txt/')
echo file: $file
echo ------------------------
./summary_cpu.sh $file
file=$(echo $1 | sed -e 's/.*_\([0-9]*\)\.txt/logcat_\1.txt/')
echo file: $file
echo ------------------------
./summary_iandos.sh $file
echo
cpu_mem.sh脚本代码
#!/system/bin/sh
# usb storage
# logdir="/storage/udisk3/log/"
logdir="/data/log/"
if [ ! -d $logdir ];then
mkdir -p $logdir
fi
function _help()
{
echo "Usage:./cpu_mem.sh interval_time running_time interval_big"
echo Set param is opton.
}
interval_time=3
if [ $# -gt 1 ] && [ $1 -gt 3 ];then
interval_time=$1
fi
running_time=0
if [ x$2 != x ];then
let running_time=$2*60
fi
interval_big=0
if [ x$3 != x ];then
if [ $3 -gt 0 ];then
let interval_big=$3*60
fi
fi
mdate=`date "+%Y%m%d%H%M"`
echo interval_time: $interval_time
echo running_time: $running_time
echo interval_big: $interval_big
echo
if [ ! -f ${logdir}/.count.txt ];then
echo 0 > ${logdir}/.count.txt
fi
count=`cat ${logdir}/.count.txt`
if [ $count -gt 0 ];then
echo "--------------------- new reboot--$count" >> ${logdir}/kernel_${mdate}.txt
echo "--------------------- new reboot--$count" >> ${logdir}/cpu_${mdate}.txt
echo "--------------------- new reboot--$count" >> ${logdir}/mem_${mdate}.txt
fi
((count++))
echo $count > ${logdir}/.count.txt
function killSubprocess()
{
bExit=1
if [ $# -eq 0 ];then
bExit=0
fi
for pid in `jobs -p`
do
echo "sub process:$pid"
kill 9 $pid;
done
if [ $bExit -eq 1 ];then
echo "exit cpu_mem.sh by signal!!!"
exit 0
fi
}
trap "echo exit by signal 2;killSubprocess 1" 2
trap "echo exit by signal 2;killSubprocess 1" 9
trap "echo ignore signal 15" 15
function my_command()
{
if [ x"$*" != x ];then
$*
echo
fi
}
cat_kernel=0
top_tag=0
logcat_tag=0
start_time=$(date +%s)
while [ 1 -eq 1 ]
do
if [ $cat_kernel -eq 0 ];then
cat /proc/kmsg >> ${logdir}/kernel_${mdate}.txt &
cat_kernel=1
fi
if [ $top_tag -eq 0 ];then
top -d $interval_time -m 10 >> ${logdir}/top_$mdate.txt &
top_tag=1
fi
if [ $logcat_tag -eq 0 ];then
logcat -c
logcat -v time > ${logdir}/logcat_$mdate.txt &
logcat_tag=1
fi
{
# date
# my_command busybox mpstat -P ALL
# my_command vmstat
# my_command busybox iostat
# my_command cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
my_command dumpsys cpuinfo
} >> ${logdir}/cpu_${mdate}.txt
{
date
my_command cat /proc/meminfo
my_command dumpsys meminfo
# dumpsys meminfo com.iandos.icetech
} >> ${logdir}/mem_${mdate}.txt
sleep $interval_time
if [ $running_time -ne 0 ];then
cur_time=$(date +%s)
diff_time=$((cur_time-start_time))
if [ ${diff_time} -ge ${running_time} ];then
echo run time: $diff_time
killSubprocess
if [ $interval_big -eq 0 ];then
echo -----exit----- break
break;
else
top_tag=0
logcat_tag=0
cat_kernel=0
echo --------${interval_big}-
sleep ${interval_big}
echo --------${interval_big}-countinue
start_time=$(date +%s)
mdate=`date "+%Y%m%d%H%M"`
fi
fi
fi
done
summary_cpu.sh代码
function calc_cpu_item()
{
if [ x"$1" = x -o ! -f "$1" ];then
echo error:file:$1 is not exist!
exit -1
fi
file=$(echo $1 | sed 's/ //g')
key_word=$(echo $2 | sed 's/ //g')
echo key_word: $key_word
case $key_word in
TOTAL)
echo -n "$key_word " >> analyze_result.txt
cat ${file} | grep "$key_word" | \
awk '{print $1}' | sed 's/%//g' | \
awk 'BEGIN {min=100;max=0;i=0;sum=0;array[i]=0}
{sum+=$0;if(min>$0) min=$0;if(max<$0) max=$0;array[i]=$0;i++}
END {
printf("%.2f %.2f %.2f ",min,max,sum/i);
for(j=0;j < i;j++) {
printf("%.2f ",array[j])
}
printf("\n");
}' >> analyze_result.txt
;;
*)
echo param exist error!
esac
}
function calc_top_item()
{
if [ x"$1" = x -o ! -f "$1" ];then
echo error:file:$1 is not exist!
exit -1
fi
file=$(echo $1 | sed 's/ //g')
key_word=$(echo $2 | sed 's/ //g')
echo key_word: $key_word
case $key_word in
cameraserver)
;&
surfaceflinger)
;&
system_server)
;&
iandos)
echo -n "$key_word " >> analyze_result.txt
cat ${file} | grep "$key_word" | \
awk '{print $5}' | sed 's/%//g' | \
awk 'BEGIN {min=100;max=0;i=0;sum=0;array[i]=0}
{sum+=$0;if(min>$0) min=$0;if(max<$0) max=$0;array[i]=$0;i++}
END {
printf("%.2f %.2f %.2f ",min,max,sum/i);
for(j=0;j < i;j++) {
printf("%.2f ",array[j])
}
printf("\n");
}' >> analyze_result.txt
;;
*)
echo param exist error!
esac
}
file=$(echo $1 | sed -e 's/.*_\([0-9]*\)\.txt/cpu_\1.txt/')
echo file: $file
echo ------------------------
calc_cpu_item $file TOTAL
echo
file=$(echo $1 | sed -e 's/.*_\([0-9]*\)\.txt/top_\1.txt/')
echo file: $file
echo ------------------------
calc_top_item $file iandos
calc_top_item $file cameraserver
calc_top_item $file surfaceflinger
calc_top_item $file system_server
echo
if [ -f ./analyze_result.txt ];then
echo "" >> analyze_result.txt
fi
summary_mem.sh代码
function calc_mem_item()
{
file=$(echo $1 | sed 's/ //g')
key_word=$(echo $2 | sed 's/ //g')
modify_key_word=0
case $key_word in
Native)
echo key_word: $key_word
cat $file | grep --after-context=1 "by OOM adjustment:$" | grep "Native" | \
sed 's/[^0-9]*\([1-9][0-9]*\),\([0-9].*\)K.*/\1\2/g' | \
awk 'BEGIN {min=999999;max=0;sum=0;i=0} {if(min>$0) min=$0;if(max<$0)max=$0;sum+=$0;i++}END{print "i="i" min="min" max="max" avg="sum/i}'
;;
Perceptible)
;&
System)
echo key_word: $key_word
cat $file | grep "$key_word" | \
sed 's/[^0-9]*\([1-9][0-9]*\),\([0-9].*\)K.*/\1\2/g' | \
awk 'BEGIN {min=999999;max=0;sum=0;i=0} {if(min>$0) min=$0;if(max<$0)max=$0;sum+=$0;i++}END{print "i="i" min="min" max="max" avg="sum/i}'
;;
zygote)
modify_key_word=1
cat $file | grep "$key_word" | awk 'NR%2==1{print $0}' > .temp_file
file=.temp_file
;&
Dalvik)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1;
key_word="${key_word}\$"
fi
;&
iandos)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1;
key_word="${key_word}.registration"
cat $file | grep "$key_word" | awk 'NR%2==1{print $0}' > .temp_file
file=.temp_file
fi
;&
Dalvik_Other)
if [ $modify_key_word -eq 0 ];then
key_word=$(echo ${key_word} | sed 's/_/ /')
fi
echo key_word: $key_word
cat $file | grep "$key_word" | \
awk '{print $1}' | sed 's/,//g;s/K://g' | \
awk 'BEGIN {i=0;sum=0;min=9999999;max=0;}
{sum+=$0;if(min>$0) min=$0;if(max<$0) max=$0;i++}
END {print "i="i; print "min="min" max="max" avg="sum/i;}'
;;
FreeMem)
echo key_word: $key_word
cat $file | grep "Free RAM:" | \
awk '{print $3" "$5" "$9" "$13}' | \
sed 's/,//g;s/K//g' | awk 'BEGIN{
RAM_MIN=9999999;RAM_MAX=0;ram_sum=0;
PSS_MIN=9999999;PSS_MAX=0;pss_sum=0;
KER_MIN=9999999;KER_MAX=0;ker_sum=0;
FRE_MIN=9999999;FRE_MAX=0;fre_sum=0;
i=0}
{
if(RAM_MIN>$1) RAM_MIN=$1;if(RAM_MAX<$1) RAM_MAX=$1;ram_sum+=$1;
if(PSS_MIN>$2) PSS_MIN=$2;if(PSS_MAX<$2) PSS_MAX=$2;pss_sum+=$2;
if(KER_MIN>$3) KER_MIN=$3;if(KER_MAX<$3) KER_MAX=$3;ker_sum+=$3;
if(FRE_MIN>$4) FRE_MIN=$4;if(FRE_MAX<$4) FRE_MAX=$4;fre_sum+=$4;i++
} END {
print "i="i;
print "Free RAM:MIN="RAM_MIN" MAX="RAM_MAX" AVG="ram_sum/i;
print "cached pss:MIN="PSS_MIN" MAX="PSS_MAX" AVG="pss_sum/i;
print "cached kernel:MIN="KER_MIN" MAX="KER_MAX" AVG="ker_sum/i;
print "free:MIN="FRE_MIN" MAX="FRE_MAX" AVG="fre_sum/i;
}'
;;
UsedRam)
echo key_word: $key_word
cat $file | grep "Used RAM:" | \
awk '{print $5" "$9}' | \
sed 's/,//g;s/K//g' | awk 'BEGIN{
PSS_MIN=9999999;PSS_MAX=0;pss_sum=0;
KER_MIN=9999999;KER_MAX=0;ker_sum=0;i=0}
{
if(PSS_MIN>$1) PSS_MIN=$1;if(PSS_MAX<$1) PSS_MAX=$1;pss_sum+=$1;
if(KER_MIN>$2) KER_MIN=$2;if(KER_MAX<$2) KER_MAX=$2;ker_sum+=$2;
i++
} END {
print "i="i;
print "used pss:MIN="PSS_MIN" MAX="PSS_MAX" AVG="pss_sum/i;
print "used kernel:MIN="KER_MIN" MAX="KER_MAX" AVG="ker_sum/i;
}'
;;
*)
echo params error!
esac
echo ------------------------
echo
if [ -f .temp_file ];then
rm .temp_file
fi
}
function excel_show()
{
file=$(echo $1 | sed 's/ //g')
key_word=$(echo $2 | sed 's/ //g')
modify_key_word=0
case $key_word in
FreeMem)
echo key_word: $key_word
cat ${file} | grep "Free RAM:" | \
awk '{print $3" "$5" "$9" "$13}' | \
sed 's/,//g;s/K//g' | awk 'BEGIN{
RAM_MIN=9999999;RAM_MAX=0;ram_sum=0;
PSS_MIN=9999999;PSS_MAX=0;pss_sum=0;
KER_MIN=9999999;KER_MAX=0;ker_sum=0;
FRE_MIN=9999999;FRE_MAX=0;fre_sum=0;i=0;
RAM[i]=0;PSS[i]=0;KER[i]=0;FRE[i]=0;}
{
if(RAM_MIN>$1) RAM_MIN=$1;if(RAM_MAX<$1) RAM_MAX=$1;ram_sum+=$1;
if(PSS_MIN>$2) PSS_MIN=$2;if(PSS_MAX<$2) PSS_MAX=$2;pss_sum+=$2;
if(KER_MIN>$3) KER_MIN=$3;if(KER_MAX<$3) KER_MAX=$3;ker_sum+=$3;
if(FRE_MIN>$4) FRE_MIN=$4;if(FRE_MAX<$4) FRE_MAX=$4;fre_sum+=$4;
RAM[i]=$1;PSS[i]=$2;KER[i]=$3;FRE[i]=$4;i++;
} END {
printf "可用内存 "
printf("%.2f %.2f %.2f ",RAM_MIN/1024.0,RAM_MAX/1024.0,ram_sum/i/1024);
for(j=0;j < i;j++) {
printf("%.2f ",RAM[j]/1024.0);
}
printf("\n");
printf "PSS缓存 "
printf("%.2f %.2f %.2f ",PSS_MIN/1024,PSS_MAX/1024,pss_sum/i/1024);
for(j=0;j < i;j++) {
printf("%.2f ",PSS[j]/1024)
}
printf("\n");
printf "kernel缓存 "
printf("%.2f %.2f %.2f ",KER_MIN/1024,KER_MAX/1024,ker_sum/i/1024);
for(j=0;j < i;j++) {
printf("%.2f ",KER[j]/1024)
}
printf("\n");
printf "实际剩余 "
printf("%.2f %.2f %.2f ",FRE_MIN/1024,FRE_MAX/1024,fre_sum/i/1024);
for(j=0;j < i;j++) {
printf("%.2f ",FRE[j]/1024)
}
printf("\n");
}' >> analyze_result.txt
;;
UsedRam)
echo key_word: $key_word
cat $file | grep "Used RAM:" | \
awk '{print $5" "$9}' | \
sed 's/,//g;s/K//g' | awk 'BEGIN{
PSS_MIN=9999999;PSS_MAX=0;pss_sum=0;
KER_MIN=9999999;KER_MAX=0;ker_sum=0;i=0;
PSS[i]=0;KER[i]=0}
{
if(PSS_MIN>$1) PSS_MIN=$1;if(PSS_MAX<$1) PSS_MAX=$1;pss_sum+=$1;
if(KER_MIN>$2) KER_MIN=$2;if(KER_MAX<$2) KER_MAX=$2;ker_sum+=$2;
PSS[i]=$1;KER[i]=$2;i++
} END {
printf "用户空间使用内存 "
printf("%.2f %.2f %.2f ",PSS_MIN/1024,PSS_MAX/1024,pss_sum/i/1024);
for(j=0;j < i;j++) {
printf("%.2f ",PSS[j]/1024)
}
printf("\n");
printf "内核空间使用内存 "
printf("%.2f %.2f %.2f ",KER_MIN/1024,KER_MAX/1024,ker_sum/i/1024);
for(j=0;j < i;j++) {
printf("%.2f ",KER[j]/1024)
}
printf("\n");
}' >> analyze_result.txt
;;
SwapCached)
echo key_word: $key_word
cat $file | grep "SwapCached:" | \
awk 'BEGIN {SWAP_MIN=9999999;SWAP_MAX=0;swap_sum=0;i=0;SWAP[i]=0}
{
if(SWAP_MIN>$2) SWAP_MIN=$2;if(SWAP_MAX<$2) SWAP_MAX=$2;swap_sum+=$2;
SWAP[i]=$2;i++
} END {
printf "SwapCached "
printf("%.2f %.2f %.2f ",SWAP_MIN,SWAP_MAX,swap_sum/i);
for(j=0;j < i;j++) {
printf("%.2f ",SWAP[j])
}
printf("\n");
}' >> analyze_result.txt
;;
Native)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1
cat $file | grep "$key_word" | awk 'NR%2==1{print $0}' > .temp_file
file=.temp_file
echo -n "Native " >> analyze_result.txt
fi
;&
System)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1
echo -n "System " >> analyze_result.txt
fi
;&
iandos)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1;
key_word="${key_word}.registration"
cat $file | grep "$key_word" | awk 'NR%2==1{print $0}' > .temp_file
file=.temp_file
echo -n "iandos " >> analyze_result.txt
fi
echo key_word: $key_word
cat $file | grep "$key_word" | \
awk '{print $1}' | sed 's/,//g;s/K://g' | \
awk 'BEGIN {i=0;sum=0;min=9999999;max=0;array[i]=0}
{sum+=$0;if(min>$0) min=$0;if(max<$0) max=$0;array[i]=$0;i++}
END {
printf("%.2f %.2f %.2f ",min/1024,max/1024,sum/i/1024);
for(j=0;j < i;j++) {
printf("%.2f ",array[j]/1024)
}
printf("\n");
}' >> analyze_result.txt
;;
*)
echo param exist error!
esac
if [ -f .temp_file ];then
rm .temp_file
fi
}
if [ x"$1" = x -o ! -f "$1" ];then
echo error:file is not exist!
exit -1
fi
echo file: $1
echo ------------------------
calc_mem_item $1 FreeMem
calc_mem_item $1 System
calc_mem_item $1 Dalvik
calc_mem_item $1 Dalvik_Other
calc_mem_item $1 zygote
calc_mem_item $1 Native
calc_mem_item $1 Perceptible
calc_mem_item $1 UsedRam
calc_mem_item $1 iandos
echo excel_show -----------
excel_show $1 FreeMem
excel_show $1 Native
excel_show $1 System
excel_show $1 iandos
# excel_show $1 UsedRam
echo
if [ -f ./analyze_result.txt ];then
echo "" >> analyze_result.txt
fi
summary_iandos.sh
应用log分析脚本,该脚本不通用,特定场景通用
function calc_logcat_item()
{
file=$(echo $1 | sed 's/ //g')
key_word=$(echo $2 | sed 's/ //g')
modify_key_word=0
echo key_word: $key_word
case $key_word in
check_face)
key_word="native check new frame succeed"
cat ${file} | grep "$key_word" | \
awk -F: '{print $NF}' | awk '{printf("%.2f ",$0)}' | \
awk 'BEGIN {gmin=10000;gmax=0;g=0;d=0;gsum=0;garray[g]=0;dmin=10000;dmax=0;darray[d]=0;dsum=0}
{
tag=$1>$2;
for(i=1;i<=NF;i++) {
if(i%2==tag) {
if(dmin>$i) dmin=$i;
if(dmax<$i) dmax=$i;
darray[d++]=$i;
dsum+=$i;
} else {
if(gmin>$i) gmin=$i;
if(gmax<$i) gmax=$i;
garray[g++]=$i;
gsum+=$i;
}
}
}
END {
printf("人脸跟随 %.2f %.2f %.2f ",gmin,gmax,gsum/g);
for(j=0;j < g;j++) {
printf("%.2f ",garray[j])
}
printf("\n");
printf("人脸提取 %.2f %.2f %.2f ",dmin,dmax,dsum/d);
for(j=0;j < d;j++) {
printf("%.2f ",darray[j])
}
printf("\n");
}' >> analyze_result.txt
;;
getfeature)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1
key_word="end GetFeature succeed"
echo -n "getfeature " >> analyze_result.txt
fi
;&
compare)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1
key_word="compare face"
echo -n "compare " >> analyze_result.txt
fi
;&
entire_checkout)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1
key_word="end check new frame"
echo -n "entire_checkout " >> analyze_result.txt
fi
;&
entire_recognition)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1
key_word="end compare succeed"
echo -n "entire_recognition " >> analyze_result.txt
fi
;&
entire_all)
if [ $modify_key_word -eq 0 ];then
modify_key_word=1
key_word="end ALL"
echo -n "entire_all " >> analyze_result.txt
fi
cat ${file} | grep "$key_word" | \
awk -F: '{print $NF}' | \
awk 'BEGIN {min=10000;max=0;i=0;sum=0;array[i]=0}
{sum+=$0;if(min>$0) min=$0;if(max<$0) max=$0;array[i]=$0;i++}
END {
printf("%.2f %.2f %.2f ",min,max,sum/i);
for(j=0;j < i;j++) {
printf("%.2f ",array[j])
}
printf("\n");
}' >> analyze_result.txt
;;
*)
echo param exist error!
esac
if [ -f .temp_file ];then
rm .temp_file
fi
}
if [ x"$1" = x -o ! -f "$1" ];then
echo error:file is not exist!
exit -1
fi
echo file: $1
echo ------------------------
calc_logcat_item $1 check_face
calc_logcat_item $1 getfeature
# calc_logcat_item $1 compare
# calc_logcat_item $1 entire_checkout
# calc_logcat_item $1 entire_recognition
# calc_logcat_item $1 entire_all
echo
if [ -f ./analyze_result.txt ];then
echo "" >> analyze_result.txt
fi