3 ms·
> That doesn't really work for games, where your work is on the scale of 0.1ms, and you might call the same function 100's of times in 16ms. Calling update_obje
by Dylan16807 6y ago
> That doesn't really work for games, where your work is on the scale of 0.1ms, and you might call the same function 100's of times in 16ms. Calling update_object() 1000 times an interval isn't actually a problem, when it's only taking 5% of your overall frame budget (on average). Games also have the constraint of not wanting your profiling to throw off the game speed itself, it needs to run very fast.
I'm confused, because the thing sampling measures is how much of your frame budget goes to each function. And sampling works equally well regardless of how fast your functions are.
But I do agree that looking for variance and focusing on frames that take too long are important.
- jms55 6y agoSay 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.
- Dylan16807 6y agoThat'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.