Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Foreach-Object with Foreach or For? #6

Closed
burkasaurusrex opened this issue Jun 6, 2019 · 2 comments
Closed

Replace Foreach-Object with Foreach or For? #6

burkasaurusrex opened this issue Jun 6, 2019 · 2 comments
Assignees

Comments

@burkasaurusrex
Copy link

Foreach ends up being about twice as fast in simple tests - I wonder if it would speed up Join-Object?

Measure-Command { 0..1000000 | Foreach-Object $_ }

Measure-Command { foreach ($i in 0..1000000) {$i} }

Measure-Command { for ($i = 0; $i -lt 1000000; $i++) {$i} }
@iRon7 iRon7 self-assigned this Jul 14, 2019
@iRon7
Copy link
Owner

iRon7 commented Jul 14, 2019

@burkasaurusrex, sorry for the late response (I didn't get any notifications for new issues).
Anyways, I coincidentally removed the For commands last update to better support DataTables. I will do some performance testing between using the ForEach-Object cmdlet and the ForEach command in this Join-Object cmdlet soon and let you know the results.

iRon7 added a commit that referenced this issue Jul 17, 2019
3.0.5     2019-07-14 meany       Issue #5, resolved: Cannot dot source / invoke script on 2012 R2 bug
3.0.6     2019-07-16 Ronald Bode Issue #6, improved performance (~2x on large tables), thanks to @burkasaurusrex' suggestion
@iRon7
Copy link
Owner

iRon7 commented Jul 17, 2019

@burkasaurusrex,
Thanks for the hint, on larger tables (of a few 1000 objects), there is indeed a performance increase of almost 2 times by using the ForEach command rather than the ForEach-Object cmdlet.
I have uploaded a new version (3.0.6) with this enhancement.

@iRon7 iRon7 closed this as completed Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants