// Generate final data of screen public static void parseCPUData() { string[] fileName = { "1_idle_1", "1_idle_10", "1_idle_50", "1_idle_100", "1_idle_500", "1_idle_1000", "10_idle_1", "10_idle_10", "10_idle_50", "10_idle_100", "10_idle_500", "10_idle_1000", "25_idle_1", "25_idle_10", "25_idle_50", "25_idle_100", "25_idle_500", "25_idle_1000", "35_idle_1", "35_idle_10", "35_idle_50", "35_idle_100", "35_idle_500", "35_idle_1000", "50_idle_1", "50_idle_10", "50_idle_50", "50_idle_100", "50_idle_500", "50_idle_1000", "60_idle_1", "60_idle_10", "60_idle_50", "60_idle_100", "60_idle_500", "60_idle_1000", "100_idle_1", "100_idle_10", "100_idle_50", "100_idle_100", "100_idle_500", "100_idle_1000" }; ArrayList trainData = new ArrayList(); ArrayList testData = new ArrayList(); string header = "util0 c0its0 c0its1 c0its2 c0ies0 c0ies1 c0ies2 freq0 bright power"; string value = ""; trainData.Add(header); testData.Add(header); int fileLen = fileName.Length; string freq0 = "1000000"; string path = "CPU_idle_900_to_1200"; for (int f = 0; f < fileLen; f++) { string rootFilePath = @"D:\Research\S4\CPU_old\CPU_one_core\old\" + path + @"\test_1_freq_" + freq0 + "_util_" + fileName[f]; if (!File.Exists(rootFilePath + @".txt")) { //Console.WriteLine("Skip "+rootFilePath + @".txt"); continue; } Console.WriteLine("Exist " + rootFilePath + @".txt"); string[] data = File.ReadAllLines(rootFilePath + ".txt"); int begin = 30; int dataLen = data.Length; double[] powerData = Tool.powerParseArr(rootFilePath + ".pt4", begin, 0, 5000); int powLen = powerData.Length; int end = Math.Min(dataLen, powLen); int len = end; int testIndex = len - ((len - begin) / 4); for (int i = begin; i < len; i++) { string line = data[i]; string[] elements = line.Split(' '); if (!rootFilePath.Contains("_100_")) { string util = elements[2].Split('=')[1]; if (util.Equals("100.00")) { continue; } } for (int j = 2; j <= 10; j++) { value += elements[j].Split('=')[1] + " "; } value += (powerData[i - begin] - 7.4); //7.4 is the power of (bright = 10) if (i >= testIndex) { testData.Add(value); } else { trainData.Add(value); } value = ""; } } string[] savetainData = (string[])trainData.ToArray(typeof(string)); string saveTrainName = @"D:\research\S4\CPU_old\CPU_one_core\output\train_" + freq0 + ".txt"; string[] savetestData = (string[])testData.ToArray(typeof(string)); string saveTestName = @"D:\research\S4\CPU_old\CPU_one_core\output\test_" + freq0 + ".txt"; Console.WriteLine("File save"); File.WriteAllLines(saveTrainName, savetainData); File.WriteAllLines(saveTestName, savetestData); trainData.Clear(); testData.Clear(); }