Stopwatch vs Measure-Command

Just a quick one – consider using the Stopwatch class instead of Measure-Command in PowerShell. There are a couple of good reasons that you might want to:

First off you get more granular measuring units. While this is not normally an issue for normal performance troubleshooting, there might be very unique circumstances where you need to get sub-millisecond.

In my opinion the main reason to use the stopwatch class is the enhanced control it has. You can stop and restart the stopwatch at any time. You can specifically start the stopwatch, run some commands, stop the stopwatch, run more commands, and then restart it without having to add together 2 or more measure-commands. You also get the ability to zero out the stopwatch anytime you want. You can also have multiple stopwatches running at the same time!