PowerShell / PSScriptAnalyzer

Download ScriptAnalyzer from PowerShellGallery
https://www.powershellgallery.com/packages/PSScriptAnalyzer/
MIT License
1.85k stars 375 forks source link

Time sum to scan sub folders is much longer than scanning parent folder #469

Open YuanMSFT opened 8 years ago

YuanMSFT commented 8 years ago

In an example of folder "A" contains sub folder "B" and "C".

Scanning folder "A" recursively took 53 seconds.

Scanning folder "B" recursively took 38 seconds. Scanning folder "C" recursively took 37 seconds.

The sum to scan sub folder is 22 seconds more than scanning the parent folder. 38+37-53=22.

ShaydeNofziger commented 8 years ago

Using the Measure-Command cmdlet, I am seeing similar results.

Folder A:

Folder B:

Folder C:

I'm not sure if this is a bug, as there are probably setup/teardown things that are only occurring once when scanning folder C recursively, whereas the setup / teardown is counted twice when summing A's and B's time. But I can confirm the findings.

MironAtHome commented 8 years ago

Seems to me this indicates out of 53, 38, and 37 second per attempt, 22 were spent somewhere else, but scanning directories. Something like initialization and cleanup. Is there any way to profile time spent at more granular level?