内存分配速度的一点测试

LARGE_INTEGER litmp;
LARGE_INTEGER qt1, qt2;
QueryPerformanceFrequency(&litmp); double dff = (double)litmp.QuadPart; QueryPerformanceCounter(&qt1); int *a = NULL; for (int i = 0; i < 700; ++i) { for (int j = 0; j < 700; ++j) { a = new int[4]; } } QueryPerformanceCounter(&qt2); float ms = ((float)qt2.QuadPart - (float)qt1.QuadPart) * 1000 / dff; cout<<"time cost: "<<ms<<endl; int *b; QueryPerformanceCounter(&qt1); b = new int[14 * 700 * 700]; QueryPerformanceCounter(&qt2); ms = ((float)qt2.QuadPart - (float)qt1.QuadPart) * 1000 / dff; cout<<"time cost: "<<ms<<endl;

posted @ 2015-04-25 23:48  light_world  阅读(161)  评论(0编辑  收藏  举报