示例#1
0
        public static long TestForeach(long listSize)
        {
            var list = EnumerableFactory.GenerateYield(listSize);

            long sum = 0;

            foreach (var item in list)
            {
                sum += item;
            }

            return(sum);
        }
示例#2
0
        public void Test()
        {
            var listSize = 10000;
            var times    = 10000;

            var languageYieldResults = Run(times, () => EnumerableFactory.GenerateYield(listSize).Last());
            var languageListResults  = Run(times, () => ListFactory.Generate(listSize).Last());

            var languageYieldAverage = GetAverage(languageYieldResults);
            var languageListAverage  = GetAverage(languageListResults);

            Debug.WriteLine(listSize);
            Debug.WriteLine(languageYieldAverage);
            Debug.WriteLine(languageListAverage);
        }