Esempio n. 1
0
		static void DisplayResults(ResultSet[] resultSets)
		{
			int maxNameLength = 2 + resultSets.Max(s => s.Name.Length);
			for (int i = 0; i < resultSets[0].Results.Count; i++) {
				Console.WriteLine();
				Console.WriteLine(resultSets[0].Results[i].Name);
				var averageStrings = resultSets.Select(s => s.Results[i].Average.ToString("f4")).ToArray();
				var sdStrings = resultSets.Select(s => s.Results[i].StandardDeviation.ToString("f4")).ToArray();
				int maxAverageLength = averageStrings.Max(s => s.Length);
				int maxSDLength = sdStrings.Max(s => s.Length);
				
				var bestResult = resultSets.Min(s => s.Results[i].Average);
				var factorStrings = resultSets.Select(s => (s.Results[i].Average / bestResult).ToString("f2")).ToArray();
				int maxFactorLength = factorStrings.Max(s => s.Length);
				
				for (int j = 0; j < resultSets.Length; j++) {
					Console.WriteLine("  " + (resultSets[j].Name + ":").PadRight(maxNameLength)
					                  + averageStrings[j].PadLeft(maxAverageLength) + resultSets[0].Results[i].Unit
					                  + " +- " + sdStrings[j].PadLeft(maxSDLength) + resultSets[0].Results[i].Unit
					                  + " (" + factorStrings[j].PadLeft(maxFactorLength) + "x)");
				}
			}
		}