Click here to Skip to main content
15,907,497 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Unexpected performance Pin
Lutosław15-Oct-08 10:12
Lutosław15-Oct-08 10:12 
GeneralRe: Unexpected performance Pin
Mark Salsbery15-Oct-08 10:47
Mark Salsbery15-Oct-08 10:47 
Try this (and do NOT run in the debugger!)
class myClass
{
};

int _tmain(int argc, _TCHAR* argv[])
{
	const int COUNT = 1000000;
	myClass** objects = new myClass*[COUNT];

	clock_t start1 = clock();
	for (int i = 0; i < COUNT; i++) 
	{
		objects[i] = new myClass();
		delete objects[i];
	}
	clock_t end1 = clock();

	clock_t start2 = clock();
	for (int i = 0; i < COUNT; i++){
		objects[i] = new myClass();
	}
	clock_t end2 = clock();
	clock_t start3 = clock();
	for (int i = 0; i < COUNT; i++){
		delete objects[i];
	}
	clock_t end3 = clock();

	printf("Loop with new/delete: %d\n\n", end1 - start1);
	printf("Loop with new: %d\n", end2 - start2);
	printf("Loop with delete: %d\n", end3 - start3);
	printf("Total of loop new and loop delete: %d\n", end3 - start2);

	printf("\n\nPress enter to end...");
	getchar();

	delete[] objects;

	return 0;
}


Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: Unexpected performance Pin
led mike15-Oct-08 10:55
led mike15-Oct-08 10:55 
GeneralRe: Unexpected performance Pin
Mark Salsbery15-Oct-08 10:56
Mark Salsbery15-Oct-08 10:56 
GeneralRe: Unexpected performance Pin
Lutosław15-Oct-08 11:03
Lutosław15-Oct-08 11:03 
GeneralRe: Unexpected performance Pin
led mike15-Oct-08 11:24
led mike15-Oct-08 11:24 
GeneralRe: Unexpected performance Pin
Lutosław15-Oct-08 10:59
Lutosław15-Oct-08 10:59 
GeneralRe: Unexpected performance Pin
Mark Salsbery15-Oct-08 11:14
Mark Salsbery15-Oct-08 11:14 
GeneralRe: Unexpected performance Pin
Mark Salsbery15-Oct-08 11:17
Mark Salsbery15-Oct-08 11:17 
GeneralRe: Unexpected performance Pin
led mike15-Oct-08 11:22
led mike15-Oct-08 11:22 
GeneralRe: Unexpected performance Pin
Mark Salsbery15-Oct-08 12:40
Mark Salsbery15-Oct-08 12:40 
GeneralRe: Unexpected performance Pin
Lutosław15-Oct-08 11:55
Lutosław15-Oct-08 11:55 
AnswerRe: Unexpected performance Pin
Mark Salsbery15-Oct-08 11:12
Mark Salsbery15-Oct-08 11:12 
GeneralRe: Unexpected performance Pin
Lutosław15-Oct-08 12:05
Lutosław15-Oct-08 12:05 
GeneralRe: Unexpected performance Pin
Mark Salsbery15-Oct-08 12:38
Mark Salsbery15-Oct-08 12:38 
GeneralRe: Unexpected performance Pin
Lutosław16-Oct-08 4:43
Lutosław16-Oct-08 4:43 
GeneralRe: Unexpected performance Pin
Mark Salsbery16-Oct-08 4:48
Mark Salsbery16-Oct-08 4:48 
GeneralRe: Managed code *is* slower Pin
Rob Bryce20-Oct-08 5:50
Rob Bryce20-Oct-08 5:50 
GeneralRe: Managed code *is* slower Pin
Mark Salsbery20-Oct-08 6:10
Mark Salsbery20-Oct-08 6:10 
GeneralRe: Managed code *is* slower Pin
Rob Bryce22-Oct-08 6:53
Rob Bryce22-Oct-08 6:53 
GeneralRe: Managed code *is* slower Pin
Mark Salsbery22-Oct-08 7:39
Mark Salsbery22-Oct-08 7:39 
GeneralRe: Managed code *is* slower Pin
led mike21-Oct-08 4:46
led mike21-Oct-08 4:46 
GeneralRe: Managed code *is* slower Pin
Rob Bryce21-Oct-08 5:31
Rob Bryce21-Oct-08 5:31 
GeneralRe: Managed code *is* slower Pin
led mike21-Oct-08 7:01
led mike21-Oct-08 7:01 
GeneralRe: Managed code *is* slower Pin
Rob Bryce21-Oct-08 8:44
Rob Bryce21-Oct-08 8:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.