回复 1# zhitingye
给你一段代码,可自行测试rd指令的耗时:- @echo off
- :: 耗时测试
- :: 记录开始时间
- set "begin_time=%time%"
-
- ::下面放你想要计算时耗的代码
- ...
- ...
- ...
-
- :: 记录结束时间
- set "end_time=%time%"
-
- :: 计算耗时
- set "begin_time=%begin_time: =0%"
- set "end_time=%end_time: =0%"
- call :time_consuming %begin_time% %end_time% c_time ms_time
-
- echo;耗时:%c_time% ( %ms_time% 毫秒 )
- pause
- exit/b
-
- :time_consuming <beginTimeVar> <endTimeVar> [retTimeVar] [ret_ms_Var]
- setlocal
- set bt=%~1
- set et=%~2
- set/a"ct=(1%et:~,2%-1%bt:~,2%)*360000+(1%et:~3,2%-1%bt:~3,2%)*6000+1%et:~-5,2%%et:~-2%-1%bt:~-5,2%%bt:~-2%","ct+=-8640000*(ct>>31)","hh=ct/360000","mm=(ct/6000)%%60","ss=(ct/100)%%60","ms=ct%%100"
- set "hh_=0%hh%"
- set "mm_=0%mm%"
- set "ss_=0%ss%"
- set "ms_=0%ms%"
- set "consuming=%hh_:~-2%:%mm_:~-2%:%ss_:~-2%.%ms_:~-2%"
- endlocal&set %3=%consuming%&set %4=%ct%&goto:eof
复制代码
|