PLEASE - you benchmark two different things :-)

C#:
   ArrayList ElementObject=  new ArrayList();

C++:
        VECTORINT intList;
        intList.reserve(5000000L);

I strongly suggest you do reserve the space in the ArrayList, too.
Currently ArrayList (in the C# code) gets expanded multiple times, while
your C+ code has the advantage of being able to allocate the correct
size beforehand :-)

That's NOT a comparable benchmark :-)

Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

-----Original Message-----
From: Yogesh Shetty [mailto:[EMAIL PROTECTED]] 
Sent: Donnerstag, 4. Juli 2002 12:47
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Benchmarking

HI,

We have performed a benchmark for the following collection

1.    VC++ List collection
2.    Silicon Graphic List collection ( VC++ )
3.    .NET ArrayList collection

We populated about 50 lakh records and below are our observation

1.    VC++                        280 ms
2.    SGL                           60 ms
3.    .NET                        1.8 s

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());

VC++ Code (SGL Code)
================
typedef vector <int> VECTORINT;
typedef VECTORINT::iterator VectorIntIter;

fnVectorInt()
{
VECTORINT intList;
VectorIntIter liIter;
long count = 0L;
clock_t startTime;
clock_t endTime;

cout << "Capacity b4 push = " << intList.capacity() << endl;
startTime = clock(); 
intList.reserve(5000000L);
for (count = 0L; count < 5000000L; count++)
{
intList.push_back(count); 
}
endTime = clock();
cout << "Capacity after push = " << intList.capacity() << endl;
cout << "Time for insert(vector) =" << endTime - startTime << endl; 

cout << "Size of vector = " << intList.size() << endl;
long sum = 0;
startTime = clock();
for (liIter = intList.begin(); liIter != intList.end(); liIter++)
{
sum += (*liIter);
}
endTime = clock();

cout << "Sum=" << sum << " Time for traversal-post(vector) =" << endTime
- startTime << endl;

sum = 0;
startTime = clock();
for (liIter = intList.begin(); liIter != intList.end(); ++liIter)
{
sum += (*liIter);
}
endTime = clock();

cout << "Sum=" << sum << " Time for traversal-pre(vector) =" << endTime
- startTime << endl;


sum = 0;
startTime = clock();
int maxcount = intList.size();

for (int i = 0; i < maxcount; ++i)
{
sum += intList[i];
}
endTime = clock();

cout << "Sum=" << sum << " Time for traversal-[](vector) =" << endTime -
startTime << endl;

VECTORINT::reverse_iterator rliIter;
sum = 0;
startTime = clock();
for (rliIter = intList.rbegin(); rliIter != intList.rend(); rliIter++)
{
sum += (*rliIter);

}
endTime = clock();

cout << "Time for reverse traversal(vector) =" << endTime - startTime <<
endl;



return 0;
}



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


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.

Reply via email to