I must say that I learned a lot about speed, and how coding structure matters when you’re going for the gold, as I was reviewing the entries from the Hadoop PowerShell challenge. The winners are at the end of this post, so zip down there to see if you won!
I’ll use the post to cover some of what we learned from the entries here! Here’s our top three tips for making your PowerShell scripts run just that much faster!
When searching through files, don’t use Get Content
As it turns out Select-String (PowerShell’s text searching cmdlet) is capable of mounting a file in memory, no need to gc it first. It’s also MUCH slimmer in memory, and has speed for days. Look at the performance difference in a common scenario, search 10 directories of files with it, and with Get-Content.
Using Select-String alone is a 31x Speed Increase!
View original post 1,421 more words