512 FPS?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
uiblob
Prole
Posts: 8
Joined: Sun Jun 10, 2018 8:06 am

512 FPS?

Post by uiblob »

Hello there,

after I played around with my layout engine I managed to get a good boost from 149 fps to 512. But even after optimizing more I did not get more fps. Then I tested an empty project which did nothing but print the fps to screen (with disabled vsync). This empty screen got between 509 and 512 fps.

So now I am wondering: Is there a cap at 512 fps? I tested it on my most powerful machine so I cant tell if it possible to go higher. If so, why?
I am not even talking about gameplay aspects now, but for benchmarking my routines a cap would not be the best situation. Or is it just a coincidence?

Greetings
uiblob
KayleMaster
Party member
Posts: 234
Joined: Mon Aug 29, 2016 8:51 am

Re: 512 FPS?

Post by KayleMaster »

There is a sleep function called in love.run to cap the fps to 512. Try using your own love.run and remove the love.timer.sleep

https://love2d.org/wiki/love.run
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: 512 FPS?

Post by zorg »

KayleMaster wrote: Thu Jul 19, 2018 7:44 am There is a sleep function called in love.run to cap the fps to 512. Try using your own love.run and remove the love.timer.sleep

https://love2d.org/wiki/love.run
Technically, it caps it to 0.001 ms, or 1000 FPS, not 512 (in the best case scenario). At least, last time i checked, that was the value in the default love.run function.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: 512 FPS?

Post by raidho36 »

It doesn't cap at any specific number, but it yields CPU time to the OS for 1 millisecond. It is not guaranteed to resume operation in exactly that much time, but, excluding extreme cases, it will not resume operation in less than that time. Your OS probably returns control to the process in 1.9 milliseconds, hence 512 fps.

Beat me to it, again!
uiblob
Prole
Posts: 8
Joined: Sun Jun 10, 2018 8:06 am

Re: 512 FPS?

Post by uiblob »

Wow, thanks for the great information.
MissDanish
Citizen
Posts: 65
Joined: Wed Mar 07, 2018 11:21 pm

Re: 512 FPS?

Post by MissDanish »

--snip--
Last edited by MissDanish on Wed May 06, 2020 12:35 am, edited 1 time in total.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: 512 FPS?

Post by zorg »

I guess i'm just lucky my configuration happened to yield at exactly that amount of time then. :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: 512 FPS?

Post by raidho36 »

Default love.run function sleeps for 1 millisecond every frame. There is no need to sleep for 1 millisecond, you can sleep for 0 milliseconds and that will allow the OS scheduler to resume immediately, if no other threads need running, without wasting that 1 or more milliseconds. You can even forego the sleep call entirely, vertical synchronization will do the same job for you and to a much greater precision. Without the vsync however the program will run in a spinlock-like state with 100% CPU load at all times, in which case a small sleep actually prevents full CPU utilization.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests