Created
November 26, 2019 09:04
-
-
Save ayende/62095f4b7cad04e8d36b04c8a79e904e 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
using System; | |
using System.Collections.Generic; | |
namespace ConsoleApp28 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var keys = new List<ulong>(); | |
var values = new List<ulong>(); | |
var wyRng = new WyHash.WyRng(0); | |
for (int i = 0; i < 1_000_000; i++) | |
{ | |
keys.Add(wyRng.NextLong()); | |
values.Add(wyRng.NextLong()); | |
} | |
var before = GC.GetTotalMemory(true); | |
var dic = new Dictionary<ulong, ulong>(); | |
for (int i = 0; i < 1_000_000; i++) | |
{ | |
dic[keys[i]] = values[i]; | |
} | |
for (int i = 0; i < 5; i++) | |
{ | |
GC.Collect(2); | |
GC.WaitForPendingFinalizers(); | |
} | |
var after = GC.GetTotalMemory(true); | |
Console.WriteLine(after - before); | |
GC.KeepAlive(dic); | |
GC.KeepAlive(keys); | |
GC.KeepAlive(values); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment