static void FindRand(ICollectionComparable <int> list) { Random rand = new Random(); for (uint i = 0; i < 1000; i++) { list.GetIndex(rand.Next()); } }
static void SetRand(ICollectionComparable <int> list) { Random rand = new Random(); for (uint i = 0; i < 333; i++) { list.AddBack(rand.Next()); list.AddFront(rand.Next()); list.Insert(rand.Next(), i + 1); } }
static string Test(ICollectionComparable <int> list) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); SetRand(list); stopwatch.Stop(); string res = " Setting time: " + stopwatch.Elapsed; stopwatch.Reset(); stopwatch.Start(); FindRand(list); stopwatch.Stop(); res += " Finding time: " + stopwatch.Elapsed + " " + list.ToString(); return(res); }