iRon7 / Join-Object

Combines two objects lists based on a related property between them.
MIT License
107 stars 13 forks source link

Replace Foreach-Object with Foreach or For? #6

Closed burkasaurusrex closed 5 years ago

burkasaurusrex commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

@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.