Table of Contents

Class TimeMeasureProfiler<TResult>

Namespace
Cuemon.Diagnostics
Assembly
Cuemon.Diagnostics.dll

Represents a profiler that is optimized for time measuring operations that provides a return value. This class cannot be inherited.

public sealed class TimeMeasureProfiler<TResult> : TimeMeasureProfiler

Type Parameters

TResult

The type of the return value.

Inheritance
TimeMeasureProfiler<TResult>
Inherited Members

Examples

TimeMeasureProfiler<TResult> extends TimeMeasureProfiler by providing typed access to the result of a timed function via TimeMeasure.WithFunc. This example wraps a Thread.Sleep(100) followed by returning 42, then inspects the profiler's Result (42), Elapsed (~100ms), IsRunning (False), and Member properties. Key setup includes capturing the profiler and checking each property after execution. Console output shows the result value, the elapsed duration, the running state, the member name, and the ToString() output like <anonymous method> took 00:00:00.100 to execute..

using System;
using System.Threading;
using Cuemon.Diagnostics;

namespace MyApp.Examples;

public class TimeMeasureProfilerOfTExample
{
    public void Demonstrate()
    {
        // TimeMeasure.WithFunc returns a TimeMeasureProfiler<int>
        TimeMeasureProfiler<int> profiler = TimeMeasure.WithFunc(() =>
        {
            Thread.Sleep(100);
            return 42;
        });

        Console.WriteLine($"Result: {profiler.Result}");       // 42
        Console.WriteLine($"Elapsed: {profiler.Elapsed}");     // ~00:00:00.100
        Console.WriteLine($"IsRunning: {profiler.IsRunning}");  // False
        Console.WriteLine($"Member: {profiler.Member}");        // <anonymous method>
        Console.WriteLine(profiler.ToString());
        // Output: <anonymous method> took 00:00:00.100 to execute.

}
}

Properties

Result

Gets or sets the result of a time measuring operation that returned a value.

public TResult Result { get; set; }

Property Value

TResult

The result of a time measuring operation that returned a value.

See Also