Merry Christmas! I should probably made something either Christmas themed or much better than this but i make the rules so this is what i have done. Anyway, I'm still tired after making The Navier-Stokes Equations are Really Simple. the red line is the fps blue is the average fps of the last 10 frames green is the target fps yellow is the standard deviation
I tried to do this a while ago and noticed that if every frame you wait 1/target_fps seconds it is off by a lot but you can correct it by adding a constant to it, but that number depends on the target fps so it's not really a constant. This was an idea I had where it waits 1/target_fps + k seconds every loop, and constantly adjusts k to get the actual fps as close to the target fps as possible. It works surprisingly well on average. I tried very hard to make the fps less bouncy but don't think it can get much better than it is. I don’t know why it bounces at such a constant rate, but it’s good enough. Use this for whatever you want, I have no idea why you would need this though. Making this really brought me back to my earlier years on scratch (last year) making "fps destroyers". hehe.