目录
1.脚本内容
2.BAT参考文章:
1.BAT命令入门与高级技巧详解(转)
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
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%
goto :eof
::=====================================================
@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 ( pause cls echo Times:%%i/%stressCnt% IntervalTimes:%IntervalTimes% call :Open_Capture_Close set /a remainder=%%i "%%" %IntervalTimes% echo remainder:!remainder! if "!remainder!"=="0" (call :DumpMemory %%i) pause ) 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 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 ::=====================================================2.BAT参考文章: 1.BAT命令入门与高级技巧详解(转)



