1. new 与 HeapAlloc :
1.测试环境:
1.操作系统:Windows 7 64位旗舰版
2.电脑类型:笔记本电脑(戴尔 Precision 7510)
3.处理器:i7-6820HQ @ 2.70GHz 四核
4.内存:32GB
5.显卡:NVIDIA Quadro M1000M
6.编译环境:Microsoft Visual Studio 2015
7.项目配置:Debug x64
8.辅助工具:无
2.对单个变量只分配不释放:
1.代码:
#define Loop 100000000 int* p; DWORD t1 = GetTickCount(); for (int i = 0; i < Loop; ++i) { p = new int; } DWORD t2 = GetTickCount(); DWORD t_new = t2 - t1; t1 = GetTickCount(); for (int i = 0; i < Loop; ++i) { p = (int*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(int)); } t2 = GetTickCount(); DWORD t_heap = t2 - t1; printf("new Time: %d \nHeapAlloc Time: %d", t_new, t_heap);
2.结果:
<未完待续>
时间: 2024-10-14 05:47:48