Register : : Login
menuleft menuright
submenu
 
Jun 11

Written by: Karl Prosser (MVP)
6/11/2008 9:23 PM  RssIcon

I've spend a lot of time in the past looking at the performance of PowerShell but have never gotten around to blogging about it. However it has become quite a hot button among MVPs and others in recent days and we've been busy testing and comparing the speeds different techniques in PowerShell in both V1 and V2.

In V1 there seems to be extreme slowdowns when invoking cmdlet, functions, any type of scriptblock and when using the pipeline. If you write a one liner that is easy to read, very elegant, but uses a lot of "powershelly" techniques its performance is often terrible, compared to it you write it out as a longer script using more traditional imperative style with "C"ish loops as the like. This brings up the whole concept of what is cheaper and more valuable - CPU cycles that keep getting cheaper, or human time in writing and maintaining code - dynamic languages and especially shells will definitely answer that programmer productivity is more valuable, and thus performance can come second.(read about it in the context of python here.) However 59 millisecond average to call an empty powershell function on a dual core machine is pushing this truth to an absurdity. PowerShell should as a language should NOT be slower than BASIC on my Commodore-64 - an 1MHZ 8 bit machine.

Here is some background of where we are coming from. Brandon Shell Started it all here. And after we spend hours running tests and bantering about the subject on the #powershell IRC room on freenode, Mow covered some cool stuff here.

Basically the results of my tests showed that new-object is very slow in V1, but calling any CMDLET, even a simple C# cmdlet with one line of code is extremely slow, and about 30 to 50 times slower than calling that SAME  line of code from powershell as a static method on a C# assembly. Additionally if you take that 50 times faster static method call, and wrap in it a simple powershell function, you loose all your spend gains and its even slower than calling the new-object CmdLet.

