Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Performance problem: -Name slows down Get-ChildItem -Recurse #9119

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

-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' }).TotalSeconds

Expected 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
Reactions are currently unavailable

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.