目录
1.脚本内容
@echo off
adb wait-for-device
adb root
adb shell setenforce 0
::====================[Controled by yourself]===================
set fileDir=memoryStress
set fileName=%fileDir%\meminfo_DMA.txt
::总压测次数
set /a stressCnt=1000
::第0次dump memory后每间隔100次dump 一次memory
set /a IntervalTimes=100
::==============================================================
if not exist %fileDir% md %fileDir%
if exist %fileName% del %fileName%
::=====================================================
@setlocal EnableDelayedExpansion
for /l %%i in (0,1,%stressCnt%) do (
cls
echo Times:%%i/%stressCnt% IntervalTimes:%IntervalTimes%
call :Open_Capture_Close & echo Open_Capture_Close Done
set /a remainder=%%i "%%" %IntervalTimes%
if "!remainder!"=="0" (call :DumpMemory %%i & echo DumpMemory Done )
)
endlocal
echo Test Done !!! & pause>nul
exit /b 0
::=====================================================
goto :eof
:Open_Capture_Close
echo FunctionName:%0
adb shell sleep 1
::launch app(apk packageName)
adb shell am start com.xxx.camera
adb shell sleep 3
::snapshot
adb shell input keyevent 27
adb shell sleep 3
::backup
adb shell input keyevent 4
adb shell sleep 3
goto :eof
::=====================================================
goto :eof
:DumpMemory
::ANSI编码的汉字BAT 可正常打印
echo 第%1次Dump: >> %fileName%
::注意%转义,%前加%
adb shell "data '%%Y-%%m-%%d %%H:%%M:%%S.%%N'" >> %fileName%
adb shell dumpsys meminfo camerahalserver >> %fileName%
adb shell cat /proc/dma_heap/all_heaps >> %fileName%
adb shell
goto :eof
::=====================================================