Exemple #1
0
        private static void SinusTest()
        {
            ResultsLogger.Log("Sinus test");

            StopwatchMeasures.MeasureTime(
                "Float",
                () =>
            {
                float result = (float)Math.Sin(311.12534);
            });

            StopwatchMeasures.MeasureTime(
                "Double",
                () =>
            {
                double result = Math.Sin(311.12534);
            });

            StopwatchMeasures.MeasureTime(
                "Decimal",
                () =>
            {
                decimal result = (decimal)Math.Sin(311.12534);
            });
        }
Exemple #2
0
        private static void NaturalLogarithmTest()
        {
            ResultsLogger.Log("Natural logarithm test");

            StopwatchMeasures.MeasureTime(
                "Float",
                () =>
            {
                float result = (float)Math.Log(311.12534);
            });

            StopwatchMeasures.MeasureTime(
                "Double",
                () =>
            {
                double result = Math.Log(311.12534);
            });

            StopwatchMeasures.MeasureTime(
                "Decimal",
                () =>
            {
                decimal result = (decimal)Math.Log(311.12534);
            });
        }
        public static void MeasureTime(string valueType, Action method)
        {
            var stopwatch = Stopwatch.StartNew();

            for (int i = 0; i < TimesToExecute; i++)
            {
                method();
            }

            stopwatch.Stop();

            ResultsLogger.LogResult(valueType, stopwatch.Elapsed.ToString());
        }