Profiling the Game

From Space Engineers Wiki
Jump to navigation Jump to search

Introduction

Keen was nice enough to give us access to their devtools and their profiler, and with some downloading and file moving, you too can use this version of the game. This will allow you to measure the performance of your script to make sure it is running as fast as it possibly can.

Getting started

You’ll need to set up a few things before you can start using the profiling version.

First things first, is you’ll need to download the ModSDK for the game. Open your Steam library, hovering your pointer over the “Library” button to get the menu. Select “Tools”, and find “Space Engineers - Mod SDK” from the list, and install it.

If it’s not there you can force install it by pasting steam://install/326880 in your browser address bar.

Once the ModSDK has finished downloading an installing, you need to open the directory where it’s installed (You can get to this quickly by right-clicking the tool in your library, selecting Properties, Local Files, Browse Local Files...).

Next, you need to have Bin64_Profile in the game folder. You can simply copy it there but that also means you have to copy it every time game/SDK gets updated.

NOTE: Do not paste into the game’s Bin64 folder. Only copy the Bin64_Profile as is in the game’s root folder.

Or, instead of copying, a better way is to make a directory junction:

  1. If you already copied Bin64_Profile to your game, delete it.
  2. Open notepad or something you can type in.
  3. Paste: mklink /J "<SEDir>\Bin64_Profile" "<SDKDir>\Bin64_Profile".
  4. Replace <SEDir> with the path to the game.
  5. Replace <SDKDir> with the path to the SDK.
  6. Press Win + R and run cmd.
  7. Copy the finished command from notepad to the commandline window (rightclick to paste) then Enter.

Finally, you can run the game via <SE>/Bin64_Profile/SpaceEngineers.exe.

The short version

Here’s how to install the profiling version of the game without all the extra fluff.

  1. Install the Space Engineers - Mod SDK (as described above)
  2. Copy <SDK>/Bin64_Profile to the game’s folder or create a directory junction (as described above).
  3. Start the game from <SE>/Bin64_Profile/SpaceEngineers.exe

In the game

Once in the game, the bottom right corner where the version is should also say PROFILING with red text, that means you’re good to go.

When in a world (or even in the menu) press Alt + NumPad . to open the profiler view.

From here, you can use the various keybinds listed below to dig deeper into what’s doing what in your game, see how long it’s taking, and other fun profiling things.

For profiling programmable blocks specifically, copy:

UpdateInternal::Update > Session.Update > After simulation > MySector > MyGameLogic.UpdateAfterSimulation > PROGRAMMABLE_BLOCK

then press Alt + Shift + NumPad *.

There are all kinds of debugging tools available in the profiler version of the game, accessible via F12 (or Alt + F12 to avoid taking a Steam screenshot) where you can mess with a lot of things, some of which can alter your game files so use with caution.

But this page is only here to detail how to use the profiler specifically.

Profiler Keybinds

The profiler has a lot of keybinds that aren’t immediately obvious. They’re listed here, grouped for convenience.


Key Combination Functionality
Profiler management
Alt + NumPad . Opens/closes the Profiler, doesn't reset the current profiler stack.
Alt + NumPad Enter Pause/unpause the profiler.
Alt + Ctrl + Insert Reset profiler data
Alt + NumPad / Decreases the level limit
Alt + NumPad * Increases the level limit
Alt + Ctrl + NumPad / Decreases the level limit by 1
Alt + Ctrl + NumPad * Increases the level limit by 1
Alt + E Toggle deep/shallow profile
Alt + Shift + E Toggle deep/shallow profile on connected DS
Alt + A Switch recording average times
Alt + Shift + A Switch recording average times on server
Alt + 1-9 Load profiler snapshot from file in `UserData/FullProfiler-X`
Alt + LCtrl + 1-9 Save profiler snapshot to file in `UserData/FullProfiler-X`
Alt + RCtrl + 1-9 Load snapshot from file and subtract it from current profiler data (diff)
Alt + Shift + LCtrl + 1-9 Save profiler snapshot on server
Alt + S Download current profiler data from server
Profiler navigation
Alt + NumPad 0 Go back 1 block (Will open the profiler if it's closed, this is done for backwards compatibility with programmer muscle memory)
Alt + NumPad 1-NumPad 9 Enter the next profiler block as usual
Alt + Ctrl + NumPad 1-NumPad 9 Select block 10-19
Alt + Ctrl + Space + NumPad 1-NumPad 9 Select block 20-29
Alt + Ctrl + Home Jump to root block
Alt + NumPad + Next thread
Alt + NumPad - Previous Thread
Alt + Shift + NumPad / Copy current profiler path to clipboard
Alt + Shift + NumPad * Try to navigate to the profiler path from the clipboard
Profiler blocks optimization
Alt + NumPad 0 Toggles all child block optimization state
Alt + B + NumPad 1-NumPad 9 Toggles block optimization state 1-9
Alt + Ctrl + B + NumPad 1-NumPad 9 Toggles block optimization state 10-19
Alt + Ctrl + Shift + B + NumPad 1-NumPad 9 Toggles block optimization state 20-29
Alt + B + NumPad Enter Toggles optimizations enabled/disabled
Alt + B + NumPad . Resets optimization on all blocks
Profiler display settings
Alt + Home Increase profiler scale
Alt + End Decrease profiler scale
Alt + Insert Change profiler sorting order
Alt + Ctrl + NumPad + Increase local area (Used for calculating the average milliseconds)
Alt + Ctrl + NumPad - Decrease local area (Used for calculating the average milliseconds)
Alt + Q Switch to alternative graph (Used for memory allocation profiling)
Profiler frame selection
Alt + PageUp Go forward through frames
Alt + PageDown Go backwards through frames
Alt + Ctrl + PageUp Go forward through frames by 1 frame
Alt + Ctrl + PageDown Go backwards through frames by 1 frame
Alt + Shift + PageUp Fast forward through frames
Alt + Shift + PageDown Fast backwards through frames
Alt + Ctrl + End Disable selection mode

Generally interesting paths

  • UpdateInternal::Update > Session.Update > Before simulation > MySector > MyEntities.UpdateBeforeSimulation
  • UpdateInternal::Update > Session.Update > After simulation > MySector > MyEntities.UpdateAfterSimulation

You can make use of these paths by copying the text from here, opening the profiler ingame and pressing Alt + Shift + NumPad *.



A big thank you goes to AndrielChaoti who was kind enough to compose this document, and MMaster for providing the original used as a source. This tutorial was adapted from the original on Malware's MDK wiki, by Malware.