new跟不new的时间距离

来源:互联网 发布:js二维数组转json对象 编辑:程序博客网 时间:2024/04/29 11:16
/********************************************************************  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
请按任意键继续. . .