CodeTrack: Profiling a .NET Core app

Back to How To

This can be used to profile an application built for .NET Core (console apps and/or webservices).

This guide is written to trace while launching your core CLR code from the dotnet.exe. If there would be cases where your core CLR code gets loaded into other hosts, you can also specify core CLR as a .NET FW type in the other profiling types (eg. if you would load it inside a windows service).

Bear in mind that if your process needs to be elevated you need to run the profiler elevated as well (you can do this by clicking on the elevation icon icon the title bar, or run the profiler as admin).

  1. Select the collect tab (on the left of the application)
  2. Select ‘CORE CLR’ and click the arrow on the right to go to the next step.

  3. Now you can select the dotnet executable that will launch your code. Codetrack will remember this value, so you don't need to specify it again.
    The bittness will be selected automatically. Should this be incorrect, you can still change this manually.
    Then specify the dll containing your Core CLR code.
    You can also override the working directory. (For webservices, you might need to select the location of your project folder in order to properly launch your service.)

    Alternatively you can select the 'Manual' mode to specify your own startup command.
    This allows you to run dotnet.exe with custom arguments (like test for instance).
    In this case you need to select the bitness yourself. Make sure you add double quotes around paths that contain spaces!
    Now click the arrow on the right to go to the next step.

  4. Now it's time to decide upon your level of detail. Important to remember, is that the more detail you require, the higher the impact profiling will have on your performance. If you just started investigating a problem, it might be a good idea to use the sampling option. Since this will be the most performant profiling mode. From this information you can then start another session with much more detail, profiling only the code that causes the performance issue.
    For more information about the different profiling settings, read Profiling Modes.

    Now we are ready for the last step, click on the right arrow to continue.

  5. In this last section you need to select the destination of the profiling data. (Make sure you select a location with enough space if you profile with lots of detail).
    If you want to als profile a child process (started by our own process), enable this before starting to profile.
    If you need to profile on a very slow machine,one with little RAM, or a production server, you can disable the processing of the data. This allows you to do the number crunching offline on another machine.

    If you want to start profiling immediately, make sure you click the record button, otherwise click the pause button and hit record from the moment you want to start capturing data.
    Now you are ready to start profiling. If you click the play button, your process wil start.
    If you press the stop button Codetrack will try to gracefully end your process and profiling will stop as soon as the process is stopped. You can also just end the process from your own application.