Defold includes profiling tools integrated with the engine and build pipeline. They help find performance, memory, and resource-usage problems. Runtime profiling data can be consumed by several facilities:
The Profiler setting in the App Manifest controls whether profiler code is linked into a build. Debug Only is the default, None excludes it, and Always includes it in both debug and release builds. The profiler settings in game.project control runtime behavior but do not link excluded profiler code back into a build. In particular, Track CPU controls CPU usage sampling; it is separate from the App Manifest choice.
Builds that include profiler support feature a runtime visual profiler that displays live information overlaid on 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 desktop or mobile build that includes profiler support, interactive frame and resource profilers 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 LuaMem value is the amount of memory in kilobytes used by the Lua VM as reported by the Lua garbage collector. Memory is the amount of memory in kilobytes used by the engine.
The Max Sample Count setting limits the number of profiler samples recorded per thread per frame. If the profiler reports that the limit was exceeded, first check native-extension profiling code for an unmatched scope begin/end pair. Raise the cap only when a legitimate frame contains more scopes than the configured limit.
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.

HTML5 uses the Web Performance API instead of Remotery for its browser timeline. To record Defold scopes:
profiler.performance_timeline_enabled) in game.project.This browser timeline is separate from both the in-game visual profiler and the interactive Remotery web profiler.
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:
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”.
