- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我对巨大的嵌套数据结构有疑问(来自 JSON Spirit)。在调试时,当这个结构充满数据时,Eclipse 开始工作非常缓慢,在每一步之后它都等待来自 GDB 的打印数据。问题是即使我没有扩展这个数据结构,Eclipse 也会收集很多关于局部变量的信息。当 pretty-print 关闭时,它可以工作,但当然我在 STL 容器内看不到任何东西。
我正在使用来自 GDB SVN 的打印机
这里有一小段代码可以产生类似的问题:
#include <iostream>
#include <string>
#include <map>
int main() {
std::map<std::string, std::map<std::string, std::map<std::string, std::string>>> mega_map;
const int factor = 50;
for (int c = 0; c < factor; ++c){
std::map<std::string, std::map<std::string, std::string>> b_map;
for (int b = 0; b < factor; ++b){
std::map<std::string, std::string> a_map;
for (int a = 0; a < factor; ++a){
std::string a_str = "a";
a_str += (std::to_string(a));
auto a_pair = std::make_pair("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + a_str, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
a_map.insert(a_pair);
}
std::string b_str = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
b_str += (std::to_string(b));
b_map[b_str] = a_map;
}
std::string c_str = "cccccccccccccccccccccccccccccccccccccccc";
c_str += (std::to_string(c));
mega_map[c_str] = b_map;
}
return 0;
}
只需在“返回”处刹车,您就会发现在“变量”窗口中获取某些内容需要花费很多时间。在此期间您无法调试。
GDB 中有一个标志 set print elements number-of-elements
可以限制容器中要打印的元素数量,它有效,但虽然我对这些嵌套结构不感兴趣,但这个设置影响我想检查的其他容器。
有什么解决办法吗?
谢谢。
最佳答案
我们(同事和我)今天遇到并调查了这个问题,这是我们的结论。不幸的是,我们没有找到仅使用某些设置来解决此问题的方法,但在 CDT 和 GDB 中发现了一些可以帮助缓解该问题的更改。如果您可以构建自己的 CDT 或 GDB,它可能会对您有所帮助。
CDT 使用 -stack-list-locals
向 GDB 询问局部变量,并使用参数来获取它们的值。对于打印精美的容器,GDB 最终包括子项:
std::vector of length 20, capacity 20 = {<children here>}
对于嵌套的数据结构,它最终可能会很大。一种解决方法是让 CDT 不询问这些值。它将正确使用变量对象,并在您扩展数据结构时根据需要请求值。这是差异:
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIStack.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIStack.java
index c319eb8..23bbb8a 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIStack.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIStack.java
@@ -859,7 +859,7 @@ implements IStack, ICachingService {
fMICommandCache.execute(
// Don't ask for value when we are visualizing trace data, since some
// data will not be there, and the command will fail
- fCommandFactory.createMIStackListLocals(frameDmc, !fTraceVisualization),
+ fCommandFactory.createMIStackListLocals(frameDmc, false),
new DataRequestMonitor<MIStackListLocalsInfo>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
@@ -988,7 +988,7 @@ implements IStack, ICachingService {
// the result without the values
// Don't ask for value when we are visualizing trace data, since some
// data will not be there, and the command will fail
- fCommandFactory.createMIStackListLocals(frameDmc, !fTraceVisualization),
+ fCommandFactory.createMIStackListLocals(frameDmc, false),
new DataRequestMonitor<MIStackListLocalsInfo>(getExecutor(), countingRm) {
@Override
protected void handleSuccess() {
在其他情况下,CDT 会发出使 GDB 吐出完整递归数据结构的请求,也就是说,如果您在变量 View 中选择了变量,或者将其悬停。然后您会注意到“详细信息”部分中的完整扩展值。但是,如果您在执行步骤时没有选择该变量,它会执行得很快。
GDB 中可能的解决方法是不让它递归地输出 pretty-print 数据结构。例如,这个 hack 将它们限制为一个级别的 child :
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 66929bf..b213699 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -700,7 +700,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
/* Print the section */
print_result = print_string_repr (printer.get (), hint.get (), stream,
recurse, options, language, gdbarch);
- if (print_result != string_repr_error)
+ if (print_result != string_repr_error && recurse == 0)
print_children (printer.get (), hint.get (), stream, recurse, options,
language, print_result == string_repr_none);
如果此递归限制是具有合理值的设置,则可以考虑对上游 GDB 的贡献。
关于c++ - Eclipse CDT (4.5.1) 打印效果很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37806352/
我有一个 view我拖了一个UITableView在里面,还有 2 UIImageView s(第一个显示背景图像,第二个只是在 View 顶部显示一个非常小的标题和图像)。 它们都设置为 weak特
我尝试用 C# 编写简单的 PostgreSQL 查询。第一个 connection.open() 需要 20 秒。其他连接立即执行。 PGAdmin 工作也很慢。如果我打开“查看所有行”,它也需要大
我制作了一个 html5 视频播放器,我注意到如果当前播放的视频有点大,搜索时间会异常地长。 越接近终点,寻找的时间越长;独立于我之前是否去过那里/与当前时间点的距离有多近,或者我是否缓冲了整个视频。
我正在使用 MaterialDatePicker,但速度很慢。 public class MainActivity extends AppCompatActivity { MaterialDa
我想知道为什么 MyBatis 是 慢 在我的应用程序中。 对于 SELECT COUNT(*) ,所用时间为: 20 秒 - 第一个请求 2-3 秒 - 后续请求 缓存很可能使后续请求更快。 配置
我已经安装了一个默认的开箱即用的 FreeSwitch 实例,但是当我尝试进行内部调用(分机到分机)时,大约需要 12 秒才能建立调用并且我可以听到铃声。 当我查看日志时,我几乎立即看到了连接请求,但
我已经放弃了让它跑得更快的实际尝试。 我最大的问题是,当我插入 html 时,应用程序会变慢到爬行。我有一个进度条,我正在调用 QCoreApplication.processEvents() (顺便
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
Doxygen 在我们的代码库上运行大约需要 12 个小时。这主要是因为有很多代码要处理(约 1.5M 行)。然而,它很快就会接近我们无法进行夜间文档更新的地步,因为它们需要太长时间。我们已经不得不减
我正在重写我的旧渲染管道。我根据自己的喜好创建了一个非常精简的原型(prototype),令我震惊的是,我原来相当复杂且优化不佳的管道与 super 简单的原型(prototype)具有完全相同的性能
我想为我的网站使用 Gridster,但我需要使用“add_widget”命令添加很多小部件。我做了一个测试,我认为“add_widget”功能存在问题:网格越来越慢并且存在内存泄漏。 您可以在此视频
我有一份包含图表和表格的报告。 我正在使用 html2canvas与 jsPDF将此报告导出为 PDF 文件。 但是这个过程耗时很长,超过11000ms。 我尝试更改格式和质量,但没有任何效果。 请看
我正在查询大于时间戳的类的所有修订,使用: AuditReaderFactory .get(emf.createEntityManager()) .createQuery().forR
我最近想加速一个加密系统。而在这个系统中,它将使用mysql,因此它包括文件。 而且我发现系统运行缓慢并不是因为加解密,而是因为处理一些sql语句。 它将在运行时使用内存数据库,并使用 中的 mys
谁能看出为什么这需要大约 20 秒?我正在运行下面的代码以将 JSON 请求发布到本地服务器 192.168.1.127。 curl -H "Content-type: application/jso
我有两个表:Posts 和Tags,其中存储了用户发布的文章以及他们为文章附加的标签。 PostTags 表用于表示文章 ID 和标签 ID 的关系。结构如下: 帖子: id | title | au
一个我应该能够自己回答但我没有,而且在谷歌中也找不到任何答案的问题: 我有一个表,其中包含具有以下结构的 500 万行: CREATE TABLE IF NOT EXISTS `files_histo
以下查询在具有大约 50 万行的表上执行需要 20 多秒: SELECT images.id, images.user_id, images_locale.filename, extension, s
我正在使用 $.getJSON 来提取对象 list (100 个项目,不是一个大集合),但 XHR 调用需要 8-10 秒。 想了解我是否缺少某些内容或我可以采取哪些措施来加快我的计划? 最佳答案
在这段代码中,我从网站获取一个字符串并将其显示在标签上。在标签上显示字符串真的很慢!大约 10 秒。但是在控制台 println (date) 上打印字符串时是立即的。我该如何解决这个问题?
我是一名优秀的程序员,十分优秀!