public static void ParsePower() { double[] powers = Tool.powerParseArr(Config.rootPath + @"\3g_3.pt4", 0); string[] powerStrs = Array.ConvertAll(powers, element => element.ToString()); File.WriteAllLines(Config.rootPath + @"\3g_3.txt", powerStrs); }
// 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(); }
/* * public static void ParseData_nexus() * { * * int fileIndex = Config.fileIndex; * int fileIndexEnd = Config.duration; * * string savePath = Config.rootPath; * * string inputFileName = savePath + "sample" + fileIndex + ".txt"; * string[] dataFiles = Directory.GetFiles(inputFileName); * string[] dataNames = new string[dataFiles.Length]; * for (int i = 0; i < dataFiles.Length; i++) * dataNames[i] = Path.GetFileNameWithoutExtension(dataFiles[i]); * * string[] powerFiles = Directory.GetFiles(savePath + "power"); * string[] powerNames = new string[powerFiles.Length]; * for (int i = 0; i < powerFiles.Length; i++) * powerNames[i] = Path.GetFileNameWithoutExtension(powerFiles[i]); * * //string header = "util freq idle_time idle_usage bright tx rx up ftime fps g3d_core gta_core g3d_time gta_time ta_load txt_uld usse_cc_pix usse_cc_ver usse_load_pix usse_load_ver vpf power"; * string header = "util0 freq0 it ie bright tx rx status capacity volt temp ftime fps gtl2d_core gtl3d_core gtlcom_core gtlta_core gtt2d_core gtt3d_core gttcom_core gttta_core spm ta_load txt_uld usse_cc_pix usse_cc_ver usse_load_pix usse_load_ver vpf vps"; * * List<List<string>> lists = new List<List<string>>(); * * ArrayList saveData = new ArrayList(); * * for (int i = 0; i < dataNames.Length; i++) * { * * string inputFile = dataFiles[i]; * * if (!File.Exists(inputFile)) * { * MessageBox.Show("File not found exception: " + inputFile); * System.Environment.Exit(-1); * } * * string[] datas = File.ReadAllLines(inputFile); * * //int resultIndex = Array.BinarySearch<string>(powerNames, dataNames[i]); * double[] powers = Tool.powerParseArr(savePath + @"power\"+dataNames[i]+@".pt4", 0); * * lists = Config.processData(datas); * * int row = lists.Count - 1; * int col = 0; // lists[0].Count; * string values = ""; * saveData.Add(header); * * for (int r = Config.offset; r < row; r++) * { * List<string> curData = lists[r]; * col = curData.Count; * * for (int c = 1; c < col; c++) * { * values += curData[c] + " "; * } * * values += powers[r-Config.offset]; * saveData.Add(values); * values = ""; * } * * string[] toSave = (string[])saveData.ToArray(typeof(string)); * string saveName = Config.rootPath + "parse\\" + dataNames[i] + ".txt"; * Console.WriteLine("File save = " + saveName); * File.WriteAllLines(saveName, toSave); * saveData.Clear(); * * //MessageBox.Show("File raw_data_" + i + ".txt is saved at " + Config.rootPath); * } * } */ public static void ParseData() { int fileIndex = Config.fileIndex; int fileIndexEnd = Config.duration; //Config.fileIndex = int.Parse(fileIndex_tb.Text); //Config.duration = int.Parse(sampleTime_tb.Text); //Config.callProcess2("pull data/local/tmp/stat/sample"+fileIndex+@".txt " + Config.rootPath+"sample"+fileIndex+@".txt"); string savePath = Config.rootPath; string header = ""; if (Config.DUT == 1) //S4 { header = "util0 util1 util2 util3 freq0 freq1 freq2 freq3 " + "it0s0 it0s1 it0s2 it1s0 it1s1 it1s2 it2s0 it2s1 it2s2 it3s0 it3s1 it3s2 " + "iu0s0 iu0s1 iu0s2 iu1s0 iu1s1 iu1s2 iu2s0 iu2s1 iu2s2 iu3s0 iu3s1 iu3s2 " + "mem " + "bright " + "tx rx status " + "volt current capacity temp " + "ftime fps gtl2d_core gtl3d_core gtac_core gtlta_core gtt2d_core gtt3d_core gttc_core gttta_core spm isp ta_load usse_cc_pp usse_cc_pv usse_load_p usse_load_v vpf vps power"; } else //Nexus s { header = "util0 freq0 it0s0 iu0s0 mem bright tx rx status volt capacity temp ftime fps gtl2d_core gtl3d_core gtlcom_core gtlta_core gtt2d_core gtt3d_core gttcom_core gttta_core spm ta_load txt_uld usse_cc_pix usse_cc_ver usse_load_pix usse_load_ver vpf vps power"; } List <List <string> > lists = new List <List <string> >(); ArrayList saveData = new ArrayList(); for (int i = fileIndex; i <= fileIndexEnd; i++) { string inputFileName = savePath + "sample" + i + ".txt"; if (!File.Exists(inputFileName)) { MessageBox.Show("File not found exception: " + inputFileName); System.Environment.Exit(-1); } string[] datas = File.ReadAllLines(inputFileName); double[] powers = Tool.powerParseArr(i, savePath, 0, 5000); //remove previous data more than 100 int ck = 0; for (int i1 = 0; i1 < powers.Length; i1++) { double p = powers[i1]; if (p < 100) { ck = i1; } } ++ck; double[] powerNews = new double[powers.Length - ck]; for (int i2 = ck; i2 < powers.Length; ++i2) { powerNews[i2 - ck] = powers[i2]; } lists = Config.processData(datas); int row = lists.Count - 1; int col = 0; // lists[0].Count; string values = ""; saveData.Add(header); int ck2 = 0; for (int r = 1; r < row; r++) { List <string> curData = lists[r]; col = curData.Count; int brightIndex = -1; if (Config.DUT == 1) { brightIndex = 15; } else { brightIndex = 6; } string test = curData[brightIndex]; if (test.Equals("0") || test.Equals("10")) { ck2 = r; } } ++ck2; int pi = 0; int lenTest = 0; if (powerNews.Length < lists.Count) { lenTest = powerNews.Length; } else { lenTest = lists.Count; } for (int r = ck2; r < lenTest; r++) { if (r == lenTest - 1) { Console.WriteLine(""); } List <string> curData = lists[r]; col = curData.Count; for (int c = 1; c < col; c++) { values += curData[c] + " "; } if (pi == lenTest) { break; } values += powerNews[pi]; ++pi; saveData.Add(values); values = ""; } string[] toSave = (string[])saveData.ToArray(typeof(string)); string saveName = Config.rootPath + "raw_data_" + i + ".txt"; Console.WriteLine("File save = " + saveName); File.WriteAllLines(saveName, toSave); saveData.Clear(); //MessageBox.Show("File raw_data_"+fileIndex+".txt is saved at "+Config.rootPath); } //MessageBox.Show("File raw_data_" + fileIndex + "-" + fileIndexEnd + ".txt is saved at " + Config.rootPath); Application.Exit(); }