Skip to content

Instantly share code, notes, and snippets.

View EngineerSmith's full-sized avatar
🔧
🦆

Engineer Smith EngineerSmith

🔧
🦆
View GitHub Profile
-- Point of entry, e.g. main.lua
local appleCake = require("lib.AppleCake")(true) -- turn on profiling for entire project (default)
local appleCake = require("lib.AppleCake")(false) -- turn off profiling for entire project
-- Other files and threads
local appleCake = require("lib.AppleCake")() -- get whatever appleCake has been loaded by the first call
local k = 0
function love.update(dt)
if k % 15 == 0 then -- Adds a mark every 15 frames
appleCake.countMemory()
end
k = k + 1
end
appleCake.countMemory("byte")
appleCake.countMemory("megabyte")
appleCake.mark("event")
local function state.begin()
appleCake.mark("State entered begin", "t")
end
local function isValid(foo)
appleCake.mark("Validating", nil, foo) -- nil will be replaced with "p"
end
appleCake.profile("FooBar"):stop() --Stops and records the profile instantly, a mark would be better use to mark timeless events
local function foo() -- foo@profile:stop.lua#3
local profile = appleCake.profileFunc()
--...
profile:stop() -- Stop's and pushes profile to be written to file
end
local profileBar -- recommended to reuse tables than creating new ones
local function bar()
local function bar() -- [email protected]#1
local _profileBar = appleCake.profileFunc({}) -- Initalizing args to an empty table as it's nil by default
--...
_profileBar.args.value = 12
--...
_profileBar:stop()
end
local _profile --Example of reusing profiles to save creating garbage, recommended
local function foo() -- [email protected]#10
local _profile = appleCake.profile("love.update")
local function bar()
local _profileBar = appleCake.profile("bar", {}) -- Initalizing args to an empty table as it's nil by default
--...
local _profileBarSet = appleCake.profile("bar set") -- Example of nested profiling
_profileBar.args.value = 12
_profileBarSet:stop() -- This could stop after _profileBar:stop() if you wanted
--...
_profileBar:stop()
appleCake.endSession()
function love.quit()
appleCake.endSession()
end
appleCake.beginSession() -- Default "profile.json" in the save direcotry
appleCake.beginSession("profile.json")
appleCake.beginSession("/profiles/profile.json")
appleCake.beginSession(nil, "Best Project")
appleCake.beginSession("profile.json", "Game4000")
if love.filesystem.isFused() then
local dir = love.filesystem.getSourceBaseDirectory()
love.filesystem.mount(dir, "gameSource")
local appleCake = require("AppleCake")() -- Will be disabled if the main thread set AppleCake to false
-- Note we don't set buffering so everything is pushed to the save thread as soon as it can be
local function foo() -- "[email protected]#3"
local profile = appleCake.profileFunc()
local n = 0
for i=0, 100000 do
n = n + i
end
profile:stop()
/*!
* Bootstrap v4.3.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/:root{--blue: #007bff;--indigo: #6610f2;--purple: #6f42c1;--pink: #e83e8c;--red: #dc3545;--orange: #fd7e14;--yellow: #ffc107;--green: #28a745;--teal: #20c997;--cyan: #17a2b8;--white: #fff;--gray: #adb4c0;--gray-dark: #747f94;--primary: #28b76b;--secondary: #5d6778;--success: #5cb377;--info: #5b99ea;--warning: #EEBF41;--danger: #d26d69;--light: #fff;--dark: #747f94;--breakpoint-xs: 0;--breakpoint-sm: 576px;--breakpoint-md: 768px;--breakpoint-lg: 992px;--breakpoint-xl: 1200px;--font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace}*,*::before,