Re: performance too LOW!
Posted: Wed Apr 01, 2015 5:18 pm
Perhaps it's better to put it this way: if you need that kind of performance, then Löve is probably not the right tool to use.
Code: Select all
function love.draw()
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10)
end
Code: Select all
function love.update()
FPS = love.timer.getFPS( )
end
function love.draw()
love.graphics.print("Current FPS: "..tostring(FPS), 10, 10)
end
Compressed textures are formats like DXT5. That tool just creates a PNG, which still has to be decompressed when it's loaded (it's not a Compressed Texture.)jjmafiae wrote:compressed textures can seriously improve performance (especially load times and VRAM usage) you can use this tool to do it: http://pnggauntlet.com/
Both of your snippets of code do essentially the same thing, performance-wise. love.timer.getFPS doesn't even do any calculations on its own, it just returns a variable, so it's one of the cheapest love functions to call.jjmafiae wrote:when checking FPS don't do as the wiki says
setColor is also very cheap (although not quite as cheap as getFPS or getWidth / getHeight.) Calling it before a draw call won't have a significant performance impact, compared to not calling it.jjmafiae wrote:avoid using "love.graphics.setColor" inside loops if possible because it seriously cripples FPS
from my own testing my games ran faster after moving the love.timer.getFPS check out of love.draw()slime wrote: Both of your snippets of code do essentially the same thing, performance-wise. love.timer.getFPS doesn't even do any calculations on its own, it just returns a variable, so it's one of the cheapest love functions to call.
Did you perhaps modify love.run? If not, take a look at the default one: https://love2d.org/wiki/love.run love.update runs just before love.draw, once per frame, so it shouldn't really change anything by just moving the getFPS call from one of them to the other.jjmafiae wrote:from my own testing my games ran faster after moving the love.timer.getFPS check out of love.draw()slime wrote: Both of your snippets of code do essentially the same thing, performance-wise. love.timer.getFPS doesn't even do any calculations on its own, it just returns a variable, so it's one of the cheapest love functions to call.
Why? The cost for calling getFPS couldn't be that high. Plus you're still calling it every frame anyway. That's what it's for. Getting the FPS every frame.jjmafiae wrote:6. when checking FPS don't do as the wiki says:
Wiki method:Correct method:Code: Select all
function love.draw() love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10) end
Code: Select all
function love.update() FPS = love.timer.getFPS( ) end function love.draw() love.graphics.print("Current FPS: "..tostring(FPS), 10, 10) end
Yes but the problem is before the call was in love.draw() which is not meant to do that kind of calls, anyway what matters is that it works and it does at least in my testing.Jasoco wrote:Why? The cost for calling getFPS couldn't be that high. Plus you're still calling it every frame anyway. That's what it's for. Getting the FPS every frame.jjmafiae wrote:6. when checking FPS don't do as the wiki says:
Wiki method:Correct method:Code: Select all
function love.draw() love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10) end
Code: Select all
function love.update() FPS = love.timer.getFPS( ) end function love.draw() love.graphics.print("Current FPS: "..tostring(FPS), 10, 10) end
Just because love.draw isn't meant for game logic, that doesn't mean you can't do calculations in it. Your little second step there even adds more of a hurdle because it's setting and retrieving global variable every frame, since you're so hellbent on being a stickler for the smallest increases in performance. In fact, this is probably the fastest possible way to do it:jjmafiae wrote: Yes but the problem is before the call was in love.draw() which is not meant to do that kind of calls, anyway what matters is that it works and it does at least in my testing.
Code: Select all
local getFPS = love.timer.getFPS
function love.draw()
love.graphics.print(getFPS(), 10, 10)
end