import{_ as i,a,b as n,ag as l}from"./chunks/framework.BcrMLAmg.js";const g=JSON.parse('{"title":"Benchmarking in Basalt","description":"","frontmatter":{},"headers":[],"relativePath":"guides/benchmarks.md","filePath":"guides/benchmarks.md","lastUpdated":1740469724000}'),h={name:"guides/benchmarks.md"};function t(e,s,k,p,r,E){return n(),a("div",null,s[0]||(s[0]=[l(`
Basalt provides built-in benchmarking tools to help you analyze and optimize your application's performance.
local main = basalt.getMainFrame()
-- Start benchmarking a container
main:benchmarkContainer("render") -- Start tracking render performance
-- Log benchmark results
main:logContainerBenchmarks("render") -- Print results to console-- Track specific container methods
container:benchmarkContainer(methodName) -- Start tracking
container:logContainerBenchmarks(methodName) -- Show results
-- Common methods to benchmark:
- "render" -- Track render performance
- "mouse_click" -- Track click handling
- "mouse_up" -- Track release handling
- "mouse_drag" -- Track drag performancelocal basalt = require("basalt")
local main = basalt.getMainFrame()
-- Create a benchmark trigger button
main:addButton()
:setText("Show Benchmarks")
:setPosition(2, 2)
:onClick(function()
main:logContainerBenchmarks("render")
end)
-- Create some test elements
local program = main:addProgram()
:execute("shell.lua")
local complexFrame = main:addFrame()
:setPosition(30, 1)
:addButton()
:addLabel()
:addList()
-- Start benchmarking
main:benchmarkContainer("render")
basalt.run()The benchmark results show:
Targeted Benchmarking
When to Benchmark
Common Areas to Watch