我正在使用 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,这是“独占成本”,这意味着它自己的函数实际上并没有真正花费任何时间来执行(真的只是回电)
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/