std :: map clear()在调试器中的性能? [英] std::map clear() performance in debugger?

查看:161
本文介绍了std :: map clear()在调试器中的性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

附带的,微不足道的测试程序测试排空一个简单std :: map的性能。使用MSVC 2008和2010,从命令提示符执行调试构建将需要<30秒,但是在调试器中执行时,差不多3分钟。对clear()的调用是完全负责的。如果我进入调试器,callstack将始终指向HeapFree。

问题:为什么有巨大差异?我可以以某种方式更改调试堆设置,以便在调试器中执行时会很快?

The attached, trivial, test program tests the performance of emptying a simple std::map. Using MSVC 2008 and 2010, the debug build will take <30seconds when executed from a command prompt but almost 3 minutes when executed from within the debugger. The call to clear() is entirely responsible for the difference. If I break into the debugger the callstack will always point to HeapFree.
Question: Why the huge difference? Can I somehow change debug heap settings so it'll be fast when executed in the debugger?

#include <map>

int
main ( int, char )
{
    std::map< time_t, double > test;
    for ( int i = 0; i < 1000000; ++i )
    {
        test[i] = i / 3.14;
    }
    test.clear();
    return 0;
}


推荐答案

尝试设置环境变量_NO_DEBUG_HEAP = 1在程序的初始环境中。这将禁用Windows的内部调试堆,这可能会使调试内存损坏问题变得更加困难。

Trying setting the environment variable _NO_DEBUG_HEAP=1 in the program's initial environment. This disables Windows' internal debug heap, which might make it harder to debug memory corruption problems.

这个知识库文章提到标志,如果程序在没有该环境变量的调试器中运行,您可以推断默认(低碎片堆)是禁用的。另见博客文章,该文章讨论调试堆如何减缓程序3-5次。

This KB article mentions the flag, and you can infer that the default (low-fragmentation heap) is disabled if the program is run in a debugger without that environment variable. See also this blog post, which discusses how the debug heap can slow down their program by 3-5 times.

这篇关于std :: map clear()在调试器中的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