views:

302

answers:

3

I'm new to Shark, and I was wondering if it's possible to narrow down a time sample to one specific method?

Let's say I'd like to, just for the sake of it, know how much resources have been used on calls to the method 'count' for all NSArray (or subclasses) instances.

+2  A: 

If you view the time profile graph bottom-up, and charge any time -count spends in libraries to its callers, that should give you what you want. It lets you see how much time is spent because of -count (i.e. both in executing that method, and anything the method needs to get its job done) and also lets you find out where you're calling the method. It's possible that the reason you spend so much time in -count is not because it takes long, but because you're doing it too often.

Graham Lee
Hi Graham, I'm lost, could you be more specific? Are you referring to a time profile chart? And what do you mean by charging?
Steph Thirion
Graham, could you be more specific about how to do it on the interface?
Steph Thirion
+1  A: 

The time spend at least on the function level is exactly what Instruments is giving you. With DTrace you can even dig deeper than that. Maybe checkout my blog post about this. That should hopefully clear things up.

You could easily write a DTrace script to print out the memory consumption of the count call for example.

cheers, Torsten

tcurdt
+1  A: 

You can hit cmd-f to search for a symbol. Make sure the "auto expand" checkbox is on so it goes down into the tree. You may need to turn on Window -> Show Advanced Settings.

Once you find the symbol, right click on it and you have some options:

  • Focus Symbol: this will let you filter down to just the calls to the symbol you selected and below

  • Retain Callstacks with: this will let you see all the calls to the symbol and filter out everything else

When you are done you can right click and "unfocus all" or "restore all". These commands end up modifying the "callstack data mining" section in the advanced settings. Fool around with that.

David Koski