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: 7
Joined: Sun Jun 10, 2018 8:06 am

512 FPS?

Post by uiblob » Thu Jul 19, 2018 5:30 am

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: 190
Joined: Mon Aug 29, 2016 8:51 am

Re: 512 FPS?

Post by KayleMaster » 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

User avatar
zorg
Party member
Posts: 2325
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: 512 FPS?

Post by zorg » Thu Jul 19, 2018 7:58 am

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: 1685
Joined: Mon Jun 17, 2013 12:00 pm

Re: 512 FPS?

Post by raidho36 » Thu Jul 19, 2018 7:58 am

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: 7
Joined: Sun Jun 10, 2018 8:06 am

Re: 512 FPS?

Post by uiblob » Thu Jul 19, 2018 8:19 am

Wow, thanks for the great information.

User avatar
MissDanish
Prole
Posts: 16
Joined: Wed Mar 07, 2018 11:21 pm
Location: Denmark

Re: 512 FPS?

Post by MissDanish » Thu Jul 19, 2018 1:56 pm

Can confirm that it doesn't cap at 1000 or a specific number, this level runs at 1000+ FPS in my game.
screenshot_1532008524.png
screenshot_1532008524.png (655.54 KiB) Viewed 434 times
Smol programmer :neko:

User avatar
zorg
Party member
Posts: 2325
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: 512 FPS?

Post by zorg » Thu Jul 19, 2018 2:52 pm

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: 1685
Joined: Mon Jun 17, 2013 12:00 pm

Re: 512 FPS?

Post by raidho36 » Fri Jul 20, 2018 4:36 am

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: No registered users and 7 guests