That makes more sense - at least youre Hindi is better than mine . Ben
-----Original Message----- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED]]On Behalf Of Alois Reisinger Sent: Friday, 5 July 2002 4:35 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Benchmarking as far as I remember, in india lakh means 100000 so he was talking about 20 lakhs what should be equivalent to 2 million. a -----Original Message----- From: Ben Kloosterman [mailto:[EMAIL PROTECTED]] Sent: Freitag, 05. Juli 2002 07:23 To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Benchmarking Can you post more detail / your code it seems to take a long time . eg time is 0.0100145ms 100 microseconds for create arraylist and 50 entries. as mentioned earlier ArrayLists are a bit brain dead but useful for some things . I tend to stick with arrays or HashTables. ArrayLists will do an Arraycopy when inserting an element or when it needs to grow . If you really want performance use an Array of structs and you will get good performance eg an array of int does the above in 0.001301833ms or 1microsecond eg static void Main(string[] args) { System.Collections.ArrayList test ; DateTime start = DateTime.Now; for (int j = 0 ; j < 1000 ; j++) { test = new System.Collections.ArrayList(50); for ( int i = 0 ; i < 50 ; i++) test.Add(i); } System.TimeSpan span = DateTime.Now - start; Console.WriteLine("time is " + span.TotalMilliseconds/1000 + "ms"); } Ben -----Original Message----- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED]]On Behalf Of Yogesh Shetty Sent: Thursday, 4 July 2002 10:17 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Benchmarking Thx for the response... Arraylist with 20 lakhs record but this time with class reference VC++ - 93 ms Silicon Graphic List - GPF C# (Debug Version ) - 110 ms C# (Release Version ) - 93 ms Can this be optimized further :-) Regards Yogesh Shetty Team COE Financial Technologies (India) Ltd. URL: <http://www.ftindia.com> www.ftindia.com mailto : <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] contact : +91 22 6164145 -----Original Message----- From: Moderated discussion of advanced .NET topics. [ <mailto:[EMAIL PROTECTED]> mailto:[EMAIL PROTECTED]] On Behalf Of Fritz Onion Sent: Thursday, July 04, 2002 5:55 PM To: <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Benchmarking > Can this be optimized further ?? I know this is the price we have to > pay for using managed code, once container is fully populated we > performed a search,traversing,hot spot insertion etc... the difference > between .NET & VC++ was negligible but SGL was at its best. > unfortunately SGL is supported only in VC++. > > We are developing a prototype for a mission critical financial > application This has led to an unwieldy situation... Whether the > components needs to be written in C# or VC++ and performance is the key > issue which needs to be addressed. > > > Enclosed below is .NET Code > =================== > ArrayList ElementObject= new ArrayList(); > int Counter; > DateTime StartTime,EndTime; > TimeSpan DiffValue; > StartTime = DateTime.Now; > for ( Counter = 0;Counter<=5000000;Counter++) > { > ElementObject.Add(Counter); > } > EndTime = DateTime.Now; > DiffValue = EndTime - StartTime; > Console.WriteLine("{0} > {1}",DiffValue.Milliseconds.ToString(),DiffValue.ToString()); As a previous poster mentioned, the ArrayList is dynamically growing, which is leading to some of the inefficiency. The other unnecessary inefficiency is the storage of int datatypes in the ArrayList. The ArrayList stores everything as an object, so integers must be boxed (wrapped in a class wrapper) prior to insertion, and unboxed upon retrieval. You can fix the dynamic growth issue by initializing the capacity of the ArrayList when you create it: ArrayList ElementObject = new ArrayList(5000000); But the boxing issue is not as easily dealt with. If, in your final design, you intend to store class references in the array list instead of integers (or any value type), then change your test to store class references, and your performance discrepancies should all but disappear. If you do intend on storing integers (or doubles, or floats, or enums, or structs, ...), then you are better off using a native array, or check out .NET Collection Gen available at [1] if you need more than a plain array. -Fritz [1] <http://www.sellsbrothers.com/tools/> http://www.sellsbrothers.com/tools/ Fritz Onion DevelopMentor <http://staff.develop.com/onion/> http://staff.develop.com/onion/ You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at <http://discuss.develop.com> http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.