update
Signed-off-by: Wenchao Hao <haowenchao22@gmail.com>
This commit is contained in:
parent
7eee0d5f02
commit
baa57ff56b
2
applist
2
applist
|
|
@ -5,7 +5,7 @@ com.taobao.taobao
|
|||
com.xunmeng.pinduoduo
|
||||
com.ss.android.article.news
|
||||
com.sina.weibo
|
||||
com.android.incallui
|
||||
com.android.contacts
|
||||
com.tencent.mobileqq
|
||||
com.tencent.qqlive
|
||||
com.smile.gifmaker
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
app=$1
|
||||
round=$2
|
||||
dir=$3
|
||||
|
||||
prev_alloc=$(adb shell cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/anon_fault_alloc)
|
||||
prev_alloc_fallback=$(adb shell cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/anon_fault_fallback)
|
||||
|
||||
adb shell "simpleperf stat -e dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses,page-faults,raw-stall-backend-mem --app $app --duration 3 -o /data/local/tmp/simpleperf-"$app"-"$round".txt" &
|
||||
|
||||
echo "即将抓$app的perfetto, 请1秒后启动应用"
|
||||
echo "即将抓的perfetto, 请1秒后启动应用 $app"
|
||||
|
||||
adb shell perfetto -c - --txt -o /data/misc/perfetto-traces/trace-"$app"-"$round".ptrace \
|
||||
<<EOF
|
||||
|
|
@ -110,7 +111,7 @@ EOF
|
|||
alloc=$(adb shell cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/anon_fault_alloc)
|
||||
alloc_fallback=$(adb shell cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/anon_fault_fallback)
|
||||
|
||||
adb shell "dumpsys meminfo --package $app" > out/meminfo-"$app"-"$round".txt
|
||||
adb shell "dumpsys meminfo --package $app" > $dir/meminfo-"$app"-"$round".txt
|
||||
|
||||
# 计算大页分配成功率
|
||||
inc_alloc=$((alloc-prev_alloc))
|
||||
|
|
@ -122,10 +123,10 @@ else
|
|||
inc_ratio=1
|
||||
fi
|
||||
|
||||
echo -e "$inc_ratio\t$inc_total" > out/ratio-"$app"-"$round".txt
|
||||
echo -e "$inc_ratio\t$inc_total" > $dir/ratio-"$app"-"$round".txt
|
||||
|
||||
adb pull /data/misc/perfetto-traces/trace-"$app"-"$round".ptrace out/
|
||||
adb pull /data/local/tmp/simpleperf-"$app"-"$round".txt out/
|
||||
adb pull /data/misc/perfetto-traces/trace-"$app"-"$round".ptrace $dir/
|
||||
adb pull /data/local/tmp/simpleperf-"$app"-"$round".txt $dir/
|
||||
|
||||
adb shell "rm /data/misc/perfetto-traces/trace-"$app"-"$round".ptrace"
|
||||
adb shell "rm /data/local/tmp/simpleperf-"$app"-"$round".txt"
|
||||
|
|
|
|||
62
run.sh
62
run.sh
|
|
@ -1,15 +1,38 @@
|
|||
#output: round app start_time start_type rss pss ratio pagefault itlbmiss dtlbmiss cpustalled
|
||||
#$dirput: round app start_time start_type rss pss ratio pagefault itlbmiss dtlbmiss cpustalled
|
||||
|
||||
echo "round app start_time start_type rss pss ratio pagefault itlbmiss dtlbmiss cpustalled" > result
|
||||
dir=$(/usr/bin/date +%Y-%m-%d-%H-%M-%S)
|
||||
mkdir $dir
|
||||
echo "round app start_type start_time inc_ratio inc_total rss pss pagefaults itlbmiss dtlbmiss cpustall" > $dir/result
|
||||
|
||||
for round in $(seq 1 2); do
|
||||
for app in `cat applist`; do
|
||||
echo "开始抓应用 $app"
|
||||
./cold_start_app.sh $app $round
|
||||
echo "开始测试应用 $app"
|
||||
read -p "输入q退出, 输入其他任意内容继续" cmd
|
||||
|
||||
if [ "$cmd" == "q" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# 抓内存相关信息
|
||||
adb shell free -h > $dir/before_free-$app-$round
|
||||
adb shell cat /proc/meminfo > $dir/before_meminfo-$app-$round
|
||||
adb shell cat /proc/zoneinfo > $dir/before_zoneinfo-$app-$round
|
||||
adb shell cat /proc/buddyinfo > $dir/before_buddyinfo-$app-$round
|
||||
adb shell cat /proc/pagetypeinfo > $dir/before_pagetypeinfo-$app-$round
|
||||
adb shell cat /proc/vmstat > $dir/before_vmstat-$app-$round
|
||||
|
||||
./cold_start_app.sh $app $round $dir
|
||||
adb shell input keyevent 3
|
||||
|
||||
adb shell free -h > $dir/after_free-$app-$round
|
||||
adb shell cat /proc/meminfo > $dir/after_meminfo-$app-$round
|
||||
adb shell cat /proc/zoneinfo > $dir/after_zoneinfo-$app-$round
|
||||
adb shell cat /proc/buddyinfo > $dir/after_buddyinfo-$app-$round
|
||||
adb shell cat /proc/pagetypeinfo > $dir/after_pagetypeinfo-$app-$round
|
||||
adb shell cat /proc/vmstat > $dir/after_vmstat-$app-$round
|
||||
|
||||
# 计算启动耗时
|
||||
python3 handle_perfetto.py out/trace-"$app"-"$round".ptrace mm > tmp.txt
|
||||
python3 handle_perfetto.py $dir/trace-"$app"-"$round".ptrace mm > tmp.txt
|
||||
|
||||
if [ $(cat tmp.txt | wc -l) -ne 1 ]; then
|
||||
start_time=0
|
||||
|
|
@ -20,36 +43,27 @@ for round in $(seq 1 2); do
|
|||
fi
|
||||
|
||||
# 计算PSS RSS
|
||||
if [ $(cat out/meminfo-"$app"-"$round".txt | grep "MEMINFO in pid" -c) -ne 1 ]; then
|
||||
cat out/meminfo-"$app"-"$round".txt | grep "TOTAL PSS" | tail -n 1 > tmp.txt
|
||||
if [ $(cat $dir/meminfo-"$app"-"$round".txt | grep "MEMINFO in pid" -c) -ne 1 ]; then
|
||||
cat $dir/meminfo-"$app"-"$round".txt | grep "TOTAL PSS" | tail -n 1 > tmp.txt
|
||||
pss=$(cat tmp.txt | awk '{print $3}')
|
||||
rss=$(cat tmp.txt | awk '{print $6}')
|
||||
else
|
||||
cat out/meminfo-"$app"-"$round".txt | grep "TOTAL PSS" > tmp.txt
|
||||
cat $dir/meminfo-"$app"-"$round".txt | grep "TOTAL PSS" > tmp.txt
|
||||
pss=$(cat tmp.txt | awk '{print $3}')
|
||||
rss=$(cat tmp.txt | awk '{print $6}')
|
||||
fi
|
||||
|
||||
pagefaults=$(cat out/simpleperf-"$app"-"$round".txt | grep 'page-faults' | awk '{print $4}')
|
||||
itlbmiss=$(cat out/simpleperf-"$app"-"$round".txt | grep 'iTLB-load-misses' | awk '{print $4}')
|
||||
dtlbmiss=$(cat out/simpleperf-"$app"-"$round".txt | grep 'dTLB-load-misses' | awk '{print $4}')
|
||||
cpustall=$(cat out/simpleperf-"$app"-"$round".txt | grep 'raw-stall-backend-mem' | awk '{print $4}')
|
||||
pagefaults=$(cat $dir/simpleperf-"$app"-"$round".txt | grep 'page-faults' | awk '{print $4}')
|
||||
itlbmiss=$(cat $dir/simpleperf-"$app"-"$round".txt | grep 'iTLB-load-misses' | awk '{print $4}')
|
||||
dtlbmiss=$(cat $dir/simpleperf-"$app"-"$round".txt | grep 'dTLB-load-misses' | awk '{print $4}')
|
||||
cpustall=$(cat $dir/simpleperf-"$app"-"$round".txt | grep 'raw-stall-backend-mem' | awk '{print $4}')
|
||||
|
||||
# 计算大页相关
|
||||
inc_ratio=$(cat out/ratio-"$app"-"$round".txt | awk '{print $1}')
|
||||
inc_total=$(cat out/ratio-"$app"-"$round".txt | awk '{print $2}')
|
||||
inc_ratio=$(cat $dir/ratio-"$app"-"$round".txt | awk '{print $1}')
|
||||
inc_total=$(cat $dir/ratio-"$app"-"$round".txt | awk '{print $2}')
|
||||
|
||||
echo $round $app $start_time $start_type $inc_ratio $inc_total $rss $pss $pagefaults $itlbmiss $dtlbmiss $cpustall >> result
|
||||
echo $round $app $start_type $start_time $inc_ratio $inc_total $rss $pss $pagefaults $itlbmiss $dtlbmiss $cpustall >> $dir/result
|
||||
|
||||
rm tmp.txt
|
||||
|
||||
echo next
|
||||
read -p "输入命令 " cmd
|
||||
|
||||
if [ "$cmd" == "c" ]; then
|
||||
continue
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
|
|
|||
Loading…
Reference in New Issue