static void Main(string[] args) { Console.WriteLine("================ Starting work ================"); CalculateMovieRatings.Version4(); Console.WriteLine("================ Finished! ================"); }
private static void GetDiagnosticsVersion4() { Console.WriteLine("================ VERSION 4 ================"); var before0 = GC.CollectionCount(0); var before1 = GC.CollectionCount(1); var before2 = GC.CollectionCount(2); var calculateMovie = new CalculateMovieRatings(); var sw = new Stopwatch(); sw.Start(); calculateMovie.Version4(); sw.Stop(); Console.WriteLine($"\nTime .: {sw.ElapsedMilliseconds} ms"); Console.WriteLine($"# Gen0: {GC.CollectionCount(0) - before0}"); Console.WriteLine($"# Gen1: {GC.CollectionCount(1) - before1}"); Console.WriteLine($"# Gen2: {GC.CollectionCount(2) - before2}"); Console.WriteLine($"Memory: {(Process.GetCurrentProcess().WorkingSet64 / 1024) / 1024} MB"); }