DelegateProfilerTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Profiling.Tests DelegateProfilerTests

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

public class DelegateProfilerTests

The DelegateProfilerTests type exposes the following members.

Constructors

  NameDescription
Public methodDelegateProfilerTests
Initializes a new instance of the DelegateProfilerTests class
Top
Methods

  NameDescription
Public methodCheckIndividualDurationOfDoingSomethingFastAMillionTimes
Public methodCheckIndividualDurationOfDoingSomethingSlowAThousandTimes
Public methodCheckTotalDurationOfDoingSomethingFastAMillionTimes
Public methodCheckTotalDurationOfDoingSomethingSlowAThousandTimes
Public methodDurationOfSingularFastActionIsNoticed
Top
Examples

[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");
}
[Test, Category("Slow")]
public void CheckIndividualDurationOfDoingSomethingFastAMillionTimes()
{
    var profiler = new DelegateProfiler(DoSomeMaths, 1000000);
    int duration = profiler.AverageDurationInPicoseconds;
    Assert.IsTrue(duration > 5);
    Console.WriteLine(duration + " picoseconds each");
}
[Test, Timeout(5000)]
public void DurationOfSingularFastActionIsNoticed()
{
    var profiler = new DelegateProfiler(DoSomeMaths, 1);
    int duration = profiler.AverageDurationInPicoseconds;
    Assert.IsTrue(duration > 0);
}
See Also