TimeMeasureProfiler Class
Definition
- Namespace
- Cuemon.Diagnostics
- Assemblies
- Cuemon.Diagnostics.dll
Represents a profiler that is optimized for time measuring operations.
public class TimeMeasureProfiler : Profiler
- Inheritance
-
objectTimeMeasureProfiler
- 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
| Name | Description |
|---|---|
| TimeMeasureProfiler() | Initializes a new instance of the TimeMeasureProfiler class. |
Properties
| Name | Description |
|---|---|
| Elapsed | Gets the total elapsed time measured by this profiler. |
| IsRunning | Gets a value indicating whether this time measuring profiler is still running. |
| Timer | Gets the actual timer of this profiler. |
Methods
| Name | Description |
|---|---|
| ToString() | Returns a string that represents this instance. |