The great thing from Mows tests is that in V2 it seems that on the language side of things, scriptblocks,functions and the pipelines have spend up drastically (in the magnitude of about 2000% to 3000%. And cmdlet invocation has spend up also, but is about 6 times slower than just calling C# static methods. GO V2 GO V2 , but is it enough?

Given that V1 is going to be important for a long time, I think that powershell scripters need to still try to script in a "PowerShelly" way, but when they determine that something really has to be performant , they need to know what workarounds they can do in PowerShell to speed things up, understanding where the bottlenecks in PowerShell are.

But this post isn't about those performance solutions - I'm sure that we will cover a lot of them over the coming of the months. I want to RANT.

One of the reasons I think PowerShell has so many language quirks (and thus related gotchas when learning to do advanced stuff and solving bugs) is because it is Defined by Implementation instead of being Defined by Specification. To be honest, PowerShell is more of a platform , than a language or even a shell, and as it brings some new ideas and melds existing ideas in totally new ways, almost experimental ways, I don't think it could have been defined any other way. However its quirks and yes also its performance is a result of that. I believe it needs to be reviewed by traditional language designers and not be excused "because its a shell language". I believe that the importance of PowerShell is growing phenomenally and being part of Microsoft's common engineering requirement I strongly believe such close working with the CLR team should be done, and even if PowerShell is defined by Implementation and will likely be in version 2 also - SPEND THE TIME TO AT LEAST DEFINE THE SPECIFICATION, DOCUMENT THE INTENDED (and thus real) BEHAVIOUR, RELEASE A FULL GRAMMAR, RELEASE OFFICIAL XSD SCHEMAS of the XML ELEMENTS, and if specification is what defines it, and that specification is best represented in the automated unit tests - maybe , just maybe even release such tests  , as per other dynamic languages. I think some of this stuff should at least be done BEFORE V2 is released. I mean getting a V2 and not even having a V1 grammar. </end of rant>

Disclaimer:

Despite the above concerns, I love PowerShell, and the general performance doesn't bother me. Being able to code at the speed of thought, and do things with far less code than C#, and do things interactively and dynamically totally win out. PowerShell does introduce many new tangents on concepts and mash together some amazing things, its amazing they got it as right as they did the first time. I know if I had implemented such a platform/language it would be less consistent and probably slower than a ZX81. PowerShell V2, even though only in CTP2 already shows great performance enhancements.

If that disclaimer gave you the warm fuzzies, don't get too comfortable, i have another pet peeve to blog about, and that is the fallacy called "Restricted Runspaces" and how the lack of being able to truly sandbox PowerShell has me running in the direction of IronRuby - But that's for another day.

-Karl / Shell Tools

 

Tags:
Categories:

8 comment(s) so far...


Gravatar

Re: Getting serious about performance in PowerShell.

Moreover, Liu Sword door who do one thing at home, that is, think of ways to kill mbt sabili! mbt sabili not a secret show in the day MBT Tenga Boots, was also the day of the show we all know that women hate, and get rid of the existence of such a trivial nature of willow house is no risk. Therefore, the Liu Yuan Liu sent home to show to hook up within days of his disciples were an attempt to start from the inside, I did not expect seeing done, Liu Yuan actually disappeared.

By yinhu on   3/16/2011 11:31 PM
Gravatar

Re: Getting serious about performance in PowerShell.

If you buy Mbt shoes you will like cheap mbt shoesMen MBT Sandals

By yinhu on   3/25/2011 11:44 PM
Gravatar

Re: Getting serious about performance in PowerShell.

Moncler Doudoune est d'abord connue à travers le monde pour son accueil chaleureux et relativement léger conceptions jackets.The piquée à la mode, des couleurs vibrantes, des coutures excellentes et un excellent service client ont fait Moncler Veste une marque bien connue des vestes partout dans le monde. Doudoune Moncler Femme sont à la mode, bien coupé, confortable, léger et de sortie extrêmement warm.Doudoune Moncler avec style long et court style non seulement avoir le meilleur matériel, mais aussi avoir la conception à la mode et élégant.

By doudounemoncler on   10/5/2011 10:39 PM
Gravatar

Re: Getting serious about performance in PowerShell.

Moncler Doudoune est une marque très célèbre de vestes partout dans le monde et doudoune Moncler ont bénéficié d'une popularité de plus en plus élevé chez les clients dans le monde entier. Veste Moncler a produit vestes différentes pour différentes personnes, comme les femmes et les hommes Moncler Mocler. En tant que professionnel de vestes souple, Moncler Pas Cher a con?u et produit la série de vestes styles différents, qui a ses propres clients réguliers partout dans le monde. Doudoune Moncler Homme peut donner aux gens la meilleure protection dans les froides journées d'hiver, car ils ont des fonctions de imperméables, la durabilité et la respirabilité.

By doudounemoncler on   10/5/2011 10:40 PM
Gravatar

Re: Getting serious about performance in PowerShell.

Piumini Moncler è prima conosciuta nel mondo per la sua calda accoglienza e design jackets.The relativamente leggeri cuciti alla moda, colori vivaci, cuciture eccellente e un servizio eccellente hanno Moncler Outlet uno giacche marchio noto in tutto il mondo. Moncler sono di moda, ben tagliato, confortevole, luminosa ed estremamente warm.Doudoune stile Moncler 2011 lungo e corto stile non solo le migliori attrezzature, ma hanno anche il design alla moda ed elegante.Un Piumini Moncler 2011 reale sarebbe mai fuori moda, e non solo per una stagione!/Moncler 2012

By doudounemoncler on   10/5/2011 10:40 PM
Gravatar

Re: Getting serious about performance in PowerShell.

You just came Chanel Replicas across this really cool bumper sticker printing website that offers colorful, custom stickers at great prices. Unfortunately, Chanel Handbags you're just not sure that you want to put Chanel Bags a sticker of any kind on your Prada Handbags car. What reason would you have to do UGG so?

Trust us;Discount UGGs there are plenty of reasons to Prada Replicas smack one of these great stickers on your ride. The Prada Bags first of which is for a cause. UGGs Is there something that you feel particularly strong about? Are you completely against illegal Gucci Replicas immigration? Do you support organ and tissue donation? Are you a gun control advocate? Are you all about owning a firearm? Gucci Handbags These days there are plenty of things to be passionate UGG Boots on Sale about, from wars in foreign countries, to animal adoption. Gucci Bags People from your hometown to places on the opposite side of the country are promoting their causes with bumper sticker printing.UGG Boots

You don't want to let everyone know Louis Vuitton Replicas how you feel about the death penalty. That's okay! People are putting bumper stickers on their Christian Louboutin Shoes on Sale cars for other reasons too. Discount UGG Boots How about advertising? Do you own a business? Louis Vuitton Handbags Do you have a friend who owns a business? What about UGG Boots Outlet your parents? Individuals who own businesses are beginning to realize that it doesn't really make sense to pay for elaborate Louis Vuitton Bags and expensive advertising when you could just advertise on your own vehicle for essentially free. Bumper sticker advertising is not Discount UGG Boots only inexpensive, it's portable. If you're promoting your business from the back window of your car, then people from your house, to the mall, to the Coach Bags Outlet beach where you're planning to go this weekend will see your advertisement.UGG Boots on Sale Talk about Christian Louboutin Outlet reaching a mass market!

What about politics? Are you a Democrat who is against the new Republican congress and you're already dreaming Coach Handbags about campaigning for the future? Come up with a slogan and make it happen! Or, you can Cheap UGG Boots just promote the candidate with whom you most relate. If you're passionate about politics and you want to help your favorite candidate get the word out, a Coach Bags bumper sticker is definitely the way to go. Political stickers are almost as The North Face Outlet prevalent on the roadway as....cars! Christian Louboutin Shoes

Another type of sticker that's seen on Coach Outlet Online the roadways quite frequently is the sports team sticker. Show off your UGG Boots Volunteer Pride or your love for the Baltimore Orioles with a big, orange "T" or an "O" Discount Christian Louboutin Shoes that takes up half of the back window on your SUV. There are sports team stickers available everywhere online. If Cheap Christian Louboutin Shoes you aren't seeing one you love, a custom bumper sticker printing company can certainly produce one for you and it'll Coach Outlet be a bumper sticker you're proud to have on your car. The North Face Jackets

People also put stickers on North Face Jackets their cars for religious and spiritual reasons. From the Jesus fish, to the cross, people Coach Handbags Outlet are praising the Lord in the pew and on their bumper!

On a more somber note, people also use Coach Handbags bumper stickers to remember relatives and friends who have passed away.

If you're UGGs interested in ordering your Coach Bags Outlet own custom bumper sticker, you're making a great decision! Have a seat in front of your computer and visit a bumper sticker printing company's website. You can customize your own sticker Coach Bags or choose one from the thousands they have to offer. Don't just stop at one though! You can order stickers in bulk, which is especially handy if you're using your bumper stickers to promote your small business. Your Coach Outlet sticker order should ship The North Face Jacket within a couple of days and you'll be well on your way to showing off your cause, political affiliation, or favorite sports team! North Face Jacket

By swei on   10/13/2011 10:35 PM
Gravatar

louis vuttion

This louis vuttion businesses are intending to save cash. It is louis vuitton replicas nobody can merchants like Bloomingdale’ delaware in order to really Sak undergo lessen revenues to read. Including the many cut. Buy too costly Hermes? Most effective The most affordable Handbag no way products Many years currently taking. I’ ngcheap louis vuitton bags to comprehended have louis vuitton gm neverfull idea of serving thousands of dollars. I just read dedicated to Hermes totes and never Hermes. Allowed obtained not possible loaded period of time afford the one thing, nevertheless will involve media fabric Hermes Birkin tote regarding $ 8-10, 000, is as compelling. I never thought louis vuitton fake
never be a customer such as LV Galliera replica Handbags aftermarket clutches, feature infringement, nevertheless I.loui vuitton should usually your own well known purses will looming great shopping. This is always fashion manner inside.louis vuitton knockoffs distant type Hermes tote that is becoming more popular, is support of your cup of tea such as system. This is always beautiful, soft reasonably media developer Hermes replica louis vuitton replica. Females look at by which the perception of Artist performers together louis vuitton replica handbags producers actors. Hermes Designer purse to look atcheap louis vuitton replicas popular regularly, as well as have the style the fashions are personality. Happening such as Jessica otherwise you Jennifer worn now around the per day those knee will probably louis vuitton replica .
Alma remember driven luggage, to do least complicated aspect of a purse and this man project in different niche, so it’ delaware without obvious duplicate Hermes tote. Are not often known by faux known as replica handbag. Liked these individuals Hermes backpacks are being a result wise that you industry lv as a result of make a commitment and get, you usually lime.cheap louis vuitton handbagsdriven Hermes? totes choose in a variety of different types as good as thecheap louis vuitton i465 black, hobo, tote, receive, messenger as well as carry. You can even examine together with a observe for yourself its excellent electronic could possibly get for thereplica louis vuitton luggage !


By zhyxw on   10/17/2011 12:34 AM
Gravatar

Re: Getting serious about performance in PowerShell.

Anyone blogging regularly Discount Vibram FiveFingers would love to increase their blog traffic. Targeted web Vibram Five Fingers on Sale traffic is what every webmaster craves. Cheap Christian Louboutin Shoes The process of getting your site or blog noticed by Vibram FiveFingers on Sale the search engines is often referred to as UGG SEO which stands for search engine Discount Vibram Five Fingers optimization.

When it comes to SEO there are 100's Vibram Five Fingers Outlet of methods, with in those 100's of methods Discount Christian Louboutin Shoes there are probably 1000's of strategies. The most popular method of SEO would have to be Vibram FiveFingers Link Building. Building quality Christian Louboutin Shoes on Sale one way links back to your site or blog Vibram FiveFingers Outlet can be very effective in getting UGGs the search engines attention, when done Vibram Five Fingers correctly.

I know, not Christian Louboutin Shoes everyone that's Blogging or doing any writing online Cheap UGG Boots for that matter, is doing it for a business purpose, I also know, it's a great hobby. A lot of people write Blue UGG Boots cause they feel they have a knack for it, but unfortunately no one can Christian Louboutin Outlet ever see it because it hasn't been Blue UGG Search Engine Optimized or to be a little more specific, Blue UGGs you need Backlinks. Yes, Backlinks is only part of the equation, but in my honest Red UGG opinion a solid Link Building Strategy can UGG Boots on Sale really get the search engines attention. Red UGG Boots

Think about this, you wouldn't be spending Red UGGs your valuable time working out or exercising if you knew you'd never UGG Gloves get results, so why are you Blogging/Writing, if only a handful of Discount UGGs people ever see it, you might as well just think it for that matter.

You need to get traffic to UGG Boots on Sale your Blogs and Articles if you'd like a chance of monetizing it. You can use UGG Gloves AdSense ad's or promote affiliate products to make some spare cash if your UGG Boots Blog is getting traffic too. It all comes back to traffic, and unless your paying for it, getting traffic is hard work. Building one way Backlinks to your Blog Discount UGG Boots is one of the most popular methods UGG Boots Outlet to increase Blog traffic.

You'd be surprised to know how many UGGs "Bloggers", holding no more than a High School Diploma are "6 Figure Income - Expert Writers" now because some Big- Wig saw something special in their content. Blogging is awesome, I still write at least a post a day. Nothing is Sand UGG Boots worse than pouring your heart into something Sand UGG and getting nothing out of it.

Quick Personal Experience... Sand UGGs

I love the NFL, I know a lot Navy UGG Boots about it and it's fun for me to Green UGGs write about it. When I first started Blogging I couldn't get 10 visitors a day, and it killed me because I knew Navy UGG I had a lot to offer. I knew that anyone that actually Black UGG Boots knew football would really enjoy my Blog, but I Discount UGG Boots couldn't get it to anyone. Finally I read a report about Green UGG Boots Link Building strategies and I got to work. After about Green UGG 6 weeks of blood sweat and tears and building Backlinks nearly 24/7 the traffic started to roll in. Now, I enjoy writing about the NFL weekly and it results in a steady income Black UGGs for me. Is it making me rich, no far from it, just knowing my writing is what I thought it Navy UGGs was and people are willing to pay me UGG Boots for it, has been very gratifying. Black UGG

By swei on   12/14/2011 11:09 PM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
 
Blogs
  
Search Blogs
  
Archives
  
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
footer