Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Verwenden von C++-Profilern

Um die Performance von Godot zu optimieren, müssen Sie zunächst wissen, was zu optimieren ist. Zu diesem Zweck sind Profiler nützliche Werkzeuge.

Bemerkung

There is a built-in GDScript profiler in the editor, but using a 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.

There are two main types of profilers: sampling profilers and tracing profilers.

Sampling profilers periodically interrupt the running program and take a "sample", which records which functions are running. Using this information, the profiler estimates which functions the program spent the most time in.

Tracing profilers work by recording application-specific events (such as the start and end of a single frame), producing a log called a "trace". The profiler can use the trace to produce a graph showing an accurate high-level timeline of what happened. However, any code that is not explicitly instrumented will not appear in a tracing profiler's timeline!

Godot supports both sampling profilers and tracing profilers, and already includes the logging code for common Godot events for use with a tracing profiler!

Different problems may be easier to debug with one kind of profiler over the other, but it's difficult to provide a set of rules for which to use. Give both a try, and see what you can learn from them!

Sampling profilers

We recommend the following sampling profilers:

Diese Profiler sind vielleicht nicht die leistungsstärksten oder flexibelsten Optionen, aber ihr Standalone-Betrieb und ihr begrenzter Funktionsumfang machen sie tendenziell einfacher in der Anwendung.

Godot einrichten

Um nützliche Profiling-Informationen zu erhalten, ist es absolut erforderlich, einen Godot-Build zu verwenden, der Debug-Symbole enthält. Offizielle Binärdateien enthalten keine Debug-Symbole, da diese die Downloadgröße erheblich erhöhen würden.

Um Profiling-Daten zu erhalten, die am besten mit der Produktionsumgebung übereinstimmen (aber mit Debug-Symbolen), sollten Sie Binärdateien mit den SCons-Optionen production=yes debug_symbols=yes kompilieren.

Es ist möglich, einen Profiler auf weniger optimierten Builds laufen zu lassen (z.B. target=template_debug ohne LTO), aber die Ergebnisse werden natürlich weniger repräsentativ für die realen Bedingungen sein.

Warnung

Entfernen Sie nicht Debug-Symbole in den Binärdateien mit dem Befehl strip nach dem Kompilieren der Binärdateien. Andernfalls erhalten Sie keine nützlichen Profiling-Informationen mehr, wenn Sie einen Profiler ausführen.

Benchmarking von Start-/Stoppzeiten

If you're looking into optimizing Godot's startup/shutdown performance, you can tell the profiler to use the --quit command line option on the Godot binary. This will exit Godot just after it's done starting. The --quit option works with --editor, --project-manager, and --path <path to project directory> (which runs a project directly).

Siehe auch

Siehe Kommandozeilen-Tutorial für weitere von Godot unterstützte Kommandozeilenargumente.

Tracing profilers

Godot currently supports three tracing profilers:

Bemerkung

Perfetto is the default tracing system for Android, so pre-built export templates with Perfetto built-in and enabled are provided from the GitHub Releases page.

In order to use either of them, you'll need to build the engine from source. If you've never done this before, please read these docs for the platform you want to profile on. You'll need to perform the same steps here, but with some additional arguments for scons.