Skip to content

.NET performance profiling

marksvc edited this page Jun 28, 2023 · 3 revisions

In Linux

Install tools:

sudo apt-get update && sudo apt-get --assume-yes install \
  lttng-tools \
  lttng-modules-dkms \
  liblttng-ust-dev \
  linux-tools-$(uname -r) \
  linux-tools-generic
dotnet tool install --global dotnet-trace

Run program to profile, with environment variable set:

cd src/SIL.XForge.Scripture
DOTNET_PerfMapEnabled=1 dotnet run

perf

Profile with perf. When viewing the report, press h for help. e to expand and collapse.

sudo perf record --pid=$(pgrep SIL.XForge) -g --timestamp-filename # Then press Ctrl+C when done. Optionally also use --output perf.data-my-report-filename
sudo perf report --input=$(ls -tr1 perf.data* | tail -1)

dotnet-trace

Profile with dotnet-trace. This can be done with a format of chromium or speedscope. The Chromium formatted file can be dragged into the Performance area of the Chromium dev tools. This is processed and displays information, but may not be very easy to use. The speedscope file can be dragged into the app at https://www.speedscope.app/ , but may not contain much information.

dotnet-trace collect --process-id $(pgrep SIL.XForge) --format chromium

Further reading

Clone this wiki locally