public void Run()
{
_test = (ILatencyTest)Activator.CreateInstance(_perfTestType);
CheckProcessorsRequirements(_test);
Console.WriteLine("Starting latency tests");
var stopwatch = new Stopwatch();
var histogram = new LongHistogram(10000000000L, 4);
for (var i = 0; i < Runs; i++)
{
stopwatch.Reset();
histogram.Reset();
GC.Collect();
GC.WaitForPendingFinalizers();
var beforeGen0Count = GC.CollectionCount(0);
var beforeGen1Count = GC.CollectionCount(1);
var beforeGen2Count = GC.CollectionCount(2);
Exception exception = null;
LatencyTestSessionResult result = null;
try
{
_test.Run(stopwatch, histogram);
}
catch (Exception ex)
{
exception = ex;
}
if (exception != null)
{
result = new LatencyTestSessionResult(exception);
}
else
{
var gen0Count = GC.CollectionCount(0) - beforeGen0Count;
var gen1Count = GC.CollectionCount(1) - beforeGen1Count;
var gen2Count = GC.CollectionCount(2) - beforeGen2Count;
result = new LatencyTestSessionResult(histogram, stopwatch.Elapsed, gen0Count, gen1Count, gen2Count);
}
Console.WriteLine(result);
_results.Add(result);
}
}