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

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

    Just a little expansion of the answer from Casey.K about using the Measure-Command from PowerShell:

    1. You can invoke PowerShell from the standard command prompt, like this:

      powershell -Command "Measure-Command {echo hi}"
      
    2. This will eat the standard output, but you can prevent that by adding | Out-Default like this from PowerShell:

      Measure-Command {echo hi | Out-Default}
      

      Or from a command prompt:

      powershell -Command "Measure-Command {echo hi | Out-Default}"
      

    Of course, you're free to wrap this in a script file *.ps1 or *.bat.

提交回复
热议问题