6

I'm using Very Sleepy to profile some C++ code, and I notice that in the Source view, where it shows the red line-by-lime time-spent measurements, there are always measurement on the lines that only have the method's open or close curly brace, in some cases these were pretty high compared to the other lines of code in the function.

My initial assumption it's showing the time spent pushing the method parameters into the stack for the opening curly brace, and the time spent popping the stack for the closing curly brace. Is this true?

Omer Raviv
  • 11,409
  • 5
  • 43
  • 82
  • Do the routines contain local variables that are allocated and destroyed, such as strings? This can cause significant hidden newing and destructing, with those curly braces being the lines on the stack while it is happening. – Mike Dunlavey Sep 13 '11 at 23:15
  • @MikeDunlavey I see this in method that only have primitive local variables, too. – Omer Raviv Sep 19 '11 at 20:01
  • Well, I'm among the people who use [this method](http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024), and there's never any doubt. It tells you, down to the instruction, exactly what's taking time. (I've got the source code of VerySleepy, but from just looking at it, it's hard to tell what it's actually doing.) – Mike Dunlavey Sep 19 '11 at 21:27

1 Answers1

4

I got an answer to this from Richard Mitton (@grumpydev), the maintainer of Very Sleepy, on twitter: "Most likely the function has been optimized, so the line number isn't matched up exactly to the code any more. i.e. all the time gets lumped at the start, instead of being spread out over the course of the function."

Omer Raviv
  • 11,409
  • 5
  • 43
  • 82