Skip to content

Instantly share code, notes, and snippets.

@jkotas
Created June 12, 2026 02:59
Show Gist options
  • Select an option

  • Save jkotas/dca7f72bcac821af48f387dfebbc63ba to your computer and use it in GitHub Desktop.

Select an option

Save jkotas/dca7f72bcac821af48f387dfebbc63ba to your computer and use it in GitHub Desktop.
GC perf
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