Performance Issue with ForEach loop

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Everyone,

For Last a few weeks I have been involved with performance tuning of an
application. I have observed that if I do a loop over a collection
(ArrayList/HashTable) which has 50000 objects in one shot then it takes about
15 minutes to do the computation. But if I break this to loop of only 5000
objects and do all computation in 10 loops of 5000 each then it takes about 1
minutes 30 seconds.

I am trying to find a reason for this but I haven't been able to get one. If
I do a search on net then it becomes more confusing as some will say don't
use ForEach while some would say use only ForEach. I don't know which advice
to take.

(I have tried using For loop also but result is some what the same).

The loop code look like:
foreach(MyClass obj in listcollection)
{
// do something with this obj.
}


Can someone throw some light on the possible reasons for above mentioned
observations.

Thanks in advance,
AMar.
 
Can someone throw some light on the possible reasons for above mentioned
observations.

Please see my reply in the performance newsgroup.
 
Jon said:
Please see my reply in the performance newsgroup.

Jon, could you supply the name of this newsgroup please (or a link to your
post). I am also interested in seeing the answer(s) on this one.

Thanks,
-rick-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top