public static ThroughputTestResult Capture(string label, long messages, Action action)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            //TODO : This obviously allocates. Change to values on the stack. -LC
            var initial = GcInfo.Current();
            var start   = Stopwatch.GetTimestamp();

            action();
            var elapsedTicks = Stopwatch.GetTimestamp() - start;
            var gcDelta      = GcInfo.Current().Delta(initial);

            return(new ThroughputTestResult
            {
                Label = label,
                Messages = messages,
                Elapsed = TimeSpan.FromTicks(elapsedTicks),
                GarbageCollections = gcDelta
            });
        }
 public GcInfo Delta(GcInfo previous)
 {
     return(new GcInfo(Gen0 - previous.Gen0, Gen1 - previous.Gen1, Gen2 - previous.Gen2, TotalBytesAllocated - previous.TotalBytesAllocated));
 }
Exemple #3
0
 public GcInfo Delta(GcInfo previous)
 {
     return new GcInfo(Gen0-previous.Gen0, Gen1-previous.Gen1, Gen2-previous.Gen2, TotalBytesAllocated - previous.TotalBytesAllocated);
 }