Skip to content

Instantly share code, notes, and snippets.

@ayende
Last active November 27, 2016 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayende/b556bed2fefb1c9ff3394256cc5dcf41 to your computer and use it in GitHub Desktop.
Save ayende/b556bed2fefb1c9ff3394256cc5dcf41 to your computer and use it in GitHub Desktop.
private static void RunOld()
{
var currentMemory = AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize;
var pageTable = new PageTable_Old();
var rand = new Random(331);
var sp = Stopwatch.StartNew();
for (int i = 0; i < 1000; i++)
{
var txPages = new Dictionary<long, long>();
for (int j = 0; j < rand.Next(900, 1000); j++)
{
for (int k = 0; k < 100; k++)
{
var next = rand.Next(i, 100000);
long value;
pageTable.TryGetValue(next, i, out value);
if (k % 30 == 0)
txPages[next] = rand.Next(10000, 20000);
}
}
pageTable.SetItems(i + 1, txPages);
if (i % 15 == 0 && i > 5)
{
pageTable.RemoveBefore(i - 5);
}
}
Console.WriteLine(sp.ElapsedMilliseconds);
Console.WriteLine("{0:#,#}", AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize - currentMemory);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment