Measuring How Long Commands Take in Windows

I was considering installing the timeit.exe command on my new laptop, but read that it may not work on the latest versions of Windows.  So, I found an article on StackOverflow that recommended using the Measure-Command command in PowerShell.  You use it as follows, where Get-ChildItem is just listing the current directory as an example command to time:

If you just want to see one of these results, you can specify the field, such as milliseconds, as follows:

Note that Measure-Command does not show you the output of the command that you have executed for PowerShell commands, just the time it took to execute the command.  If you want to see the command’s output, pipe it to Out-Default, as follows:

If you want to use it to execute cmd.exe commands vs. PowerShell commands, prefix the command with “cmd /c” as follows:

Thanks to Casey K and TechGibbon for the useful information.