-
Notifications
You must be signed in to change notification settings - Fork 21
Lua Profiling using Tracy
- Get the tracy profiler from https://github.com/wolfpld/tracy
- Markup your lua code (See Lua Markup)
- Run Tracy.exe
- Run the game
- Hit connect in the profiler
Notes: The tracy profiler can use a lot of Memory, so you might only want to connect the profiler once you know the script is running
For basic profiling you can simply add tracy.ZoneBegin()
at the start of your lua functions and tracy.ZoneEnd()
before every return
and at the end of the function or region you want to profile.
Those marked Zones should now show up in the Statistics
window under Instrumentation
.
By default Zones are named only by the script file name and line number, so for easier organization you may create named zones by using tracy.ZoneBeginN("NAME")
instead.
Tracy also has a message system, where you can attach messages to your marked zones. So if you want additional info you may use
tracy.Message("Your message here")
to print additional information that might help you understand what your code is actually doing in specific frames (this can of course be dynamic strings).
The point of profiling is of course to see how your code improves with changes. Tracy can help you by providing a comparison mode in which you can load a saved tracy file to compare against. However this only provides useful data if you captured the same thing both times. To load a trace to compare simply use the compare button and follow directions.
For much more (possibly too much) information and a lesson on profiling read the tracy manual Documentation (lua documentation is on page 41-42)
You missed some return paths or you have errors in your code causing your marked up region to exit early. Check the console for errors (first) and check that all return paths have a ZoneEnd before them.
Go to Options
and uncheck Draw ghost zones.
Check that the code you're profiling is actually runngning.