- :::::::::::::::::::::::::::::::: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
- @echo off
- set /p var=<%0
-
- :: 获得100000次执行 @echo off 任务的耗时,存放在ct1变量内
- set t1=%time%
- for /l %%a in (1 1 100000)do @echo off
- set t2=%time%
- call:etime t1 t2 tc1
- setlocal enabledelayedexpansion
- for /l %%i in (32 1 126) do (
- if defined _"!var:~%%i,1!" (
- set "#!var:~%%i,1!=!var:~%%i,1!"
- set "$#!var:~%%i,1!=%%i"
- ) else set _"!var:~%%i,1!"=!var:~%%i,1!&set "$!var:~%%i,1!=%%i"
- )
-
- :: 获得500次执行“你的代码”任务的耗时,存放在ct2变量内
-
-
-
- set t1=%time%
- for /l %%a in (1 1 500)do (
-
- set str= ^^!"$%%&'()*+,-./09:;<=>?@AZ[^^_`az|}~
-
- set Len=0&set "Slen=!str!"
- for %%i in (4096 2048 1024 512 256 128 64 32 16)do if "!Slen:~%%i!" NEQ "" set/aLen+=%%i&set Slen=!Slen:~%%i!
- set Slen=!Slen!FEDCBA9876543210&set/aLen+=0x!Slen:~16,1!
-
- for /l %%i in (0 1 !Len!) do (
- for /f "delims=" %%j in ("!str:~%%i,1!") do (
- if "%%j" neq "" (
- if "!#%%j!" neq "" (
- if "!#%%j!" lss "%%j" (set Ans=!Ans! !$%%j!) else set Ans=!Ans! !$#%%j!
- ) else if "!$%%j!" neq "" (set Ans=!Ans! !$%%j!)else set Ans=!Ans! 61
- ) else set Ans=!Ans! 33
- )
- )
- echo!Ans!&set Ans=
- )
- set t2=%time%
- call:etime t1 t2 tc2
-
- :: 计算执行一次“你的代码”与执行一次“@echo off”的耗时比
- set/a rate=200*tc2/tc1
- echo 一次任务与一次“@echo off命令”耗时比=%rate%
- pause
-
- :etime <begin> <end> <ret> //求时差
- setlocal enabledelayedexpansion
- Set/a "c=(!%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!,c+=-8640000*(c>>31)"
- endlocal&set %3=%c%&goto:eof
-
- :: 某些标签子过程,(该处可省略)
- :label
- rem ....
复制代码
|