Class TimeMeasureProfiler
- Namespace
- Cuemon.Diagnostics
- Assembly
- Cuemon.Diagnostics.dll
Represents a profiler that is optimized for time measuring operations.
public class TimeMeasureProfiler : Profiler
- Inheritance
-
TimeMeasureProfiler
- Derived
- Inherited Members
Examples
TimeMeasureProfiler captures performance timing metrics for synchronous operations via the TimeMeasure API. This example calls TimeMeasure.WithAction(() => Thread.Sleep(25)) to profile a 25ms sleep and TimeMeasure.WithFunc(() => 42) to profile a function returning a result. Key steps include checking the profiler's Elapsed time and IsRunning state, and accessing the Result of the function profiler. Console output confirms Elapsed > TimeSpan.Zero for both profilers, IsRunning is False after completion, and the function result is 42.
using System;
using System.Threading;
using Cuemon.Diagnostics;
namespace MyApp.Examples;
public static class TimeMeasureProfilerExample
{
public static void Demonstrate()
{
TimeMeasureProfiler profiler = TimeMeasure.WithAction(() => Thread.Sleep(25));
var measured = TimeMeasure.WithFunc(() => 42);
Console.WriteLine(profiler.Elapsed > TimeSpan.Zero);
Console.WriteLine(profiler.IsRunning);
Console.WriteLine(measured.Result);
Console.WriteLine(measured.Elapsed > TimeSpan.Zero);
}
}
Constructors
TimeMeasureProfiler()
Initializes a new instance of the TimeMeasureProfiler class.
public TimeMeasureProfiler()
Properties
Elapsed
Gets the total elapsed time measured by this profiler.
public TimeSpan Elapsed { get; }
Property Value
IsRunning
Gets a value indicating whether this time measuring profiler is still running.
public bool IsRunning { get; }
Property Value
- bool
trueif this time measuring profiler is still running; otherwise,false.
Timer
Gets the actual timer of this profiler.
public Stopwatch Timer { get; }
Property Value
- Stopwatch
The actual timer of this profiler.
Methods
ToString()
Returns a string that represents this instance.
public override string ToString()