public void TrappingRainWater2Performance() { Console.WriteLine("Testing TrappingRainWater2s"); // Arrange TrappingRainWater2 trappingRainWater2 = new TrappingRainWater2(); Stopwatch sw = new Stopwatch(); int[] terrain = new int[981]; long averageRuntime = 0; int numberOfRuns = 10; int i; int j = 0; for (i = 980; i >= 0; i--) { terrain[j++] = i; } // Act for (int k = 0; k < 10; k++) { sw.Reset(); sw.Start(); trappingRainWater2.Trap(terrain); sw.Stop(); averageRuntime += sw.ElapsedMilliseconds; Console.WriteLine("Runtime for trappingRainWater2.Trap run {0}: {1}", k, sw.ElapsedMilliseconds); } averageRuntime = averageRuntime / numberOfRuns; // Assert Console.WriteLine("Average runtime for trappingRainWater2.Trap: {0}", averageRuntime); }