如何编写简单的批处理文件来衡量基于控制台的应用程序的性能?控制台应用程序接受两个命令行参数.
我想得到:
StartTime = System Dos time myconsoleapp arg1,arg2 StopTime = System Dos Time timeDelta = stoptime - starttime
纯批量解决方案可能是.
原文链接:https://www.f2er.com/windows/371694.html@echo off set "startTime=%time%" for /L %%n in (1,1,1000) do <nul set /p "=" set "stopTime=%time%" call :timeDiff diff startTime stopTime echo %diff% milli seconds goto :eof :timeDiff setlocal call :timeToMS time1 "%~2" call :timeToMS time2 "%~3" set /a diff=time2-time1 ( ENDLOCAL set "%~1=%diff%" goto :eof ) :timeToMS ::### WARNING,enclose the time in " ",because it can contain comma seperators SETLOCAL EnableDelayedExpansion FOR /F "tokens=1,2,3,4 delims=:,.^ " %%a IN ("!%~2!") DO ( set /a "ms=(((30%%a%%100)*60+7%%b)*60+3%%c-42300)*1000+(1%%d0 %% 1000)" ) ( ENDLOCAL set %~1=%ms% goto :eof )