Hi all,

When I moved to .NET I found out that all my Stl data structure where slown down. I wrote a little demo and find out that the same code run faster on Visual 6. I compared CArray Vs std::vector and my results were as following

CArray in .Net (atl::carray ? ) is 20% slower then in Visual 6 ( mfc::CArray ).

std::vector in .Net is 50% slower then in Visual 6.

Do the data structures I checked are much slower or did I do something wrong ???

Thanks, udi

p.s. here is the code I tested ( concole application using MFC )

Code:
// MfcVsStl.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include 
#include "MfcVsStl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;
#include 

using namespace std;
class CMyClass
{
public:
	CMyClass()
	{
		m_myIntMember = 0;
		m_myString = "";
		m_myArray.RemoveAll();
	}
	
	CMyClass(const CMyClass & other )
	{
		*this = other;
	}
	
	CMyClass & operator = (const CMyClass & other )
	{
		m_myIntMember = other.m_myIntMember;
		m_myString = other.m_myString;

		m_myArray.RemoveAll();
		int dummy;
		for (int i=0 ; i m_myArray;
	CString m_myString;
};
typedef std::vector MyClassVecotr;	
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else
	{
		// TODO: code your application's behavior here.
		CMyClass myClass;
		myClass.m_myIntMember = 23847143;

		for ( int i=0 ; i<1000 ; i++ )
		{
			myClass.m_myArray.Add(i);
		}

		myClass.m_myString = "Why is .Net so slow ???";
		CArray udi;
		
		MyClassVecotr udi2;
		DWORD time1 = GetTickCount();
		for ( i=0 ; i<500 ; i++)
		{
			udi2.push_back(myClass);
		}

		DWORD total2 = GetTickCount() - time1;
		int dummy2 = 0;
		
		time1 = GetTickCount();
		for ( i=0 ; i<500 ; i++)
			{
			udi.Add(myClass);
			}

		DWORD total = GetTickCount() - time1;
		int dummy = 0;
	}

	return nRetCode;
}