Timing a command's execution in PowerShell

前端 未结 7 841
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 01:13

Is there a simple way to time the execution of a command in PowerShell, like the \'time\' command in Linux?
I came up with this:

$s=Get-Date; .\\do_somet         


        
7条回答
  •  天涯浪人
    2020-11-28 01:49

    You can also get the last command from history and subtract its EndExecutionTime from its StartExecutionTime.

    .\do_something.ps1  
    $command = Get-History -Count 1  
    $command.EndExecutionTime - $command.StartExecutionTime
    

提交回复
热议问题