Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Say you sample every 10ms. This frame, and every frame for the sake of example, looks like this:

* f1() - 1ms

* f2() - 8ms

* f3() - 4ms

* wait_for_next_frame() - 3ms

After 10ms, you'll sample and see f3() is running. Now you seem to think, oh, I should optimize f3(). But f2() is clearly the main cost of the frame. You can totally increase the frequency, so now you sample every 0.1ms or something, and that's probably fine. But you probably want to just instrument your code and get more accurate results at that point.

My main point is that out of the box typical sampling profilers

A: Don't sample fast enough B: Don't display the data split up by frame.



That's why you take thousands of samples. Most of them will hit f2 if you do it right.

If your sampler's timer is running perfectly in sync with your framerate, that's a problem, but it's not a "not enough samples" problem. Fix it by taking samples every 10.05-10.07 milliseconds instead.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: