A class in Alta.Profiling.Runtime, Alta.Profiling.
A timed, nestable profiling scope. Making one starts it and makes it the current session; sessions made inside become its children. Dispose it to stop.
Constructors
| Member | What it is |
|---|
ProfilingSession(string name, params string[] groups) | Creates a ProfilingSession from name and groups. |
Fields
9 private and internal fields
| Member | What it is |
|---|
private readonly List<ProfilingSession> children | Sessions started while this one was current. |
private static ProfilingSession current | The innermost running session. |
private const string Failure | Status text "FAILURE". |
private readonly Dictionary<string, List<ProfilingSession>> groupAssociations | Child sessions per group, filled for a report. |
private readonly Dictionary<string, double> groupMs | Total ms per group, filled for a report. |
private string status | Cached status text. |
private readonly Stopwatch stopwatch | Times the session. |
private const string Success | Status text "SUCCESS". |
private bool wasSuccess | False once the session is cancelled. |
Properties
| Member | What it is |
|---|
TimeSpan Elapsed { get; } | Time the session has run. |
string Name { get; } | The session's name; also used as the profile marker name. |
4 private and internal properties
| Member | What it is |
|---|
private string[] Groups { get; } | Group names this session counts towards in the report. |
private bool IsEnded { get; set; } | Whether the session has stopped. |
private ProfilingSession Parent { get; } | The session that was current when this one started. |
private string Status { get; } | "SUCCESS" or "FAILURE". |
Methods
| Member | What it is |
|---|
void Cancel() | Marks this session and its children as failed and stops them. |
void Dispose() | Stops the session. |
string GenerateReport(float summaryPercentThreshold = 0.2) | Builds a text tree of the session and its children, leaving out successful ones under the threshold (a percentage of total time, default 0.2%). |
4 private and internal methods
| Member | What it is |
|---|
private void PopulateReport(StringBuilder stringBuilder, double msLimit, int indentCount) | Writes this session's line, its notable groups and its children into the report. |
private void PrepareGroupsForReport() | Totals the time of children (and their children) per group before a report. |
private void ProcessRecursively(ProfilingSession child) | Adds one child's time to this session's group totals, including groups found deeper down. |
private void Stop() | Ends the profile marker, stops the timer and makes the parent current again. |
Used in
Members of other types that take, return or hold a ProfilingSession: