private static void DecimalEvaluation()
    {
        decimal number = 0;

        Console.Write("Square Root: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                Math.Sqrt((double)number);
            }
        });

        number = 0;

        Console.Write("Natural Logarithm: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                Math.Log((double)number);
            }
        });

        number = 0;

        Console.Write("Natural Logarithm: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                Math.Sin((double)number);
            }
        });
    }
    private static void FloatEvaluation()
    {
        float number = 0;

        Console.Write("Square Root: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                Math.Sqrt(number);
            }
        });

        number = 0;

        Console.Write("Natural Logarithm: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                Math.Log(number);
            }
        });

        number = 0;

        Console.Write("Natural Logarithm: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                Math.Sin(number);
            }
        });
    }
    private static void LongEvaluation()
    {
        long number = 0;

        Console.Write("Long Add: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number += 1;
            }
        });

        number = 0;

        Console.Write("Long Substract: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number -= 1;
            }
        });
        number = 0;

        Console.Write("Long Increment: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number++;
            }
        });
        number = 0;

        Console.Write("Long Miltiply: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number *= 1;
            }
        });
        number = 0;

        Console.Write("Long Divide: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number /= 1;
            }
        });
    }
    private static void DecimalEvaluation()
    {
        decimal number = 0;

        Console.Write("Decimal Add: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number += 1;
            }
        });

        number = 0;

        Console.Write("Decimal Substract: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number -= 1;
            }
        });
        number = 0;

        Console.Write("Decimal Increment: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number++;
            }
        });
        number = 0;

        Console.Write("Decimal Miltiply: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number *= 1;
            }
        });
        number = 0;

        Console.Write("Decimal Divide: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number /= 1;
            }
        });
    }
    private static void DoubleEvaluation()
    {
        double number = 0;

        Console.Write("Double Add: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number += 1;
            }
        });

        number = 0;

        Console.Write("Double Substract: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number -= 1;
            }
        });
        number = 0;

        Console.Write("Double Increment: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number++;
            }
        });
        number = 0;

        Console.Write("Double Miltiply: \t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number *= 1;
            }
        });
        number = 0;

        Console.Write("Double Divide: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number /= 1;
            }
        });
    }
    private static void IntEvaluation()
    {
        int number = 0;

        Console.Write("Int Add: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number += 1;
            }
        });

        number = 0;

        Console.Write("Int Substract: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number -= 1;
            }
        });
        number = 0;

        Console.Write("Int Increment: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number++;
            }
        });
        number = 0;

        Console.Write("Int Miltiply: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number *= 1;
            }
        });
        number = 0;

        Console.Write("Int Divide: \t\t");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            for (int i = 0; i < 20000000; i++)
            {
                number /= 1;
            }
        });
    }
Beispiel #7
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
    private static void TestArrays <T>(T[] arr1, T[] arr2, T[] arr3)
        where T : IComparable
    {
        Console.WriteLine("Insertion sort:");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            var intArr = InsertionSort(arr1);
        });

        Console.WriteLine("Selection sort:");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            var intArr = SelectionSort(arr2);
        });

        Console.WriteLine("Quick sort:");
        TimeDisplayer.DisplayExecutionTime(() =>
        {
            QuickSort(arr3, 0, arr3.Length - 1);
        });
    }