Skip to content

Instantly share code, notes, and snippets.

@EngineerSmith
Last active March 24, 2022 18:41
Show Gist options
  • Save EngineerSmith/a8cfe75f8ab89b1a4484ff2d9afcdc72 to your computer and use it in GitHub Desktop.
Save EngineerSmith/a8cfe75f8ab89b1a4484ff2d9afcdc72 to your computer and use it in GitHub Desktop.
local appleCake = require("lib.AppleCake")(true)
local jprof = appleCake.jprof
appleCake.beginSession() -- or jprof.START(), if you want to only use the jprof table
function love.run()
love.load(love.arg.parseGameArguments(arg), arg)
love.timer.step()
local dt = 0
return function()
jprof.push("frame")
if love.event then
jprof.push("event")
love.event.pump()
for name, a,b,c,d,e,f in love.event.poll() do
if name == "quit" then
if not love.quit or not love.quit() then
appleCake.endSession() -- you can use jprof.write if you desire, but it doesn't work the same; see docs
return a or 0
end
end
love.handlers[name](a,b,c,d,e,f)
end
jprof.pop("event") -- supports both named pops and unnamed pops
end
if love.timer then dt = love.timer.step() end
if love.update then
jprof.push("update")
love.update(dt)
jprof.pop()
end
if love.graphics then
love.graphics.origin()
love.graphics.clear(love.graphics.getBackgroundColor())
jprof.push("draw")
love.draw()
jprof.pop()
love.graphics.present()
end
jprof.pop()
love.timer.sleep(0.001)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment