valgrind - 在理解 kcachedgrind 输出方面需要帮助

标签 valgrind kcachegrind

我正在使用 valgrind callgrind 来分析 gtk 上的程序。然后我使用 kcachedgrind 读取结果。我在这里捕获了 kcachedgrind 的更新截图:http://i41.tinypic.com/168spk0.jpg .它说函数 gtk_moz_embed_new() 花费了“15.61%”。 但我不明白这怎么可能。函数 gtk_moz_embed_new() 从字面上看有 1 行:它只是调用 g_object_new()。

GtkWidget *
gtk_moz_embed_new(void)
{
  return GTK_WIDGET(g_object_new(GTK_TYPE_MOZ_EMBED, NULL));
}

能否请您帮助理解结果或如何使用 kcachedgrind。

谢谢。

最佳答案

如果我没记错的话,这应该意味着(或多或少)该函数 gtk_moz_embed_new() 在应用程序运行的时间中执行了 15.61%。

您会看到,该函数返回对也需要时间执行的其他函数(或类或其他)的内联调用。当它们都完成后,函数 gtk_moz_embed_new() 就会真正返回一个值。与 main() 99% 的时间执行相同的原因,它会在执行完所有包含的代码后完成执行。

请注意,gtk_moz_embed_new()self 值为 0,这是“独占成本”,这意味着它自己的函数实际上并没有真正花费任何时间来执行(真的只是回电)

But to be exact:

1.1 What is the difference between 'Incl.' and 'Self'?

These are cost attributes for functions regarding some event type. As functions can call each other, it makes sense to distinguish the cost of the function itself ('Self Cost') and the cost including all called functions ('Inclusive Cost'). 'Self' is sometimes also referred to as 'Exclusive' costs.

So e.g. for main(), you will always have a inclusive cost of almost 100%, whereas the self cost is neglectable when the real work is done in another function.

关于valgrind - 在理解 kcachedgrind 输出方面需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2798995/

相关文章:

php - wincachegrind 中的列名是什么?

c++ - 优化与未优化构建的 KCachegrind 输出

c - 将文件读取到双向链表时泄漏内存

c - 在 Windows 7 上获取 Valgrind

linux - 是否有工具可以检查两个 callgrind/valgrind 配置文件的差异?

ruby-on-rails - 如何使用 Rails 应用程序的 ruby​​-prof 输出 KCacheGrind 的调用树分析?

performance - KCachegrind:找不到命令

c - while 循环条件中大小为 1 的读取无效

C++ 或 Cython 内存泄漏?

c++ - Valgrind 提示内存泄漏,但我正在调用 new 和 delete