Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
使用 C++ 性能分析器¶
要优化 Godot 的性能,你首先得知道要优化什么,性能分析器在这方面非常有用。
备注
There is a built-in GDScript profiler in the editor, but using C++ profiler may be useful in cases where the GDScript profiler is not accurate enough or is missing information due to bugs in the profiler.
性能分析器推荐¶
VerySleepy (仅适用于 Windows)
HotSpot (仅适用于 Linux)
Xcode Instruments (仅适用于 macOS)
这些性能分析器可能不是最强大或者最灵活的,但它们独立的操作和有限的功能非常易用。
设置 Godot¶
如果要获取有用的性能分析信息,就必须使用包含调试符号的 Godot 构建。官方二进制文件并不包含调试符号,因为会显著增加文件下载大小。
如果想要获取与生产环境最接近的性能分析数据,你应该使用如下 SCons 选项来编译程序。
It is possible to run a profiler on less optimized builds (e.g. target=template_debug
without LTO),
but results will naturally be less representative of real world conditions.
警告
请勿在编译完成后使用 strip
命令剥离调试符号,否则运行性能分析器时无法得到有用的信息。
测量启动/关闭耗时¶
如果想要尝试优化 Godot 的启动/关闭性能,你可以让分析器使用 Godot 二进制文件的 --quit
命令行参数,它会让 Godot 在启动完成后立即退出。--quit
参数可以和 --editor
、--project-manager
、--path <项目目录路径>
(该参数可以直接运行项目)搭配使用。
参见
更多 Godot 支持的命令行参数见 命令行教程。
性能分析器指令¶
VerySleepy¶
Start the Godot editor or your project first. If you start the Project Manager, make sure to edit or run a project first. Otherwise, the profiler will not track the child process since the Project Manager will spawn a child process for every project edited or run.
打开 VerySleepy 然后在左侧的进程列表中选中 Godot 程序:

点击右侧的 Profile All 按钮开始性能分析。
在编辑器或者项目中执行你想分析性能的操作,完成后点击 Stop(注意不是 Abort)。
等待出现结果窗口。
结果窗口出现后,在视图中筛选掉外部模块(例如图形驱动)。筛选模块的