Difference between revisions of "profile"
(Updated profiler URL) |
(→profile.lua) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== profile.lua == | == profile.lua == | ||
− | profile.lua is a | + | profile.lua is a small module used for finding bottlenecks in your Lua code. To use the profiler, you need to require the profile.lua file and specify when to start or stop collecting data. Once you are done profiling, a report is generated, describing: |
− | == Documentation and | + | * which functions were called most frequently and |
+ | * how much time was spent executing each function | ||
+ | |||
+ | == Example == | ||
+ | <source lang="lua"> | ||
+ | -- setup | ||
+ | function love.load() | ||
+ | love.profiler = require('profile') | ||
+ | love.profiler.start() | ||
+ | end | ||
+ | |||
+ | -- generates a report every 100 frames | ||
+ | love.frame = 0 | ||
+ | function love.update(dt) | ||
+ | love.frame = love.frame + 1 | ||
+ | if love.frame%100 == 0 then | ||
+ | love.report = love.profiler.report(20) | ||
+ | love.profiler.reset() | ||
+ | end | ||
+ | end | ||
+ | |||
+ | -- prints the report | ||
+ | function love.draw() | ||
+ | love.graphics.print(love.report or "Please wait...") | ||
+ | end | ||
+ | </source> | ||
+ | |||
+ | == Documentation and source code == | ||
https://github.com/2dengine/profile.lua | https://github.com/2dengine/profile.lua | ||
+ | |||
+ | https://2dengine.com/doc/profile.html | ||
{{#set:LOVE Version=Any}} | {{#set:LOVE Version=Any}} | ||
{{#set:Description=A real-time profiler for finding bottlenecks in your game}} | {{#set:Description=A real-time profiler for finding bottlenecks in your game}} | ||
− | {{#set:Keyword= | + | {{#set:Keyword=Debug}} |
[[Category:Libraries]] | [[Category:Libraries]] | ||
== Other Languages == | == Other Languages == | ||
{{i18n|profile}} | {{i18n|profile}} |
Latest revision as of 09:10, 9 October 2024
profile.lua
profile.lua is a small module used for finding bottlenecks in your Lua code. To use the profiler, you need to require the profile.lua file and specify when to start or stop collecting data. Once you are done profiling, a report is generated, describing:
- which functions were called most frequently and
- how much time was spent executing each function
Example
-- setup
function love.load()
love.profiler = require('profile')
love.profiler.start()
end
-- generates a report every 100 frames
love.frame = 0
function love.update(dt)
love.frame = love.frame + 1
if love.frame%100 == 0 then
love.report = love.profiler.report(20)
love.profiler.reset()
end
end
-- prints the report
function love.draw()
love.graphics.print(love.report or "Please wait...")
end
Documentation and source code
https://github.com/2dengine/profile.lua
https://2dengine.com/doc/profile.html
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info