本帖最后由 plp626 于 2011-6-17 21:36 编辑
这个无需给定命令循环次数,由程序指定。- :: cff "命令名"; "命令名"; ...
- :: 举例:
- :: cff "set var=^!random^!"
- :: cff "call set a=1"; "call set/a a=1"; "set/a a=1"
- :: cff "for /f %a in ("abcdef")do set str=%a"
复制代码
- :: cmd 命令执行效率测试,保存为cff.bat于windows目录下,
- :: 命令行调用格式:
- :: cff "命令名"; "命令名"; ...
- :: Version: 1.1; Code by plp; Thanks to: fastslz, batchar
- @ECHO off&setlocal EnableDelayedExpansion&call:getinf
- echo ------------ CMD指令测试 -------------
- :beg
- set/a $lp=random%%5+1&set "cmd=%~1"
- :begin
- Set $time1=%time%
- for /l %%@ in (1 1 %$lp%)do %cmd%
- Set $time2=%time%
- call:etime $time1 $time2 $t12
- if !$t12! leq 20 set/a $lp=$lp*2+5&goto:begin
- set/a $cff=$lp*100/$t12,$r=$lp*100%%$t12*10/$t12
- call:print
- if %2. neq . shift&goto:beg
- goto:eof
-
- :etime <beginTime_VarName> <endTime_VarName> <retVar>
- Set/a "%3=(!%2:~,2!-!%1:~,2!)*360000+(1!%2:~3,2!-1!%1:~3,2!)*6000+1!%2:~-5,2!!%2:~-2!-1!%1:~-5,2!!%1:~-2!,%3+=-8640000*(%3>>31)"&goto:eof
- :getinf 获取版本信息和CPU信息
- ver&wmic cpu get name|find "CPU"
- set NUMBER_OF_PROCESSORS&goto:eof
- :print 格式化输出
- set "prt="!cmd!" "
- set $cf= !$cff!.!$r!&set $cf=!$cf:~-8! Hz
- if !cmd:~37!. neq . (echo "!cmd!" @ !$cf!)else (
- echo !prt:~0,37! @ !$cf!
- )
复制代码
|