/// <summary> /// Writes a log file with a line of "1" listed for the value in logAmount. /// </summary> /// <param name="segmentSize">The size of the segment that the algorithm was performed on.</param> /// <param name="logAmount">The number of ones to log; a measure of operations that were performed by the algorithm.</param> /// <param name="algorithmType">The type of algorithm that was performed.</param> public static void WriteEfficiencyLog(int segmentSize, int logAmount, string algorithmType) { string logFilePath = Common_Code.GetLogFilePath("Efficiency_" + algorithmType, ("Size" + segmentSize.ToString())); using (var logger = new StreamWriter(logFilePath)) { for (int i = 0; i <= logAmount; i++) { logger.WriteLine(1); } } }
/// <summary> /// Write the given frequency sort array to a log file with the given value appended as "Size". /// </summary> /// <param name="counters">The an array of the count of each value to be written.</param> /// <param name="segmentSize">The size of the original array that was sorted.</param> public static int FrequencySortToFile(int[] counters, int segmentSize) { string path = Common_Code.GetLogFilePath(Common_Code.frequencySort, "SegmentSize" + segmentSize.ToString() + "_Counters" + counters.ToString()); int logCount = 1; using (var writer = new StreamWriter(path)) { for (int i = 0; i < counters.Length; i++) { for (int j = 0; j < counters[i]; j++) { writer.WriteLine(i); logCount++; } } } return(logCount); }