|
1 | 1 | # Application Profiler Tool |
2 | 2 |
|
3 | | -Experimental tool. |
4 | | -Documentation is pending. |
| 3 | +While [metrics](./metrics.md) primarily contain a single dimension of information, suitable for displaying as a chart, profilers capture richer data. After a recording is completed, `Developer Tools` aggregates the results and displays them as a table. |
| 4 | + |
| 5 | +## Recording a Profile |
| 6 | + |
| 7 | +1. Click the **Record** button to start a profiling session. |
| 8 | +2. The application continues running normally while data is collected in the background. |
| 9 | +3. Click **Record** again to stop. |
| 10 | +4. Results are aggregated and displayed across separate tabs, one for each profiler type. |
| 11 | + |
| 12 | +For best results, try to isolate the interaction you want to measure. For example, open a specific view or trigger a UI action while recording, so the data isn't diluted by unrelated activity. |
| 13 | + |
| 14 | +## Style Matching |
| 15 | + |
| 16 | +When a control is created or added to the visual tree, Avalonia evaluates all active style selectors to determine which ones apply. The Style Matching profiler aggregates match attempts. |
| 17 | + |
| 18 | +Columns: |
| 19 | +- **Selector** — the style selector being evaluated (e.g., `TextBlock.h1`, `Button:pointerover > ContentPresenter`) |
| 20 | +- **Elapsed** — total time spent evaluating this selector across all match attempts |
| 21 | +- **Fast Reject Count** — how many times the selector was quickly ruled out without full evaluation. A fast reject occurs when a control can be excluded by a simple static check, such as a mismatched type or control name. Importantly, a fast-rejected control will not be re-evaluated later when activators change — for example, a `TextBox` will never be re-evaluated for `Button:pointerover`, because it was already rejected on type |
| 22 | +- **Match Attempts** — total number of times this selector was tested against a control |
| 23 | +- **Matches** — how many attempts resulted in a successful match |
| 24 | + |
| 25 | +A high number of match attempts with very few matches can indicate an overly broad selector. Consider targeting a concrete control type rather than a base class to reduce unnecessary matching during control creation. |
| 26 | + |
| 27 | +## Style Activators |
| 28 | + |
| 29 | +Unlike Style Matching (which measures initial selector resolution), this profiler measures how often selectors are re-evaluated at runtime. This happens when conditional selectors — those with activators like `:pointerover`, `:focus`, `:pressed` — toggle on and off as the user interacts with the application. |
| 30 | + |
| 31 | +Columns: |
| 32 | +- **Selector** — the style selector being re-evaluated |
| 33 | +- **Elapsed** — total time spent on re-evaluations |
| 34 | +- **Evaluations** — total number of times the selector's activator was re-evaluated |
| 35 | +- **Active Evaluations** — how many evaluations resulted in the style becoming active |
| 36 | +- **Activator** — type of activator responsible (e.g., pseudo-class, property match) |
| 37 | + |
| 38 | +If a selector shows a very high number of evaluations, it may be toggling more often than expected. Narrowing the scope of such selectors can help. |
| 39 | + |
| 40 | +## Resource Lookup |
| 41 | + |
| 42 | +Every time a control, style, or binding resolves a resource by key (e.g., a brush, thickness, or template), Avalonia walks the resource hierarchy until it finds a match. This profiler aggregates those lookups by key. |
| 43 | + |
| 44 | +Columns: |
| 45 | +- **Key** — the resource key being looked up |
| 46 | +- **Elapsed** — total time spent resolving this key across all lookups |
| 47 | +- **Total Lookups** — how many times this key was requested |
| 48 | +- **Successful** — how many lookups found a matching resource |
| 49 | +- **Theme Variant** — the theme variant (Light/Dark) active during the lookup |
| 50 | + |
| 51 | +A key with many total lookups but few successful ones likely indicates a missing or misspelled resource definition. You can use the [Resources Tool](./resources.md) to inspect available resources at each scope. |
0 commit comments