我正在将我的应用程序从Windows 7迁移到Windows 10.
所有功能都没有任何更改,但执行时间比Windows 7
慢.似乎对象构造/破坏很慢.然后我创建了关于malloc()和free()的简单基准程序,如下所示.
for (int i = 0; i < 100; i++)
{
QueryPerformanceCounter(&gStart);
p = malloc(size);
free(p);
QueryPerformanceCounter(&gEnd);
printf("%d, %g\n", i, gEnd.QuadPart-gStart.QuadPart);
if (p == NULL)
printf("ERROR\n", size);
}
Run Code Online (Sandbox Code Playgroud)
我在同一台PC上的Windows 7和Windows 10中运行了这个程序.当数据大小为1,100,1000,10000,100000,1000000,10000000和100000000字节时,我测量了malloc()和free()性能.
在所有上述情况中,窗口10比窗口7慢.
特别是,当数据大小为10000000和100000000时,窗口10的速度超过十倍窗口7.
当数据大小为10000000字节时
当数据大小为100000000字节时
你有什么建议在Windows 10上改进吗?
我已经在Windows 10中尝试了以下内容,但遗憾的是性能没有得到改善.
这是源代码.(2月15日更新)
#include "stdafx.h"
#define START_TIME QueryPerformanceCounter(&gStart);
#define END_TIME QueryPerformanceCounter(&gEnd);
#define PRT_FMT(fmt, ...) printf(fmt, __VA_ARGS__);
#define PRT_TITLE(fmt, ...) printf(fmt, __VA_ARGS__); gTotal.QuadPart = 0;
#define PRT_RESULT printf(",%d", …Run Code Online (Sandbox Code Playgroud)