PowerShell is slow

Home  >>  PowerShell  >>  PowerShell is slow

PowerShell is slow

On January 1, 2007, Posted by , In PowerShell,Rant, With Comments Off on PowerShell is slow

I was going to start the new year with a positive note, but then I thought, lets get a PS1 pet hate out of the way first.

PowerShell is slow.

There are many ways to demonstrate this, but for this case I’m going to use a small snippet of code I found to render the mandelbrot set to the console window. It’s not my code and don’t know where it came from, but algorithm is fairly well known.

The code to demonstrate this is in a zip file here.

If you run ./mandel2.ps1 you get this pretty picture.

There is a Windows Scripting Host version. Run this with cscript mandel2.wsf.

There is a JScript.NET version. Compile it with JSC and or run the supplied one with ./mandel2.js.exe.

There is even a javascript-embedded-in-a-HTML-page version, just click on mandel2.html.

Now on my machine (a 2.66ghz quad core MacPro running XP in Parallels Desktop), I get these results:

PowerShell 1510 ms
Windows Scripting Host 90 ms
JScript.NET 160 ms
HTML (IE7) 110 ms
HTML (Firefox 2) 140 ms
HTML (Safari on OSX) 103 ms

OK, so the existing javascript engine in Windows (used by IE and WSF) are pretty good at this. Safari’s is pretty good (using KJS). So why is this brand spanking new language, PowerShell, so very poor?

It’s more than an order of magnitude slower than Microsoft’s previous attempt at a scripting environment!

This tardiness really shows itself in other inappropriate projects I’m working on in PS1. I really hope the PowerShell team at Microsoft address this for version 1.1 – maybe they should go speak to the jscript team.

Comments are closed.