DelegateProfiler ClassDelta Engine Documentation
Allows delegates to be run millions of times to compare different implementations. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Profiling DelegateProfiler

Namespace: DeltaEngine.Profiling
Assembly: DeltaEngine.Profiling (in DeltaEngine.Profiling.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class DelegateProfiler

The DelegateProfiler type exposes the following members.

Constructors

  NameDescription
Public methodDelegateProfiler
Initializes a new instance of the DelegateProfiler class
Top
Properties

  NameDescription
Public propertyAverageDurationInNanoseconds
Public propertyAverageDurationInPicoseconds
Public propertyTotalDurationInMilliseconds
Top
Remarks

Tests: DeltaEngine.Profiling.Tests.DelegateProfilerTests
Examples

5 unit tests call DeltaEngine.Profiling.DelegateProfiler
[Test, Category("Slow")]
public void CheckTotalDurationOfDoingSomethingSlowAThousandTimes()
{
    var profiler = new DelegateProfiler(() => Thread.Sleep(1));
    int totalDuration = profiler.TotalDurationInMilliseconds;
    Assert.IsTrue(totalDuration > 950);
    Console.WriteLine(totalDuration + " milliseconds for 1,000 iterations");
}
[Test, Category("Slow")]
public void CheckIndividualDurationOfDoingSomethingSlowAThousandTimes()
{
    var profiler = new DelegateProfiler(() => Thread.Sleep(1));
    int duration = profiler.AverageDurationInNanoseconds;
    Assert.IsTrue(duration > 950);
    Console.WriteLine(duration + " nanoseconds each");
}
[Test, Category("Slow")]
public void CheckTotalDurationOfDoingSomethingFastAMillionTimes()
{
    var profiler = new DelegateProfiler(DoSomeMaths, 1000000);
    int duration = profiler.TotalDurationInMilliseconds;
    Assert.IsTrue(duration > 5);
    Console.WriteLine(duration + " milliseconds for 1,000,000 iterations");
}
See Also