Profiling with jit.p and perf
Profile Lua code with jit.p, annotate hot paths, and reduce allocations.
Why Profile?
Profiling identifies which functions consume the most CPU time. Without profiling, optimization efforts are often misdirected to code that is not the bottleneck.
jit.p: LuaJIT Built-in Profiler
LuaJIT includes jit.p, a sampling profiler. Enable it from the command line or inside the script.
-- Command line:
luajit -jp=s script.lua
-- Or inside script:
require("jit.p").start("s") -- sample at function level
-- ... code ...
require("jit.p").stop()All lessons in this course
- LuaJIT Architecture Overview
- Writing JIT-Friendly Lua
- Profiling with jit.p and perf
- Benchmarking Patterns