小编ple*_*s92的帖子

Windows 10中的malloc比Windows 7慢

我正在将我的应用程序从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字节时

  • Windows 7:0.391392毫秒
  • Windows 10:4.254411毫秒

当数据大小为100000000字节时

  • Windows 7:0.602178毫秒
  • Windows 10:38.713946毫秒

你有什么建议在Windows 10上改进吗?

我已经在Windows 10中尝试了以下内容,但遗憾的是性能没有得到改善.

  • 禁用超级抓取
  • 已禁用Ndu.sys
  • 磁盘清理

这是源代码.(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)

c performance windows-10

20
推荐指数
2
解决办法
1483
查看次数

标签 统计

c ×1

performance ×1

windows-10 ×1