static int collectionCount = 0;
static Stopwatch watch = null;
static int testCount = 100000;
static void TestBegin()
{
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
collectionCount = GC.CollectionCount(0);
watch = new StopWatch();
watch.Start();
}
static void TestEnd()
{
wtach.Stop();
Console.WriteLine("Time Cost:" + watch.ElapsedMilliseconds.ToString());
Console.WriteLine("GC Count:" + (GC.CollectionCount(0) - collectionCount));
}
TestBegin();
// xxx
TestEnd();