记录运行时间
调用方式- call :C_timer
- call :C_timer sum
复制代码 log文件 time.txt- b1.bat 0 11:04:04.59
- b1.bat 1 11:04:42.21 37.62
- b1.bat 2 11:05:10.62 28.41
- b1.bat 3 11:05:25.92 15.30
- b1.bat 81.33
复制代码
- :C_timer [sum]
- if not defined _ti_ set _ti_=-1
- set/a _ti_+=1
- set _tb_=%_te_%
- set _te_=%time%
- if %_ti_% EQU 0 (
- set _tb_=%_te_%
- )
- set/a _tdiff_=(9%_te_:~0,2%-9%_tb_:~0,2%)*360000+(9%_te_:~3,2%-9%_tb_:~3,2%)*6000+(9%_te_:~6,2%%_te_:~9,2%-9%_tb_:~6,2%%_tb_:~9,2%)
- set/a _tdiff_=%_tdiff_:-=8640000-%
- set/a _tdiffSum_+=%_tdiff_%
- if "%_ti_%" == "0" (
- (echo,) >>time.txt
- (echo %~nx0 %_ti_% %_te_%) >>time.txt
- ) else (
- (echo %~nx0 %_ti_% %_te_% %_tdiff_:~0,-2%.%_tdiff_:~-2%) >>time.txt
- )
- if %1.==sum. (
- (echo %~nx0 %_tdiffSum_:~0,-2%.%_tdiffSum_:~-2%) >>time.txt
- )
- goto :eof
复制代码
|