-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management moduleWG-Engine-Performancecore PowerShell engine, interpreter, and runtime performancecore PowerShell engine, interpreter, and runtime performance
Description
-Name is a convenient switch to only output item names (without -Recurse) or relative paths (with -Recurse).
Given that only string instances rather than System.IO.File/DirectoryInfo instances are output, one would expect -Name to speed things up (or at least not to slow things down); however, with -Recurse present, -Name slows down the command noticeably.
Steps to reproduce (on Windows)
# Warm up the cache
$null = Get-ChildItem -Recurse 'C:\Program Files'
# Without -Name
(Measure-Command { Get-ChildItem -Recurse 'C:\Program Files' }).TotalSeconds
# With -Name
(Measure-Command { Get-ChildItem -Name -Recurse 'C:\Program Files' }).TotalSecondsExpected behavior
The command with -Name should be faster (or at least not slower).
Actual behavior
Sample timings:
1.544098 # without -Name
4.5759553 # with -Name
That is, adding -Name made the command about 3 times slower.
Environment data
PowerShell Core 6.2.0-preview.4
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management moduleWG-Engine-Performancecore PowerShell engine, interpreter, and runtime performancecore PowerShell engine, interpreter, and runtime performance