PSProfiler icon indicating copy to clipboard operation
PSProfiler copied to clipboard

Recursive dive in to a function source

Open PrzemyslawKlys opened this issue 4 years ago • 1 comments

I would like to measure my script problems. But since I mostly deal with functions that I create doing:

Measure-Script {
    MyFunction
}

Doesn't bring me any useful results. It would be nice if it would dive (or as you said "explode") into MyFunction and then asses it instead of just doing what it does now.

Thanks, looking forward to improving some of my code with your measurements.

PrzemyslawKlys avatar Jun 18 '20 17:06 PrzemyslawKlys

As mentioned in Twitter this is definitely possible for script functions. One of the ideas I had was to pass an include list of functions to expand, if not recursively then at least from the immediate script block scope, and then use that to choose which functions to explode and instrument, like:

$measurement = Measure-Script {
  # ... 
  ... |ForEach-Object {
    Call-Function $_
  }
  # ...
} -ExplodeFunction 'Call-Function'

$measurement.ProfiledFunctions['Call-Function'] # would hold line measures for `Call-Function` execution

@jaapbrasser mentioned he also had something in mind for this, let's see what he comes up with :)

IISResetMe avatar Jun 19 '20 10:06 IISResetMe