static Dictionary<string, FunctionStat> ProcessingCallStack(string rawTextLog) { string[] perRecord = rawTextLog.Split(new string[] { recordSep }, StringSplitOptions.None); List<string> PrevCallStackString = null; List<string> CurCallStackString = new List<string>(); string curRunningFn = null; string prevRunningFn = null; Dictionary<string, FunctionStat> histogram = new Dictionary<string, FunctionStat>(); foreach (string l in perRecord) { Regex regex = new Regex(@"tsc: ([\w]+ [\w]+) ([\d]+.[\d]+) \(([\d]+.[\d]+)\) rip:([\w]+)"); Match match = regex.Match(l); //bool bFound = false; double curTimestamp = 0; double previousTimestamp = 0; // Read current callstack if (match.Success) { curTimestamp = double.Parse(match.Groups[2].Value); string temp = l.Trim(); CurCallStackString.Clear(); foreach (string l2 in temp.Split('\n')) { Regex regex2 = new Regex(@"Pc:([\w]+) AddrReturn:([\w]+) \(([\w\+]+)\) Frame:([\w]+)"); Match match2 = regex2.Match(l2); if (match2.Success) { CurCallStackString.Add(l2); } } } // Compare cur/prev callstack to figure out running fn if (PrevCallStackString != null && PrevCallStackString.Count != 0 && CurCallStackString.Count != 0) { for (int i = 0; i != CurCallStackString.Count - 1; i++) { for (int j = 0; j != PrevCallStackString.Count - 1; j++) { //Console.WriteLine("i {0} j {1}", i, j); if (CurCallStackString[i] == PrevCallStackString[j] && CurCallStackString[i + 1] == PrevCallStackString[j + 1] && IsInFilter(getNameOnlyFunction(CurCallStackString[i])) == false) { // bFound = true; curRunningFn = CurCallStackString[i]; goto _break; } } } _break: ; //Console.WriteLine("--- curRunningFn: {0} prevRunningFn: {1}", curRunningFn, prevRunningFn); } // update the current fn if (curRunningFn != null && curRunningFn == prevRunningFn) { string fnName = getNameOnlyFunction(curRunningFn); //Console.WriteLine("Fn: {0}", fnName); UpdateTimeHistogram(ref histogram, fnName, curTimestamp - previousTimestamp); } prevRunningFn = curRunningFn; previousTimestamp = curTimestamp; // update prev callstack PrevCallStackString = null; PrevCallStackString = CurCallStackString.ToList(); } return histogram; }
private void UpdateAddList() { addlist.ItemsSource = Notification.ToList(); }