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

后端 未结 30 2928
南笙
南笙 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:03

    An alternative to measure-time is simply "Get-Date". You don't have that hassle with forwarding output and so on.

    $start = Get-Date
    [System.Threading.Thread]::Sleep(1500)
    $(Get-Date) - $start
    

    Output:

    Days              : 0
    Hours             : 0
    Minutes           : 0
    Seconds           : 1
    Milliseconds      : 506
    Ticks             : 15060003
    TotalDays         : 1.74305590277778E-05
    TotalHours        : 0.000418333416666667
    TotalMinutes      : 0.025100005
    TotalSeconds      : 1.5060003
    TotalMilliseconds : 1506.0003
    

提交回复
热议问题