Vinicius Canto posted a comment regarding the performance of the QL function that I posted in my Year of the Pig Revisited – the magic of QL blog post. He found that this function was 16x slower than creating an array using the form: @(“Pig”, “Rat”, “Ox”).
That is good to know and if you have a script which you need to speed up, this is one area you might want to look at. That said, we did little to no work on performance in V1 so it would be a mistake to hardwire your coding practices according to the performance characteristics of this version. We are going to do work on performance for the next release so things that are expensive today, may be cheap tomorrow. We’ve already looked at a few things and are very optimistic about what we’ll be able to achieve. (e.g. Lee Holmes recently did some work to substantially speed up the performance of calling functions.)
As a general rule, you should code to the right abstractions and have faith that we’ll be investing in making the right abstractions be the most performant. Then, if a particular script doesn’t meet your performance requirements, go in and tweak that script. When you do this, you might find that the right solution is not to do things like this but rather to take an loop and re-write it as a C# or VB.Net Cmdlet.
Just to be clear – I’m NOT saying that QL is the “right” way to create an array. Either way is fine. I’m just saying that you should choose the abstraction you want first and accept the perf characteristics unless perf is actually an issue.
Jeffrey Snover [MSFT]
Windows PowerShell/MMC Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx