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_something.ps1 ; $e=Get-Date; ($e - $s).TotalSeconds
But I would like something simpler like
time .\do_something.ps1
Yup.
Note that one minor downside of
Measure-Commandis that you see nostdoutoutput.[Update, thanks to @JasonMArcher] You can fix that by piping the command output to some commandlet that writes to the host, e.g.
Out-Defaultso it becomes:Another way to see the output would be to use the .NET
Stopwatchclass like this: