如何使用Windows批处理文件来衡量控制台应用程序的性能?

前端之家收集整理的这篇文章主要介绍了如何使用Windows批处理文件来衡量控制台应用程序的性能?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何编写简单的批处理文件来衡量基于控制台的应用程序的性能?控制台应用程序接受两个命令行参数.

我想得到:

StartTime = System Dos time
myconsoleapp arg1,arg2
StopTime = System Dos Time
timeDelta = stoptime - starttime

我会将timeDelta写入控制台上的文件显示.

纯批量解决方案可能是.
@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
)
原文链接:https://www.f2er.com/windows/371694.html

猜你在找的Windows相关文章