在VS 2012中调试STL
debugging STL in VS 2012
根据这里和其他地方的帖子,我试图通过设置_NO_DEBUG_HEAP
、_SECURE_SCL
和_HAS_ITERATOR_DEBUGGING
符号来加速VS 2012调试(本机C++,STL)。
没有运气。
我编写了一个基本的测试程序,用于解析一个大型文本文件(100,000 行,100 列),然后......
释放模式下的输出:
read 102595 lines in 6.051 seconds
调试模式下的输出:
read 102595 lines in 317.979 seconds <== 50x slower, ouch !!!
下面是完整的源代码(C++控制台应用,没有预编译的标头)。#define 语句没有任何效果。调试速度仍然慢得令人难以忍受。 有什么建议吗?
// testAppDebugSTL.cpp : Defines the entry point for the console application.
//
#ifdef _DEBUG
#define _SECURE_SCL 0
#define _HAS_ITERATOR_DEBUGGING 0
#define _NO_DEBUG_HEAP 1
#endif
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
int main(int argc, char** argv[])
{
std::ifstream f ("c:\temp\largeFile.csv");
std::vector<std::string> lines;
std::vector<std::vector<std::string> > tokenized_lines;
size_t num_lines = 0;
clock_t tBeg = clock();
while(!f.eof())
{
std::string line;
std::getline(f, line);
if (!f.eof())
{
lines.push_back(line); num_lines++;
std::stringstream ss(line);
std::string token;
std::vector<std::string> tokens;
while (std::getline(ss, token, ','))
{
tokens.push_back(token);
}
tokenized_lines.push_back(tokens);
}
}
clock_t tEnd = clock();
std::cout << "read " << num_lines << " lines in " << double(tEnd - tBeg)/CLOCKS_PER_SEC << " seconds";
return 0;
}
更改发布模式以输出调试符号。 一开始调试优化的发布版本有点奇怪,但你会习惯的(阅读一些汇编程序的能力会有所帮助)。
还要记住先在小型数据集上运行测试。
相关文章:
- 当回溯以零开始时,如何调试崩溃
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 为什么这个运算符<重载函数对 STL 算法不可见?
- 在C应用程序中运行C++(带有STL)函数
- 使用2个键的cpp-stl::优先级队列排序不正确
- 在linux上调试巨大的C++项目
- 为什么使用__LINE_的代码在发布模式下在MSVC下编译,而不是在调试模式下
- STL Map.使用VS2010在调试和发布方面的表现不同
- Visual Studio 2013 C++:STL 容器的元素显示在调试器中
- 如何调试STL/C++的GCC/LD链接过程
- DEV-C++5.11 STL迭代器的调试问题
- VS2010 调试与发布:为什么 STL 列表解释错误
- 在VS 2012中调试STL
- 调试工具跟踪程序中所有STL容器的大小
- 在Eclipse中合理调试STL容器
- 调试c++代码,涉及使用:vector, string, STL
- 打印/调试libc++ STL与Xcode/LLDB
- Python异常:在调试支持stl的c++代码时,索引超出范围
- 混合STL调试/发布库
- 使用STL列表调试问题