Allows delegates to be run millions of times to compare different implementations.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Profiling DelegateProfiler
Namespace: DeltaEngine.Profiling
Assembly: DeltaEngine.Profiling (in DeltaEngine.Profiling.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The DelegateProfiler type exposes the following members.
Constructors
Name | Description | |
---|---|---|
![]() | DelegateProfiler | Initializes a new instance of the DelegateProfiler class |
Properties
Name | Description | |
---|---|---|
![]() | AverageDurationInNanoseconds | |
![]() | AverageDurationInPicoseconds | |
![]() | TotalDurationInMilliseconds |
Remarks
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"); }
See Also