private static void RunAllocationQuestion(string number)
{
Console.WriteLine("Running " + number);
Console.WriteLine();
var types = typeof(Program).Assembly.GetTypes().Where(x => x.Namespace != null && !x.Namespace.Contains("Performance") && x.Namespace.EndsWith(number) && !x.IsNested);
foreach (var type in types)
{
var runDelegate = (Action)type.GetMethod("Run").CreateDelegate(typeof(Action));
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
var gcCount = GC.CollectionCount(0);
for (var i = 0; i < 10 * 1000 * 1000; i++)
{
runDelegate();
}
gcCount = GC.CollectionCount(0) - gcCount;
Console.WriteLine($"{number}/{type.Name}: {gcCount,5:N0} gen 0 collection(s).");
}
}
}