Engine Library
debug
Summary
Functions
profilebegin(label: string):() |
profileend():() |
setmemorycategory(tag: string):string |
resetmemorycategory():() |
dumpcodesize():() |
API Reference
Functions
traceback
traceback
info
info
info
profilebegin
profileend
debug.profileend():()
Returns
()
Code Samples
Debug Profile End
debug.profilebegin("Outer")
debug.profilebegin("Inner")
-- Work done here is timed under both labels
debug.profileend() -- closes "Inner"
debug.profileend() -- closes "Outer"getmemorycategory
Returns
Code Samples
Debug Get Memory Category
local category = debug.getmemorycategory()
print(type(category)) --> string
-- The category follows the thread, so a new one can differ from this one
local previous = debug.setmemorycategory("Pathfinding")
print(debug.getmemorycategory()) --> Pathfinding
debug.setmemorycategory(previous)setmemorycategory
Parameters
Returns
Code Samples
Debug Set Memory Category
local original = debug.setmemorycategory("MapGeneration")
print(debug.getmemorycategory()) --> MapGeneration
-- Allocations made here are listed under "MapGeneration" in the Developer Console
local tiles = table.create(1000, 0)
-- The return value is the previous category, so it can be restored
print(debug.setmemorycategory(original) == "MapGeneration") --> trueresetmemorycategory
debug.resetmemorycategory():()
Returns
()
Code Samples
Debug Reset Memory Category
local automatic = debug.getmemorycategory()
debug.setmemorycategory("Spawning")
print(debug.getmemorycategory()) --> Spawning
debug.resetmemorycategory()
print(debug.getmemorycategory() == automatic) --> truedumpcodesize
debug.dumpcodesize():()
Returns
()
Code Samples
Debug Dump Code Size
-- debug.dumpcodesize() only works from the Studio Command Bar, where it prints a
-- report to the Output with one table per native script, largest functions first:
-- # Native Code Size Analysis
-- <n> scripts, <n> functions, <n> KB memory, 256 MB code size limit
-- ## <script name>
-- <n> functions, <n> KB memory
-- | Function | Line | Native Code Size | Native Code Size (%) |
-- Only scripts that start with --!native and have run appear in the report.
-- From a Script it raises an error, which pcall catches
local ok, message = pcall(debug.dumpcodesize)
print(ok) --> false
print(message) --> dumpcodesize can only be called from CommandBar