fps
参考资料与下载资料
https://testerhome.com/topics/4775
https://github.com/ChromiumWebAPPs/chromium/blob/master/build/Android/pylib/perf/surface_stats_collector.py
参考资料
https://mp.weixin.qq.com/s?__biz=MzA3NTYzODYzMg==&mid=208258190&idx=2&sn=22af4f01a6090599da3dca4c44f0f396&scene=2&from=timeline&isappinstalled=0#rd
https://mp.weixin.qq.com/s?__biz=MzA3NTYzODYzMg==&mid=209682379&idx=1&sn=d43adbdc22235450e9de0ae7fbd46ff0&scene=2&from=timeline&isappinstalled=0#rd
https://blog.csdn.net/itfootball/article/details/43084527
https://github.com/Tencent/GT
重写的获取帧率脚步:
#!/system/bin/sh
show_help() {
echo "
Usage: sh fps.sh [ -t target_FPS ] [ -w monitor_window ] [ -k KPI ] [ -f csv_path ] [ -h ]
Show: FU(s) LU(s) Date FPS Frames jank MFS(ms) OKT SS(%)
FU(s): Uptime of the first frame.
LU(s): Uptime of the last frame.
Date: The date and time of LU.
FPS: Frames Per Second.
Frames: All frames of a loop.
jank: When the frame latency crosses a refresh period, jank is added one.
MFS(ms): Max Frame Spacing.
OKT: Over KPI Times. The KPI is the used time of one frame.
SS(%): Smoothness Score. SS=(FPS/target FPS)*60+(KPI/MFS)*20+(1-OKPIT/Frames)*20
IF FPS > target FPS: FPS/The target FPS=1
IF KPI > MFS: KPI/MFS=1
WN: the window number of same name's window. Eg. surfaceview
POSIX options | GNU long options
-t | --target The target FPS of the choosed window. Default: 60
-w | --window The choosed window. Default: no window.
-k | --KPI The used time of a frame. Default: KPI=1000/The target FPS.
-f | --file The path of the csv file. Default: output result to console.
-h | --help display this help and exit
"
}
file=""
window=""
target=60
KPI=16.66
while :
do
case $1 in
-h | --help)
show_help
exit 0
;;
-t | --target)
shift
target=$1
KPI=$((1000/$1))
shift
;;
-w | --window)
shift
window="$1"
shift
;;
-k | --KPI)
shift
KPI=$1
shift
;;
-f | --file)
shift
file="$1"
shift
;;
--) # End of all options
shift
break
;;
*) # no more options. Stop while loop
break
;;
esac
done
if [ -f /data/local/tmp/busybox ];then
export bb="/data/local/tmp/busybox"
else
echo "No /data/local/tmp/busybox"
exit
fi
if [ -f /data/local/tmp/stop ];then
$bb rm /data/local/tmp/stop
fi
if [ -f /data/local/tmp/FPS.pid ];then
pid=`cat /data/local/tmp/FPS.pid`
if [ -f /proc/$pid/cmdline ];then
if [ `$bb awk 'NR==1{print $1}' /proc/$pid/cmdline`"a" == "sha" ];then
echo "The $pid is sh command."
exit
fi
fi
fi
echo $$ >/data/local/tmp/FPS.pid
if [ $target -le 60 -a $target -gt 0 ];then
###60hz*128~=2.12s
###50hz*128~=2.56s
sleep_t=1600000
else
echo "$target is out of (0-60]"
exit
fi
if [ $target -eq 60 ];then
sleep_t=2000000
elif [ $target -eq 50 ];then
sleep_t=2400000
fi
mac=`cat /sys/class/net/*/address|$bb sed -n '1p'|$bb tr -d ':'`
model=`getprop ro.product.model|$bb sed 's/ /_/g'`
build=`getprop ro.build.fingerprint`
if [ -z $build ];then
build=`getprop ro.build.description`
fi
uptime=`$bb awk -v T="$EPOCHREALTIME" 'NR==3{printf("%.6f",T-$3/1000000000+8*3600)}' /proc/timer_list`
if [ -z "$file" ];then
echo ""
echo `date +%Y/%m/%d" "%H:%M:%S`": $window"
if [ `$bb awk -F. '{print $1}' /proc/uptime` -lt 1000 ];then
echo -e "FU(s) \tLU(s) \tDate \t\t\t\tFPS:$target\t\t\tFrames\tjank\tjank2\tMFS(ms)\tOKT:$KPI\tSS(%)\tWN"
else
echo -e "FU(s) \t\tLU(s) \t\tDate \t\t\t\tFPS:$target\t\t\tFrames\tjank\tjank2\tMFS(ms)\tOKT:$KPI\tSS(%)\tWN"
fi
while true;do
dumpsys surfaceflinger --latency-clear
$bb usleep $sleep_t
dumpsys SurfaceFlinger --latency "$window" |$bb awk -v time=$uptime -v target=$target -v kpi=$KPI '{
if(NR==1){
###the first line
refresh_time=$1/1000000;
if(refresh_time<0)
refresh_time=$1/1000;
vsync_sf=0;
frame_cnt=0;
space_invalide_frame=1
}else{
####three number in a line
if(frame_cnt>0&&$0=="")
frame_invalid=1;
if(NF==3&&$2!=0&&$2!=9223372036854775807){
###in a line have three number and the second number !=0 && !=2^63-1
frame_cycle=($3-$1)/1000000/refresh_time;
if(vsync_sf==0){
###the first frame
####the first frame
vsync_sf=$2;
frame_cnt=1;
jank1=0;
jank2=0;
vsync_overtime=0;
if(frame_cycle<=1)
over_drame=refresh_time;
if(frame_cycle>1){
####frame jake
jank1+=1;
over_drame=int(frame_cycle)*refresh_time;
if(frame_cycle%1>0){
over_drame+=refresh_time;
vsync_overtime +=int(frame_cycle)+1
}else{
vsync_overtime+=int(frame_cycle)
}
};
if(frame_cycle>=2)
jank2+=1;
max_frame_space=refresh_time;
over_kpi=0
}else{
nearby_drame_duration=($2-vsync_sf)/1000000;
if(nearby_drame_duration>500){
####if two frame duration large than 500ms,means user is not operate
frame_invalid=1
}else{
frame_cnt+=1;
if(nearby_drame_duration>=refresh_time){
over_drame+=nearby_drame_duration;
if(nearby_drame_duration>kpi)
over_kpi+=1;
if(nearby_drame_duration>=max_frame_space)
max_frame_space=nearby_drame_duration;
if(frame_cycle>1){
jank1+=1;
if(frame_cycle%1>0){
vsync_overtime +=int(frame_cycle)+1
}else{
vsync_overtime+=int(frame_cycle)
}
}
if(frame_cycle>=2)
jank2+=1;
vsync_sf=$2
}else{
over_drame+=refresh_time;
vsync_sf=sprintf("%.0f",vsync_sf+refresh_time*1000000)
}
}
};
if(frame_cnt==1)
s=sprintf("%.3f",$2/1000000000)
};
if(frame_cnt>0&&frame_invalid==1){
frame_invalid=0;
if(frame_cnt==1)
t=sprintf("%.3f",s+over_drame/1000);
else
t=sprintf("%.3f",vsync_sf/1000000000);
T=strftime("%F %T",time+t)"."sprintf("%.0f",(time+t)%1*1000);
fps=sprintf("%.2f",frame_cnt*1000/over_drame);
max_frame_space=sprintf("%.0f",max_frame_space);
target_fps_rate=fps/target;if(target_fps_rate>1)target_fps_rate=1;
fps2=sprintf("%.2f",frame_cnt*target/(vsync_overtime+frame_cnt));
fps3=sprintf("%.2f",frame_cnt/(vsync_overtime+frame_cnt));
h=kpi/max_frame_space;if(h>1)h=1;
e=sprintf("%.2f",target_fps_rate*60+h*20+(1-over_kpi/frame_cnt)*20);
print s"\t"t"\t"T"\t\t"fps+0"\t"fps2+0"\t"fps3+0"\t"frame_cnt"\t"jank1"\t\t"jank2"\t"max_frame_space"\t"over_kpi"\t"e"\t"space_invalide_frame;
frame_cnt=0;
if($0==""){
vsync_sf=0;
space_invalide_frame+=1
}else{
vsync_sf=$2;
frame_cnt=1;
jank1=0;
jank2=0;
vsync_overtime=0;
if(frame_cycle<=1)
over_drame=refresh_time;
if(frame_cycle>1){
jank1+=1;
over_drame=int(frame_cycle)*refresh_time;
if(frame_cycle%1>0){
over_drame+=refresh_time
vsync_overtime+=int(frame_cycle)+1
}else{
vsync_overtime+=int(frame_cycle)
}
};
if(frame_cycle>2)
jank2+=1;
max_frame_space=refresh_time;
over_kpi=0
}
}###if(frame_cnt>0&&frame_invalid==1)
}###the first line end
}'
if [ -f /data/local/tmp/stop ];then
break
fi
done
else
start_time="`date +%Y/%m/%d" "%H:%M:%S`"
echo "PID:$$\nWindow:$window\nT-FPS:$target\nKPI:$KPI\nStart time:$start_time\nmodel:$model\nmac:$mac\nbuild:$build"
echo "FU(s),LU(s),Date:$window,FPS:$target,Frames,jank,jank2,MFS(ms),OKT:$KPI,SS(%),WN" >$file
while true;do
dumpsys SurfaceFlinger --latency-clear
if [ -f /data/local/tmp/stop ];then
echo "Stop Time:`date +%Y/%m/%d" "%H:%M:%S`"
break
fi
$bb usleep $sleep_t
dumpsys SurfaceFlinger --latency "$window"|$bb awk -v time=$uptime -v target=$target -v kpi=$KPI '{
if(NR==1){
refresh_time=$1/1000000;
if(refresh_time<0)
refresh_time=$1/1000;
vsync_sf=0;
frame_cnt=0;
space_invalide_frame=1
}else{
if(frame_cnt>0&&$0=="")
frame_invalid=1;
if(NF==3&&$2!=0&&$2!=9223372036854775807){
frame_cycle=($3-$1)/1000000/refresh_time;
if(vsync_sf==0){
vsync_sf=$2;
frame_cnt=1;
jank1=0;
jank2=0;
if(frame_cycle<=1)
over_drame=refresh_time;
if(frame_cycle>1){
jank1+=1;
over_drame=int(frame_cycle)*refresh_time;
if(frame_cycle%1>0)
over_drame+=refresh_time};
if(frame_cycle>2)
jank2+=1;
max_frame_space=refresh_time;
over_kpi=0
}else{
nearby_drame_duration=($2-vsync_sf)/1000000;
if(nearby_drame_duration>500){
frame_invalid=1
}else{
frame_cnt+=1;
if(nearby_drame_duration>=refresh_time){
over_drame+=nearby_drame_duration;
if(nearby_drame_duration>kpi)
over_kpi+=1;
if(nearby_drame_duration>=max_frame_space)
max_frame_space=nearby_drame_duration;
if(frame_cycle>1)
jank1+=1;
if(frame_cycle>2)
jank2+=1;
vsync_sf=$2
}else{
over_drame+=refresh_time;
vsync_sf=sprintf("%.0f",vsync_sf+refresh_time*1000000)
}
}
};
if(frame_cnt==1)
s=sprintf("%.3f",$2/1000000000)
};
if(frame_cnt>0&&frame_invalid==1){
frame_invalid=0;
if(frame_cnt==1)
t=sprintf("%.3f",s+over_drame/1000);
else
t=sprintf("%.3f",vsync_sf/1000000000);
T=strftime("%F %T",time+t)"."sprintf("%.0f",(time+t)%1*1000);
fps=sprintf("%.2f",frame_cnt*1000/over_drame);
max_frame_space=sprintf("%.0f",max_frame_space);
target_fps_rate=fps/target;
if(target_fps_rate>1)
target_fps_rate=1;
h=kpi/max_frame_space;
if(h>1)
h=1;
e=sprintf("%.2f",target_fps_rate*60+h*20+(1-over_kpi/frame_cnt)*20);
print s","t","T","fps+0","vsync_sf","jank1","jank2","max_frame_space","over_kpi","e","space_invalide_frame;vsync_sf=0;
if($0==""){
vsync_sf=0;space_invalide_frame+=1
}else{
vsync_sf=$2;
frame_cnt=1;
jank1=0;
jank2=0;
if(frame_cycle<=1)
over_drame=refresh_time;
if(frame_cycle>1){
jank1+=1;
over_drame=int(frame_cycle)*refresh_time;
if(frame_cycle%1>0)
over_drame+=refresh_time};
if(frame_cycle>2)
jank2+=1;
max_frame_space=refresh_time;
over_kpi=0
}
}
}
}' >>$file
done
fi
文章最后发布于: 2019-01-23 17:47:22
相关阅读
第一章 MySQL架构与历史1.1 MySQL逻辑架构1.2 开发控制1.3 事务1.4 多版本并发控制1.5 MySQL的存储引擎1.6 MySQL时间线(Timeline)1
A5创业网(公众号:iadmin5)8月24日消息,昨日华为正式发布AI处理器Ascend 910(昇腾910),同时推出全场景AI计算框架MindSpore。据悉,昇腾91
文章目录简介安装安装PMMServerPMM client 安装使用pmm-adminOPTIONSpmm-admin add查看各种信息是否能够连接pmm服务器获取PMM客
如今许多家庭对生活品质的要求都很高,在家居清洁产品的选择上,他们往往会选择功能多样的无线吸尘器,给生活带来更多方便。市场上这么
GTX 1650显卡玩游戏怎么样 GTX 1650显卡游戏性能测试
显卡性能测试与分析:GPU理论性能测试,是用AIDA64的内置工具进行的。3D基准测试,主要是跑一些基准测试软件。3D游戏测试,表格中将DX9~D