new跟不new的时间距离

/******************************************************************** 
 file name : new.h 
 author  :   Clark/陈泽丹 
 created :   2011-11-29 
*********************************************************************/  

#include <iostream>
#include <Windows.h>
using namespace std;

void test1()
{
	int* p = new int;
	delete p;
	p = NULL;
}

void test2()
{
	int p;
}

void main()
{
	int s, e;

	s = GetTickCount();
	for(int i=0; i<10000; i++)
		test2();
	e = GetTickCount();
	cout<<"test2 cost: "<<e-s<<endl;

	s = GetTickCount();
	for(int i=0; i<10000; i++)
		test1();
	e = GetTickCount();
	cout<<"test1 cost: "<<e-s<<endl;

	system("pause");
}

test2 cost: 0
test1 cost: 32
请按任意键继续. . .

你可能感兴趣的:(File,null)