Esempio n. 1
0
 public static double DoBenchmarkValueTuple(uint size)
 {
     return(CTBenchmark.RunBenchmark(() => {
         double cnt = 0;
         cnt += GenerateHashSetValueTuple(size).Sum(x => x.Item2);
         Console.Write("{0}", cnt);
     }));
 }
Esempio n. 2
0
 public static double DoBenchmarkMinMaxLinq(uint size)
 {
     return(CTBenchmark.RunBenchmark(() => {
         var array = GenerateArray(size);
         var max = array.Max();
         var min = array.Min();
         Console.Write("{0} {1}", min, max);
     }));
 }
Esempio n. 3
0
        public static double DoBenchmarkStringHashSetLinq(uint size)
        {
            var oldArray = GenerateCollection <HashSet <string> >(size);
            var newArray = GenerateCollection <HashSet <string> >(size / 2);

            return(CTBenchmark.RunBenchmark(() => {
                Console.Write("{0}", oldArray.Except(newArray).Last());
            }));
        }
Esempio n. 4
0
        public static double DoBenchmarkMinMaxManual(uint size)
        {
            return(CTBenchmark.RunBenchmark(() => {
                IEnumerable <int> array = GenerateArray(size);
                var iterator = array.GetEnumerator();
                if (!iterator.MoveNext())
                {
                    throw new ArgumentNullException();
                }

                int min = iterator.Current;
                int max = iterator.Current;
                while (iterator.MoveNext())
                {
                    max = Math.Max(max, iterator.Current);
                    min = Math.Min(min, iterator.Current);
                }
                Console.Write("{0} {1}", min, max);
            }));
        }