Skip to content

Instantly share code, notes, and snippets.

@EngineerSmith
Last active April 12, 2025 17:17
Show Gist options
  • Save EngineerSmith/4a65e074d108dde0f0241fe4e672f63c to your computer and use it in GitHub Desktop.
Save EngineerSmith/4a65e074d108dde0f0241fe4e672f63c to your computer and use it in GitHub Desktop.
local appleCake = require("AppleCake")(true) -- False will disable AppleCake for your project
appleCake.setBuffer(true) -- Buffer data, and only send it to be saved when appleCake.flush is called
appleCake.beginSession()
appleCake.mark("Begin") -- Add markers for timeless events
local r = 0
function love.update(dt)
local profileUpdate = appleCake.profileFunc({radian=r}) -- Auto-generates a name for the function, "[email protected]#7", and records the arguments
r = r + 0.5 * dt
profileUpdate:stop()
end
local lg = love.graphics
local profileDraw -- Reuse tables to avoid garbage
function love.draw()
profileDraw = appleCake.profile("Draw", nil, profileDraw) -- Reusing tables works for .profileFunc(args, tbl) too
lg.push()
lg.rotate(r)
lg.rectangle("fill", 0,0,30,30)
lg.pop()
profileDraw.args = lg.getStats() -- You can view the value of args in the tool
profileDraw:stop()
appleCake.flush() -- Flush profiling data to saving thread
end
function love.quit()
appleCake.endSession() -- In the event of a crash or endSession isn't reached, it is still possible to recover the profiling data
-- EndSession calls appleCake.flush to catch any unflushed data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment