Created
August 4, 2020 13:15
-
-
Save azborgonovo/3ca45dec202f04f0294ece8d816944fe to your computer and use it in GitHub Desktop.
Performance logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var before0 = GC.CollectionCount(0); | |
var before1 = GC.CollectionCount(1); | |
var before2 = GC.CollectionCount(2); | |
var sw = Stopwatch.StartNew(); | |
// Do... | |
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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment