views:

52

answers:

1

Hi,

I am using valgrind callgrind to profile a program on gtk. And then I use kcachedgrind to read the result. I have captured an update a screenshot of kcachedgrind here: http://i41.tinypic.com/168spk0.jpg. It said the function gtk_moz_embed_new() costed '15.61%'. But I dont understand how is that possible. the function gtk_moz_embed_new() literally has 1 line: and it is just calling a g_object_new().

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

Can you please help understanding the result or how to use kcachedgrind.

Thank you.

+1  A: 

If i remember correctly that should mean (more or less) that function gtk_moz_embed_new() was executing 15.61% of the time the the app was running.

You see, that function returns an inline call to other functions (or classes or whatever) that also take time to execute. When they are all done it's then that the function gtk_moz_embed_new() acutally returns a value. The very same reason it takes main() 99% of the time to execute, it finisesh execution after all included code in it is executed.

Note that self value for the gtk_moz_embed_new() is 0 which is "exclusive cost" meaning that function it self did not really took any time to execute (it's really only a return call)

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.

rebus
Thanks. I have added http://i44.tinypic.com/iz4936.png. I have clicked the 'gtk_moz_embed_new' which is 15.61 in 'incl' cost. But in the 'callee' tab. the function g_object_new''s Ir is 15.60. Why 'g_object_new is taking so much cost?
hap497
Well i am not very familiar with GTK so i can't provide an answer to that, my best guess would that it takes some time to create a new object. :) Basically cachegrind will help you find bottlenecks not fix them (at least as far as i know)
rebus