根据同事的一个需求,写了一个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
* 博客园: http://www.cnblogs.com/lihaiyan/
* 邮箱:1063385677@qq.com
* QQ: 1063385677
* Copyright ©2014 Lover雪儿
********************************************
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。