Defold includes a set of profiling tools that are integrated with the engine and the build pipeline. These are designed to help find problems with performance and memory usage. The built-in profilers are available on debug builds only. The frame profiler that is used in Defold is the Remotery profiler by Celtoys.
Debug builds feature a runtime visual profiler that displays live information rendered overlayed on top of the running application:
function on_reload(self)
-- Toggle the visual profiler on hot reload.
profiler.enable_ui(true)
end
The visual profiler provides a number of different function that can be used to change the way the visual profiler presents its data:
profiler.set_ui_mode()
profiler.set_ui_view_mode()
profiler.view_recorded_frame()
Refer to a the profiler API reference for more information about the profiler functions.
While running a debug build of the game, an interactive web-based profiler can be accessed through a browser.
The Frame profiler allows you to sample your game while it is running and analyze individual frames in detail. To access the profiler:
The frame profiler is divided into several sections that all give different views into the running game. Press the Pause button in the top right corner to temporarily stop the profiler from updating the views.
When you use multiple targets simultaneously, you can manually switch between them by changing the Connection Address field at the top of the page to match the Remotery profiler URL shown in the console when the target started:
INFO:ENGINE: Defold Engine 1.3.4 (80b1b73)
INFO:DLIB: Initialized Remotery (ws://127.0.0.1:17815/rmt)
INFO:ENGINE: Loading data from: build/default
The Resource profiler allows you to inspect your game while it is running and analyze resource use in detail. To access the profiler:
The resource profiler is divided into 2 sections, one showing a hierarchical view of the collections, game objects and components currently instantiated in your game, and the other showing all currently loaded resources.
When bundling your game there is an option to create a build report. This is very useful to get a grip on the size of all the assets that are part of your game bundle. Simply check the Generate build report checkbox when bundling the game.
The builder will produce a file called “report.html” alongside the game bundle. Open the file in a web browser to inspect the report:
The Overview gives an over all visual breakdown of the project size based on resource type.
Resources shows a detailed list of resources that you can sort based on size, compression ratio, encryption, type and directory name. Use the “search” field to filter the resource entries displayed.
The Structure section shows sizes based on how resources are organized in the project file structure. Entries are color coded from green (light) to blue (heavy) according to the relative size of the file and directory content.
In addition to the built-in tools, there is a wide range of free high quality tracing and profiling tools available. Here is a selection:
https://github.com/jgrahamc/ProFi
Note that pure Lua profilers add quite a lot of overhead with each hook they install. For this reason you should be a bit wary of the timing profiles you get from such a tool. Counting profiles are accurate enough though.
This tool allows you to inspect a running Defold application and see how it uses OpenGL. It allows you to do traces of OpenGL function calls, set breakpoints on OpenGL functions, investigate application resources (textures, programs, shaders etc), look at buffer contents, and check other aspects of the OpenGL state.
A set of profiling tools that captures real-time data of your game’s CPU, memory, and network activity. You can perform sample-based method tracing of code execution, capture heap dumps, view memory allocations, and inspect the details of network-transmitted files. Using the tool requires that you set android:debuggable="true"
in “AndroidManifest.xml”.
Note: Since Android Studio 4.1 it is also possible to run the profiling tools without starting Android Studio.
This is a collection of tools that allows you to inspect, tweak and replay calls from an application to a graphics driver. To use the tool requires that you set android:debuggable="true"
in “AndroidManifest.xml”.
Did you spot an error or do you have a suggestion? Please let us know on GitHub!
GITHUB