473,378 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Performance Issue with ForEach loop

AK
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.
Nov 17 '05 #1
3 1615
AK <AK@discussions.microsoft.com> wrote:

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


Please see my reply in the performance newsgroup.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Jon Skeet [C# MVP] wrote:
AK <AK@discussions.microsoft.com> wrote:

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

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-
Nov 17 '05 #3
I believe it is Microsoft.public.dotnet.framework.performance

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randell D. | last post by:
Folks, A ng poster recently questioned their usage/creation of arrays and their correct syntax. I got the idea to performance test from a recent (excellent) PHP Tutorial article that was in Linux...
0
by: Randell D. | last post by:
Folks, Ever since reading an interesting article in Linux Format on PHP whereby suggested code writing was made that could enhance performance on a server, I've started testing various bits of...
25
by: Brian Patterson | last post by:
I have noticed in the book of words that hasattr works by calling getattr and raising an exception if no such attribute exists. If I need the value in any case, am I better off using getattr...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
15
by: MuZZy | last post by:
Hi, Consider this: ArrayList al = new ArrayList(); FillList(al); /// NOW TWO SCENARIOS: /// 1. for (int i = 0 ; i < al.Count ; i++)
4
by: Mrinal Kamboj | last post by:
Hi , I am confused that's is not even correctly mentioned in MSDN , if my code snippet works , have a look at this : 1. string s = {"1", "2","3"} ; foreach(string ss in s) { ss = "4" ; //...
3
by: Jesper Stocholm | last post by:
I have developed a data-cleaner that extracts some data from a database, cleans it for illegal/unwanted data and writes it to a CSV-fil for later insertion to a SQL Server 2000 database. My problem...
7
by: David Veeneman | last post by:
This is a very simple question, but for moe reason I can't find an answer. Do I take a performance hit if a foreach statement has to evaluate an expression? For example, consider the following:...
12
by: Mark S. | last post by:
Hello, The app in question is lives on a Windows 2003 server with .NET 2.0 running IIS 6. The page of the app in question processes 2000 get requests a second during peak loads. The app uses...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.