PowerTab 0.99.5.0 Much Slower than 0.99 Beta 2 (MOW)

Jul 29, 2010 at 6:31 AM
Edited Jul 29, 2010 at 6:43 AM

I thought that PowerTab seemed to be running slower than I remembered, so I removed the module and loaded an old one from MOW and gave it a try.

tabexpansion 'dir \\server\c' '\\server\c'

Duration 0.99 Beta 2 - 0.07 seconds

Duration 0.99.5.0 - 0.64 seconds

PowerTab 0.99.5.0 takes about 9 times as long to run as 0.99 Beta 2.  I'm not sure why, but it is noticable on my system at home (not the newest thing). 

I hope there is some way to speed it up, since I really like it that you are working on making this so much better.

Thanks,


Stephen

Jul 30, 2010 at 2:13 PM

I found out part of the reason for the speed difference.  0.99.5.1 runs Get-Command 4 times and 0.99 Beta 2 didn't run Get-Command at all.  Originally 0.99.5.1 did it 5 times, but a previous change I made ( see issue "Change how alias is resolved in TabExpansionUtil.ps1" - also reduces average duration from 0.64 to 0.52 seconds), removed one of the references to Get-Command by using the property ResolvedCommand instead.

I determined the number of calls to Get-Command by using
Set-PSBreakpoint -Command Get-Command
tabexpansion 'dir \\server\c' '\\server\c'

0.99.5.1 runs Get-Command in TabExpansionUtil.ps1 4 times ( I'd list the line numbers, but I doubt if mine match right now with the debug stuff I'm doing ).  It does it 1 time for dir and 3 times for Get-ChildItem.  I think reducing the number of time Get-ChildItem gets called would do a lot to speed this up.  As it is, I use the old version of PowerTab so much, that the current version noticably slows me down (Even if the functionality is better).  If it could be reduce to only 2 calls to Get-Command, that would be a big benifit.

Thanks for the work you're doing on PowerTab.  Great utility and makes a huge difference in the ease of use of PowerShell.

Coordinator
Aug 5, 2010 at 4:38 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 12, 2010 at 12:52 AM

Another thought I have for speeding things up a little bit is to cache the results of Get-Command for at least the duration of tabexpansion.  It would be nice to cache it for longer, but I don't think having tabexpansion be out of date would be popular.

Since it is calling Get-Command 1 time for dir and then 3 times for Get-ChildItem in my example, then if it cached the "dir" lookup and took the results, "Get-ChildItem", and added that to a cache as well, it would only have to execute 1 Get-Command and be able to resolve the other 3 requests from the cache.  Even if you didn't add the result to the cache, it might still be possible to eliminate 2 executions of Get-Command.

Coordinator
Aug 12, 2010 at 4:53 AM
That was basically my solution. Save the CommandInfo object in the context after the first call, and then use it thereafter.
Aug 13, 2010 at 5:49 AM

I guess it would have helped if I had looked at the new code closer.  I'm still trying to figure out what all the different parts do and when they are used.

Currently I'm getting about 0.15 seconds for the example I started out this thread with.  This is really a large improvement and makes it much more usable.