public static void WriteCalculations() { List <int> integers = Enumerable.Range(1, 30).ToList <int>(); Console.WriteLine("DeliveryTruck time tests." + Environment.NewLine); Console.WriteLine("Calculating for 10 locations:"); for (int i = 1; i <= 10; i++) { long result = DeliveryTruck.TimeCalculation(i, DeliveryTruck.locationsForTimeTest_10); Console.WriteLine($" {i} stops took {result} ms"); } Console.WriteLine("Calculating for 20 locations:"); for (int i = 1; i <= 20; i++) { long result = DeliveryTruck.TimeCalculation(i, DeliveryTruck.locationsForTimeTest_20); Console.WriteLine($" {i} stops took {result} ms"); } Console.WriteLine("Calculating for 30 locations:"); for (int i = 1; i <= 30; i++) { long result = DeliveryTruck.TimeCalculation(i, DeliveryTruck.locationsForTimeTest_30); Console.WriteLine($" {i} stops took {result} ms"); } }
public static long TimeCalculation(int stopCount, int[,] locations) { DeliveryTruck calculator = new DeliveryTruck(locations.GetLength(0), locations, stopCount); var timer = new System.Diagnostics.Stopwatch(); timer.Start(); calculator.GetResult(); timer.Stop(); return(timer.ElapsedMilliseconds); }