Profiling a powershell module

Code profiling for .NET Developers

Moderators: Luke Jefferson, StephenC, Alex.Davies, AndrewH, melvyn.harbour, Laura Morley

Profiling a powershell module

Postby sh54 » Mon Oct 24, 2011 9:45 am

I have tried to profile a powershell module compiled as a 32-bit c# dotnet 3.5 library by choosing ".NET executable" where the executable is "C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe" and giving it arguments: noexit -command Import-Module "C:/xyz/MY-MODULE.dll"

However, whilst I get to see a graph of the CPU, I cannot inspect which methods take a long time. All the time used is placed under a row labeled "(Waiting for synchronization)".

I have no trouble attaching the Visual Studio debugger directly to powershell.exe and stepping through my source code.

Is there any specific settings I should be using to get profiling working correctly?
sh54
 
Posts: 2
Joined: Mon Oct 24, 2011 9:38 am

Postby Brian Donahue » Mon Oct 24, 2011 10:25 am

What does the Import-Module command do? Doesn't it just load the module into Powershell? Then you're not actually running any managed code, so no, you shouldn't expect to see any results.

You'll need to call some code in the DLL.
Brian Donahue
 
Posts: 6669
Joined: Mon Aug 23, 2004 10:48 am

Postby sh54 » Mon Oct 24, 2011 11:12 am

My apologies! I just was not looking hard enough in the call tree (and forgot to mention I was calling a method in my dll from powershell).
sh54
 
Posts: 2
Joined: Mon Oct 24, 2011 9:38 am

Postby Brian Donahue » Mon Oct 24, 2011 11:27 am

If you are invoking some code then this is probably the same common problem of not getting results regardless of the kind of app.

You can try the usual first steps - show all methods (vs just the ones that have source), show all threads, and uncheck "hide insignificant methods".
Brian Donahue
 
Posts: 6669
Joined: Mon Aug 23, 2004 10:48 am

Postby Brian Donahue » Tue Oct 25, 2011 11:02 am

Just checking - did turning some of those filters off get the methods to show in the results?
Brian Donahue
 
Posts: 6669
Joined: Mon Aug 23, 2004 10:48 am


Return to ANTS Performance Profiler 6

Who is online

Users browsing this forum: No registered users and 0 guests