Title: Performance problem: -Name slows down Get-ChildItem -Recurse · Issue #9119 · PowerShell/PowerShell · GitHub
Open Graph Title: Performance problem: -Name slows down Get-ChildItem -Recurse · Issue #9119 · PowerShell/PowerShell
X Title: Performance problem: -Name slows down Get-ChildItem -Recurse · Issue #9119 · PowerShell/PowerShell
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 ...
Open Graph 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 ...
X 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 ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/9119
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Performance problem: -Name slows down Get-ChildItem -Recurse","articleBody":"`-Name` is a convenient switch to only output item _names_ (without `-Recurse`) or _relative paths_ (with `-Recurse`).\r\n\r\nGiven 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.\r\n\r\n# Steps to reproduce (on Windows)\r\n\r\n```powershell\r\n# Warm up the cache\r\n$null = Get-ChildItem -Recurse 'C:\\Program Files' \r\n\r\n# Without -Name\r\n(Measure-Command { Get-ChildItem -Recurse 'C:\\Program Files' }).TotalSeconds\r\n\r\n# With -Name\r\n(Measure-Command { Get-ChildItem -Name -Recurse 'C:\\Program Files' }).TotalSeconds\r\n```\r\n\r\n# Expected behavior\r\n\r\nThe command with `-Name` should be faster (or at least not slower).\r\n\r\n# Actual behavior\r\n\r\nSample timings:\r\n\r\n```none\r\n1.544098 # without -Name\r\n4.5759553 # with -Name\r\n```\r\n\r\nThat is, adding `-Name` made the command about 3 times _slower_.\r\n\r\n# Environment data\r\n\r\n```none\r\nPowerShell Core 6.2.0-preview.4\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-03-11T18:46:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/9119/PowerShell/issues/9119"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:86fb7cac-029a-e160-aa60-90e13f4040cf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB3C:388D53:2AF0420:3E08A67:6A5674B1 |
| html-safe-nonce | 973d29123df097d52594a6900260a3cd6256c16d926205c740ab702868b226d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjNDOjM4OEQ1MzoyQUYwNDIwOjNFMDhBNjc6NkE1Njc0QjEiLCJ2aXNpdG9yX2lkIjoiNTk4NzM2MDgwNjcxNDg5NzU4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d16812e64bdebeb3dc561a0e177cb59a601fa4dce8c4a6503e254ff2391131da |
| hovercard-subject-tag | issue:419627184 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/9119/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1db93384881b57a1616050e4419b4eed2ae796d78fa222116676ea4033365ab4/PowerShell/PowerShell/issues/9119 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1db93384881b57a1616050e4419b4eed2ae796d78fa222116676ea4033365ab4/PowerShell/PowerShell/issues/9119 |
| og:image:alt | -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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19b5ee9431dcfce15ab4b001d626e4e3a6ba1acb7be814813a52bbebd9a86ef5 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | afc01ffdb045f4ff81c6122091366ade7b6166b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width