I recently came over an interesting thread on LinkedIn where they talked about how to count lines in a CSV. A lot of good code examples where posted, where they tried to optimize for speed and memory consumption. I decided to try out some ideas of my own, but as I often do, I got sidetracked into building a function to easily perform measurements of code blocks instead.
“Wait a minute” I hear you say, “there already exist a command for that!”. True, Measure-Command is golden, but what I needed was something that was able to measure memory and cpu as well as time. So I created Measure-ScriptBlock. It uses Measure-Command internally but also measures memory consumption and CPU time while the code is executing. To top it all of, I added the option of specifying how many iterations of the code you want to run, and whether you want the mean value automatically calculated or not.
If you have any comments, or ideas for future improvement, please let me know!