Configure Profiling Session
To configure a profiling session, you should:
Specify how dotTrace should run the application you wish to profile. You can do this with the help of run configurations. If you want to profile an already running application, this step is not required.
1. Creating a run configuration
A run configuration is the way to tell dotTrace how it should run the profiled application. For example, a run configuration of a standalone .NET application will include a path to the application executable, command-line arguments, and a path to the application working directory.
If you already have a run configuration for the profiled application, select this run configuration from the New Process Run under Choose what you want to profile. Otherwise, create the run configuration by following the instruction below.
To create a run configuration
Under Choose what you want to profile, New Process Run, click Add run configuration.
In the New Run Configuration wizard, choose the application type and provide application options:
Click Save. This will create and save the run configuration. Next time when you need to profile this application, select the created configuration from the New Process Run list.
2. Choosing profiling type
Choose a profiling type in Profiling Type under Choose how you want to profile it.
The profiling type defines the way of how dotTrace collects profiling data and as a result – the amount and the type of the collected data. The following table will help you choose the best suitable profiling type. For more details, refer to Basic Concepts.
Collects temporal data about thread states, application events, and other multi-threading data. Based on Event Tracing for Windows (ETW). Supports native profiling.
Recommended for most cases. Especially, for analyzing multithreaded apps. Use it, for example, to determine the cause of UI freezes, excessive garbage collections, uneven workload distribution, insufficient I/O, and so on.
Accurate time measurement, number of calls is not measured.
Recommended for most cases. Ideal when you look for performance issues in your app for the first time.
Accurate calls count measurement, time measurement may be inaccurate due to profiling overhead.
When sampling data is not enough. For example, for analyzing algorithm complexity (when info about number of calls is more valuable than call time values).
Each line of code is measured, call time values are inaccurate due to huge profiler overhead.
To lower the overhead, you can profile only particular methods using filters.
For advanced use cases only. For example, when you already know what function causes issues and want to analyze each line of it.
3. Configuring other profiling options
- Control profiling
Control the profiling session using the buttons in the profiling controller window. For example, to take a snapshot, you click Get Snapshot and Wait.
Control profiling directly from the code of the profiled application. For example, to take a snapshot in the exact point of your code, you call the
MeasureProfiler.SaveData()function. Learn more about using the API in Controlling Profiling Process Through API.
- Time measurement
(Sampling, Tracing, Line-by-line)
This option defines how dotTrace must calculate calls time. Typically, this is a choice between whether dotTrace should calculate time when a thread is not working or should not. For more details, refer to Time Measurement Methods.
Real time (performance counter)
Recommended. dotTrace calculates the overall real time passed between method entry and exit. This time does not depend on app threads states. Time is calculated using system performance counter.
Real time (CPU instruction)
dotTrace calculates the overall real time passed between method entry and exit. This time does not depend on app threads states. Time is calculated using the CPU register.
dotTrace calculates only the time when a certain thread is running. The time when the thread is waiting or sleeping is not included in calculation.
Thread cycle time
dotTrace calculates only the time when a certain thread is running. The time when the thread is waiting or sleeping is not included in calculation. Time is calculated using the CPU register.
- Enable inlining
Clear this option if you want dotTrace to turn off JIT-inlining and get call stacks that closely resemble the structure of application's source code.
- High accuracy
If selected, dotTrace will take into account time spent in profiler itself by taking more time samples.
- Enable native profiling
(Timeline, Unity/Mono on Windows)
If selected, dotTrace will collect native call stack data. The resulting snapshot will contain both managed and native call stacks. This profiling option may be helpful for finding performance issues in Unity games.
- Collect native allocations
If selected, dotTrace will collect information about all memory allocations the profiled application does in the native (unmanaged) heap. To be able to select this option, you must have Windows Performance Toolkit installed on your computer.
- Collect TPL events
If selected, profiling performance may be affected but dotTrace will collect Task Parallel Library (TPL) data. If cleared, there will be no
Tasknodes in Call Tree and
asynccall nodes will be shown without their await and continuations parts.
Clear this option in case your application does not use multitasking or you do not need this info.
- Collect debug output
If selected, dotTrace will collect information about all messages the profiled application sends to the debug output.
- Download symbol files
PDB files (or symbol files) let you see native functions in the call tree. This is relevant for native applications and managed applications that call native code. If you select Download symbol files, dotTrace will try downloading PDB files from remote servers right after you get a snapshot. Note that this may take a significant amount of time depending on file size.
By default, dotTrace looks for PDB files in the locations specified in the
_NT_SYMBOL_PATHenvironment variable. Alternatively, you can specify custom local or remote locations using Edit Symbol File Locations.
- Collect profiling data from start
If selected, dotTrace will start recording profiling data right after the launch. Otherwise, dotTrace will start collecting these data only after you click Start in the profiling controller window.
4. (Optional) Configuring process filters
If the profiled application creates a number of processes, use the Process filters setting to specify what processes you want to profile. You can either select a predefined filter or create a new one.
Note that process filters work differently depending on the application type specified in the selected run configuration.
dotTrace will profile only processes that match the specified filter. The filter is applied to the entire process tree of the profiled process (including child processes).
For example, you have a managed process that creates a number of child processes. You want to profile not only the main process but also child processes with
In this mode, starting the profiling session does not start the profiled process. Instead, dotTrace waits for and attaches to the first managed process started in the operating system. When certain Process filters are selected, dotTrace will attach to the first process that matches the filter.
For example, you created the include filter:
Process filters are not applied.
To select a process filter
Under Choose how you want to profile it, Advanced Options, open the Process filters list.
Select the required filter.
dotTrace provides two predefined filters:
Default: process filter is not applied.
Entire process tree: dotTrace will profile the entire process tree including child processes. In case a .NET Process run configuration is selected, dotTrace will attach to and profile the first managed process started in the system including all its child processes.
To create a process filter
Under Choose how you want to profile it, Advanced Options, open the Process filters list.
Choose Add Filter.
Specify filter settings:
Name: filter name.
Profile entire process tree: if selected, dotTrace will profile the entire process tree including child processes. Disabling this option makes sense only if you create a filter for the .NET Process run configuration. In this case, dotTrace will wait for and attach to the first process in the system that matches the filter but it will not profile child processes of this process.
Include filter masks, Exclude filter masks: include and exclude filter masks correspondingly. The masks are applied according to the following rules:
The default policy is 'profile all'.
Include masks are applied first. Exclude masks are applied to the processes filtered by the include masks.
You can use asterisk
For example, to profile all child processes with
Servicein their name excluding
MyService, add the
*Service*include mask and the
5. (Optional) Configuring filters for the line-by-line profiling
Line-by-line profiling may be effective in particular cases but it is always time-consuming. To somehow minimize the profiling overhead, you can define some rules. According to them, not all functions are profiled line by line but only those that are really interesting for further investigation.
So you can create and set a filter or filters that match only the functions/classes/assemblies you need.
To create a filter for the line-by-line profiling
Under Choose how you want to profile it, select the Line-by-Line profiling type.
Click Edit Filters.
Click Add filter in the Edit Filter dialog.
Choose a filter type:
Profile code in: include the specified code item into profiling and exclude all other code items.
Do not profile code in: exclude the specified code item from profiling.
Do not profile code marked with attribute: exclude code items with the specified attribute from profiling.
If you have chosen one of the first two options, specify an assembly, a class, and/or a method to be included or excluded from profiling. Code items are filtered independently on one another. For example, if you specify a method and leave asterisks
*for assembly and class to exclude methods with the specified name from all assemblies and all classes.
If you have chosen the last option, specify the name of the attribute that will be used to exclude symbols from profiling. Optionally, specify the assembly name where this attribute is declared.
You can use asterisk wildcards when specifying code item names in a filter:
*(asterisk) represents zero or more characters. For example, the
*.Testswildcard will exclude all test projects from code analysis.