Created
June 12, 2026 02:59
-
-
Save jkotas/dca7f72bcac821af48f387dfebbc63ba to your computer and use it in GitHub Desktop.
GC perf
This file contains hidden or 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
| using System.Diagnostics; | |
| Stopwatch sw = new Stopwatch(); | |
| int count = 0; | |
| double total = 0; | |
| for (; ; ) | |
| { | |
| sw.Restart(); | |
| Populate(19); | |
| double step = sw.ElapsedMilliseconds; | |
| total += step; | |
| count++; | |
| Console.WriteLine($"{step} ms, Average: {total / count} ms"); | |
| } | |
| Node Populate(int depth) | |
| { | |
| var n = new Node(); | |
| if (depth <= 0) | |
| return n; | |
| n._left = Populate(depth - 1); | |
| Populate(depth - 2); | |
| n._right = Populate(depth - 2); | |
| Populate(depth - 1); | |
| n._payload = new byte[Random.Shared.Next(50)]; | |
| return n; | |
| } | |
| class Node | |
| { | |
| public Node _left, _right; | |
| public byte[] _payload; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment