Automating the world one-liner at a time…
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 ArchitectVisit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShellVisit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
Thanks for the comment! I've posted this too in my blog:
I agree with you. You didn't say that the QL function isn't the right choose for everything... but is the fastest way to type, of course. I liked it very much too!