The samples given by OProfile in the flat report, are they the samples for the function itself, or they are the samples for the function itself plus samples for the functions it calls? I tried to look at the docs, tutorials but could not find a concrete answer. My feeling is that it is samples for self, more precisely, the number of samples when the CPU is executing instructions for the body of the function but not in the function it calls.
Asked
Active
Viewed 239 times
1 Answers
0
It's hard to tell from the doc, but if you have turned on stack sampling, it seems to say that every return address on the stack is treated as if it is a program-counter sample. If it does that, then the time would be inclusive, provided it handles recursion properly.
To handle recursion properly, if a function appears more than once on a sample, it should only be counted once.
Also, I can't tell from the doc if the samples are suspended during I/O or sleeps, which they should not be, unless you want to be blind to those.

Mike Dunlavey
- 40,059
- 14
- 91
- 135
-
what is "stack sampling", do you mean --callgraph ? – szli Jan 08 '14 at 20:38
-
@szli: In Oprofile, [*stack sampling is an option*](http://oprofile.sourceforge.net/doc/internals/logging-stack.html). You get it by saying [*--callgraph*](http://oprofile.sourceforge.net/doc/opreport.html). I like stack sampling. I do not like call graphs. But that's off-topic. – Mike Dunlavey Jan 08 '14 at 21:17
-
I tried, with or without --callgraph, the sample numbers are very close in the "flat" report. I doubt if that makes any difference. – szli Jan 08 '14 at 22:53
-
@szli: OK, forget my answer. You're either going to have to go over the doc with a fine comb, or get an answer from somebody who really knows Oprofile. (I think [*Zoom*](http://www.rotateright.com/) is a good profiler, as profilers go. The technique I use is [*this*](http://stackoverflow.com/a/378024/23771). The general problem with profilers is *if you're trying to find "bottlenecks"*, they give you false negatives. That is, there may be some there, but since the profiler doesn't find them, you're inclined to think there are none.) – Mike Dunlavey Jan 09 '14 at 00:19