Skip to main content

ProfilingSession

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​

MemberWhat it is
ProfilingSession(string name, params string[] groups)Creates a ProfilingSession from name and groups.

Fields​

9 private and internal fields
MemberWhat it is
private readonly List<ProfilingSession> childrenSessions started while this one was current.
private static ProfilingSession currentThe innermost running session.
private const string FailureStatus text "FAILURE".
private readonly Dictionary<string, List<ProfilingSession>> groupAssociationsChild sessions per group, filled for a report.
private readonly Dictionary<string, double> groupMsTotal ms per group, filled for a report.
private string statusCached status text.
private readonly Stopwatch stopwatchTimes the session.
private const string SuccessStatus text "SUCCESS".
private bool wasSuccessFalse once the session is cancelled.

Properties​

MemberWhat 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
MemberWhat 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​

MemberWhat 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
MemberWhat 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: