How do I measure execution time of a command on the Windows command line?

后端 未结 30 3532
南笙
南笙 2020-11-22 09:44

Is there a built-in way to measure execution time of a command on the Windows command line?

30条回答
  •  面向向阳花
    2020-11-22 10:12

    Using a sub to return time in hundredths of second

    ::tiemeit.cmd
    @echo off
    Setlocal EnableDelayedExpansion
    
    call :clock 
    
    ::call your_command  or more > null to pipe this batch after your_command
    
    call :clock
    
    echo %timed%
    pause
    goto:eof
    
    :clock
    if not defined timed set timed=0
    for /F "tokens=1-4 delims=:.," %%a in ("%time%") do ( 
    set /A timed = "(((1%%a - 100) * 60 + (1%%b - 100)) * 60 + (1%%c - 100))  * 100 + (1%%d - 100)- %timed%"
    )
    goto:eof
    

提交回复
热议问题