OpenTTD Development • Re: OpenTTD Squirrel Debugger & Profiler for AI / GameScript
Transport Tycoon Forums - Index page [Unofficial]
March 22, 2026
It's me again! Did you know that with sqdbg you can profile your GameScript or AI?
Check out the functions available in the API, copied from the sqdbg repository:
Code:
sqdbg_prof_start Enable profiler and start collecting datasqdbg_prof_stop Disable profiler and remove all collected datasqdbg_prof_pause Pause profilersqdbg_prof_resume Resume paused profiler. Should be placed in the same call frame as pausesqdbg_prof_gets Get a profile report of the current or specified thread, or the specified block as a string. Parameter optionally takes a thread, and requires group name or report type (0: call graph, 1: flat). E.g.: sqdbg_prof_gets(1) or sqdbg_prof_gets(thread, 1). Measured peak times are ignored in total and average times in block reports.
Profiling with Debug Console
- Start a debugging session.
- Open Debug Console in VS Code (Ctrl+Shift+Y on Windows).
- In the text input field, type sqdbg_prof_start() and press Enter.
- Then type sqdbg_prof_gets(1) and press Enter.
- You should get something like:
Profiling with VS Code Addon
You can do the same with the VS Code addon: Download sqdbg-profiler-vs 0.1.0.vsix Source code: https://github.com/PaSaSaP/sqdbg-profiler-vs
- Start a debugging session so the addon can read data from it.
- Select the command: Open Squirrel Profiler from the command palette.
- Click Start.
- Click Update.
- You should get something like:
Enjoy!
Statistics: Posted by MustBe — 22 Mar 2026 09:22
Discussion in the ATmosphere