Last active
November 27, 2016 20:40
-
-
Save ayende/b556bed2fefb1c9ff3394256cc5dcf41 to your computer and use it in GitHub Desktop.
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
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