using System; using System.Diagnostics; namespace RiderTestApp { internal class Program { public static double Round(double d) { return Math.Round(d); } public static double RoundWithPrecision(double d) { return Math.Round(d, 0); } public static double Floor(double d) { return Math.Floor(d + 0.5); } private static void TestRound(int n) { var s = new Stopwatch(); double d = 0; s.Start(); for (var i = 0; i < n; i++) { d += Round(3.5); } s.Stop(); Console.WriteLine("Round - d: " + d + ", Time: " + s.ElapsedMilliseconds); } private static void TestRoundWithPrecision(int n) { var s = new Stopwatch(); double d = 0; s.Start(); for (var i = 0; i < n; i++) { d += RoundWithPrecision(3.5); } s.Stop(); Console.WriteLine("RoundWithPrecision - d: " + d + ", Time: " + s.ElapsedMilliseconds); } private static void TestFloor(int n) { var s = new Stopwatch(); double d = 0; s.Start(); for (var i = 0; i < n; i++) { d += Floor(3.5); } s.Stop(); Console.WriteLine("Floor - d: " + d + ", Time: " + s.ElapsedMilliseconds); } public static void Main() { Console.WriteLine(Environment.OSVersion); Console.WriteLine(Type.GetType("Mono.Runtime") == null ? "MS" : "Mono"); Console.WriteLine(Environment.Version); #if DEBUG Console.WriteLine("Mode=Debug"); #else Console.WriteLine("Mode=Release"); #endif Console.WriteLine(); const int n1 = 1000000; TestRound(n1); TestRoundWithPrecision(n1); TestFloor(n1); Console.WriteLine(); const int n2 = n1 * 10; TestRound(n2); TestRoundWithPrecision(n2); TestFloor(n2); Console.WriteLine(); const int n3 = n2 * 10; TestRound(n3); TestRoundWithPrecision(n3); TestFloor(n3); } } }