Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start of program");
            Stopwatch s = new Stopwatch();
            Random    r = new Random();

            decimal[] data = new decimal[100000000];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = r.Next();
            }

            Console.WriteLine("Data ready!");

            ForeachTest(s, data);
            ForArrayTest(s, data);

            ForeachTest(s, data);
            ForArrayTest(s, data);

            Console.WriteLine("Array test done!");
            Console.WriteLine();

            IEnumerable <decimal> enumrableData = data.AsEnumerable();

            ForeachTest(s, enumrableData);
            ForArrayTest(s, enumrableData);

            ForeachTest(s, enumrableData);
            ForArrayTest(s, enumrableData);
            Console.WriteLine("IEnumerable test done!");
            Console.WriteLine();
            enumrableData = null;


            List <decimal> listData = data.ToList();

            ForeachTest(s, listData);
            ForArrayTest(s, listData);
            ForeachTest(s, listData);
            ForArrayTest(s, listData);
            Console.WriteLine("List test done!");
            Console.WriteLine();
            listData.Clear();

            ICollection <decimal> collectionData = data;

            ForeachTest(s, collectionData);
            ForArrayTest(s, collectionData);
            ForeachTest(s, collectionData);
            ForArrayTest(s, collectionData);
            Console.WriteLine("ICollection test done!");
            Console.WriteLine();
            listData.Clear();

            Console.WriteLine("Program finished");
            Console.ReadLine();
        }