Lover雪儿
想念时,就看看天空,无论距离有多远,我们总在同一片天空下!

根据同事的一个需求,写了一个bat脚本,内容如下:

@ECHO OFF
color 2f
ECHO ※※※※※※※※※※※※※※※※※※※※
ECHO ※ made by lihaiyan@wind-mobi.com ※
ECHO ※ date: 2015/10/29                        ※
ECHO ※※※※※※※※※※※※※※※※※※※※

set Filename=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%-%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%

echo %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
set file_path=d:\save-%Filename%.txt
echo file saved in %file_path%
:a
set /p cpu_number=请输入CPU核心数:
set /p loop=无限循环测试请输入1,有限次数测试请输入0:

if %loop% == 1 (
echo >%file_path%
echo CPU核心数:%cpu_number% >> %file_path%
echo 无限次循环测试 >> %file_path%
set times_temp2=1
:d
echo ------------第%times_temp2%次测试-----------------
echo ------------第%times_temp2%次测试----------------- >> %file_path%
echo date: %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% >> %file_path%
adb shell i=0;while [ i -lt %cpu_number% ];do cat /sys/bus/cpu/devices/cpu$i/online;cat /sys/bus/cpu/devices/cpu$i/cpufreq/cpuinfo_cur_freq;let i+=1;done >> %file_path%
set /a times_temp2+=1
goto d

)

set /p times=请输入测试次数:
set times_temp=1

if not defined cpu_number (
echo CPU核心数不能为空!
GOTO a
)
if not defined times (
echo 测试次数不能为空!
GOTO a
)
if %cpu_number% == 0 (
echo CPU核心数不能为零!
GOTO a
)
if %cpu_number% LSS %times_temp% (
echo 测试次数不能小于1!
GOTO a
)

echo >%file_path%
echo CPU核心数:%cpu_number% >> %file_path%
echo 测试次数:%times% >> %file_path%
echo >> %file_path%
:b
echo ------------第%times_temp%次测试-----------------
echo ------------第%times_temp%次测试----------------- >> %file_path%
echo date: %DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2% >> %file_path%
adb shell i=0;while [ i -lt %cpu_number% ];do cat /sys/bus/cpu/devices/cpu$i/online;cat /sys/bus/cpu/devices/cpu$i/cpufreq/cpuinfo_cur_freq;i=$(($i+1));done >> %file_path%
set /a times_temp+=1

if %times_temp% LEQ %times% (
GOTO b
) else (
echo 保存成功,路径为%file_path%
)

:c
pause

posted on 2015-10-30 09:45  Lover雪儿  阅读(3819)  评论(0编辑  收藏  举报