PowerShell/Pscx Startup Time

Topics: Developer Forum
Coordinator
Feb 20, 2007 at 12:41 AM
Edited Feb 20, 2007 at 12:41 AM
It seems that loading our snapin is now taking ~2.7 seconds on my Vista PC (2 GB RAM, 3 GHz P4).

PS C:\Users\Keith> measure-command { Add-PSSnapin Pscx }
 
 
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 2
Milliseconds      : 676
Ticks             : 26769969
TotalDays         : 3.09837604166667E-05
TotalHours        : 0.00074361025
TotalMinutes      : 0.044616615
TotalSeconds      : 2.6769969
TotalMilliseconds : 2676.9969
I wonder what this is related to. My PC is not on any domain (home PC). Any chance that the AD or Directory services providers are taking long to initialize? Could it be all the format/typedata files we are integrating?
Developer
Feb 20, 2007 at 12:51 AM
It might be the directory services provider. I need to find better way to determine whether the machine is joined to a domain.
Developer
Feb 20, 2007 at 1:07 AM
It "should" be fixed now in 1.1. I don't have any unjoined machine right here. Could you measure it again, please?
Coordinator
Feb 20, 2007 at 2:26 AM
Yeah that helped a lot - thanks!

PS C:\Users\Keith> measure-command { Add-PSSnapin Pscx }
 
 
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 0
Milliseconds      : 390
Ticks             : 3908899
TotalDays         : 4.52418865740741E-06
TotalHours        : 0.000108580527777778
TotalMinutes      : 0.00651483166666667
TotalSeconds      : 0.3908899
TotalMilliseconds : 390.8899
Developer
Feb 20, 2007 at 2:27 AM
wow, that's much better :)
Coordinator
Feb 20, 2007 at 2:37 AM
My profile is still loading slower than it should. I've instrumented my profile and here's what I'm seeing:

Before dot-sourcing 0.70308
After dot-sourcing TabExpansion 0.749952
After dot-sourcing GenericAliases 0.8231895
After dot-sourcing GenericFilters 0.8544375
After dot-sourcing GenericFunctions 0.9345105
After dot-sourcing PscxAliases 1.122975
After dot-sourcing Debug 1.1532465
After dot-sourcing Environment 1.3622175
After dot-sourcing Environment.VisualStudio2005 1.50381
After dot-sourcing CD 1.5555645
After dot-sourcing DIR 1.595601
After dot-sourcing complete 1.599507
After EyeCandy.Keith 1.6825095
Transcript started, output file is C:\Users\Keith\Docum
After dot-sourcing TranscribeSession 1.7508645
 
VolumeLabel        Name          UsedSpace          Fre
-----------        ----          ---------          ---
Local Disk         C:\     147,608,690,688    102,448,0
Local Disk         D:\     111,827,640,320     14,002,6
Local Disk         F:\      16,198,778,880     18,009,9
SEAGATE            H:\      94,147,104,768     65,875,6
After Get-DiskUsage 1.9344465
Profile done 1.9383525
Dot-sourcing PscxAliases is taking about 200 mS and Environment is taking about 210 mS, Env.VS is taking about 140 mS and Get-DiskUsage is taking about 180 mS. Here's what I'm sticking in my profile:

$start = get-date # at top
 
. "$Env:PscxHome\Profile\Environment.VisualStudio2005.ps1"
"After dot-sourcing Environment.VisualStudio2005 $(((get-date)-$start).TotalSeconds)"
Developer
Feb 20, 2007 at 2:58 AM
So what can we optimize here? I don't see many opportunities, except of merging files together...
Coordinator
Feb 20, 2007 at 4:42 AM
Not sure unless we reduce the number of aliases. I'm not quite sure why Environment.ps1 is taking so long. Guess I'll need to profile it. Right now with Get-DiskUsage removed (but with transcribe) I'm loading in about 1.8 - 2.0 seconds which is just at the range of tolerability IMO. As long we don't go over 2.0 secs I "think" we're OK.