Skip to content

Instantly share code, notes, and snippets.

@EngineerSmith
Last active February 8, 2020 20:22
Show Gist options
  • Save EngineerSmith/46c6847e44701cc19e9edb2ffd616cc7 to your computer and use it in GitHub Desktop.
Save EngineerSmith/46c6847e44701cc19e9edb2ffd616cc7 to your computer and use it in GitHub Desktop.
local profileUpdate -- Recommended to reuse tables for commonly hit profiles to avoid recreating tables often
function love.update(dt) -- Will be profiled as "update#gettingstarted2.lua#2"
profileUpdate = appleCake.profileFunc(nil, profileUpdate)
--...
profileUpdate:stop()
end
local profileDraw
function love.draw() -- Will be profiled as "draw#gettingstarted2.lua#9"
profileDraw = appleCake.profileFunc(nil, profileDraw)
--...
profileDraw.args = love.graphic.getStats() -- So we can view the draw stats
profileDraw:stop()
end
function loadMap(map) -- Example of a single use profile, as loadMap will be rarely called it can be pointless reusing the table
local profile = appleCake.profile("Loading map: "..map.name, {["Tile Count"]=#map.tiles})
--...
profile.args["size X"] = loadedMap.size.X
profile:stop()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment