Skip to content

Instantly share code, notes, and snippets.

@hashar
Last active September 14, 2023 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hashar/0c3c95f12d862ce0df41b0bd66394dc3 to your computer and use it in GitHub Desktop.
Save hashar/0c3c95f12d862ce0df41b0bd66394dc3 to your computer and use it in GitHub Desktop.
Profiling Unrailed with mono

Install Mono with profiler and utilities from Debian

sudo apt install mono-profiler mono-utils

Head to the Steam application directory

cd path/to/Unrailed

Game is started by shell script linux/UnrailedGame the command can then be tweaked to add the host Mono and pass extra parameters to mono

MONO_CFG_DIR="$PWD/linux/lib" \
MONO_PATH="/usr/lib/mono/4.5:$PWD/linux/lib" \
LD_LIBRARY_PATH="$PWD/linux/so:$LD_LIBRARY_PATH" \
  mono \
    --config ./linux/config.mono.linux \
    --profile=log:report \
      UnrailedGame.exe

And you get a profiling report!

Pass --profile=log will saves the profiling data to output.mlpd which can be inspected with mprof-report. Based on https://www.mono-project.com/docs/debug+profile/profile/profiler/ that is the equivalent of

--profile=log:calls,alloc,output=output.mlpd,maxframes=8,calldepth=100

But looks like calls are not the default in the version on Debian Bullseye, so gotta be added explicitly:

MONO_CFG_DIR="$PWD/linux/lib" MONO_PATH="/usr/lib/mono/4.5:$PWD/linux/lib" \
LD_LIBRARY_PATH="$PWD/linux/so:$LD_LIBRARY_PATH" \
  mono --config ./linux/config.mono.linux \
    '--profile=log:calls,maxframes=8,calldepth=100' UnrailedGame.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment