// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; namespace E { public class Program { private static Random rng = new Random(); public static void Test(int bits) { int n = 1 << bits; int[] a = new int[n]; for(int i = 0; i < n; i++) a[i] = rng.Next(); long t1 = DateTime.Now.Ticks; HashSet hs = new HashSet(a); int z = hs.Count; if(z == 0 || z > n) throw new Exception("Houston we have a problem"); long t2 = DateTime.Now.Ticks; Console.WriteLine("{0} : {1} / {2}", n, t2 - t1, (t2 - t1) * 1000/ n); } public static void Main(string[] args) { for(int i = 16; i < 26; i++) { Test(i); } } } }