| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
When using & { process { $_ }} instead of Foreach-Object/Where-Object, there is a huge performance gain, apparently caused by using a simple function instead of an advanced function. Parameter binding is no issue for these cmdlets in the vast majority of use cases as users typically only use $_ in their payload scriptblocks, and thus internally switching to a simple function w/o cmdletbinding might improve the speed without having to reinvent the entire cmdlet. |
Sorry, something went wrong.
|
I have an open issue #9941 for Where-Object. Dongbo Wang (@daxian-dbw) is taking care of it. Maybe those two can be worked together? Seems similar to me? |
Sorry, something went wrong.
|
I guess there is 2 places for perf consideration:
|
Sorry, something went wrong.
|
Jason Shirk (@lzybkr) Dongbo Wang (@daxian-dbw) could the suggestion from Dr. Tobias Weltner (@TobiasPSP) be considered for 7.1? In his blog he shows many alternative approaches to speed up pwsh that should be unnecessary due to optimizations in the core. |
Sorry, something went wrong.
Sorry, something went wrong.
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
Sorry, something went wrong.
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment. |
Sorry, something went wrong.
|
Why did this PR get marked as 'Waiting on Author' when there wasn't any maintainer feedback that I can see? EDIT: Oops, nevermind. Didn't notice daxian-dbw was part of the PowerShell team. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Proof of concept change to speed up ForEach-Object. I don't plan to do further work, but someone else can hopefully use the idea.
This undoubtedly misses something important, but it does make ForEach-Object faster. (Note I include the loop for comparison, the cmdlet is still an order of magnitude slower.)
PR Context
People often use trivial pipelines with ForEach-Object to micro-benchmark PowerShell and conclude that it is slow, or they should use the foreach statement instead of the cmdlet.
I've long had the idea that we can have dynamic sites like we have for property access or method invocation, for but instead for parameter binding.
This PR is the embodiment of that idea for the single use case of binding InputObject for the ForEach-Object command.
PR Checklist