public void showDataForSignature(String sSignature) { // check if this function is on the current list (if not this is an edge) if (false == cirDataAnalysis.dCirFunction_bySignature.ContainsKey(sSignature)) // this case do a hack by adding this edge as a function { var lsFunctionsThatCallSignature = new List <ICirFunctionCall>(); // first find everybody that calls into it foreach (ICirFunction ccFunction in cirDataAnalysis.dCirFunction_bySignature.Values) { if (cirDataAnalysis.dCirFunction_bySignature.ContainsKey(sSignature)) { if (ccFunction.FunctionsCalledUniqueList.Contains(cirDataAnalysis.dCirFunction_bySignature[sSignature])) { lsFunctionsThatCallSignature.Add(new CirFunctionCall(ccFunction)); } } } var ccNewCirFunction = new CirFunction { FunctionSignature = sSignature, FunctionIsCalledBy = lsFunctionsThatCallSignature }; cirDataAnalysis.dCirFunction_bySignature.Add(sSignature, ccNewCirFunction); } var tvTraces = new TreeView(); var lFunctionsCalled = new List <string>(); const string sFilter_Signature = ""; const string sFilter_Parameter = ""; if (cbSearchMode.SelectedItem.ToString() == SearchModes.CalledFunctions.ToString()) { TraceAnalysis.calculateAllTracesFromFunction(sSignature, tvTraces.Nodes, lFunctionsCalled, sFilter_Signature, sFilter_Parameter, false, cirDataAnalysis); } else { TraceAnalysis.calculateAllTracesFromFunction(sSignature, tvTraces.Nodes, lFunctionsCalled, sFilter_Signature, sFilter_Parameter, true, cirDataAnalysis); } if (cbViewMode.SelectedItem.ToString() == ViewModes.List.ToString()) { afv_Functions.showSignatures(lFunctionsCalled); } else { replaceTreeView(this, ref tvTreeView, tvTraces); if (cbSearchMode.SelectedItem.ToString() == SearchModes.IsCalledBy.ToString()) { tvTreeView.ExpandAll(); } } }
public TraceAnalysis InitAnalysis(List <TraceRow> rows, string analysisName) { var result = new TraceAnalysis { RawRows = rows, Name = analysisName }; result.RawGrouped = result.RawRows.GroupBy(g => g.TextData).Select(c => new CountedCommand { Count = c.Count(), Command = c.Key, TotalDuration = c.Sum(m => m.Duration), AverageDuration = c.Average(m => m.Duration) }).OrderByDescending(c => c.Count).ToList(); result.CleanRows = new List <TraceRow>(); foreach (var traceRow in rows) { const string clearingRegex = @"=(\d+)"; var cleanRow = traceRow.Clone(); var procStart = cleanRow.TextData.IndexOf("exec", StringComparison.Ordinal); cleanRow.TextData = cleanRow.TextData.Substring(procStart); cleanRow.TextData = Regex.Replace(cleanRow.TextData, clearingRegex, "=#"); cleanRow.TextData = cleanRow.TextData.Replace("=NULL", "=#"); cleanRow.TextData = cleanRow.TextData.Replace("exec ", string.Empty); //custom cases, I'm lazy right now if (cleanRow.TextData.Contains("@CreationDate=")) { cleanRow.TextData = cleanRow.TextData.Substring(0, cleanRow.TextData.IndexOf("@CreationDate=", StringComparison.Ordinal)); } result.CleanRows.Add(cleanRow); } result.CleanGrouped = result.CleanRows.GroupBy(g => g.TextData).Select(c => new CountedCommand { Count = c.Count(), Command = c.Key, TotalDuration = c.Sum(m => m.Duration), AverageDuration = c.Average(m => m.Duration) }).OrderByDescending(c => c.Count).ThenBy(c => c.Command).ToList(); return(result); }
public static string OutputBasicStats(TraceAnalysis analysis, int rowsToShow = 20) { var sb = new StringBuilder(); sb.AppendLine( $"# [name: {analysis.Name}] statistics: {analysis.Total} total; {analysis.Grouped} grouped; gain -> {analysis.Gain} ({analysis.GainPercent}%)"); sb.AppendLine( $"# [name: {analysis.Name}] statistics: {analysis.CleanRows.Sum(r => r.Reads)} reads; {analysis.CleanRows.Sum(r => r.Writes)} writes;"); sb.AppendLine( $"# [name: {analysis.Name}] statistics: {(analysis.CleanRows.Last().StartTime - analysis.CleanRows.First().EndTime)} total time;"); const int stringLimit = 100; if (rowsToShow > 0) { sb.AppendLine("#====== with ids"); foreach (var source in analysis.RawGrouped.Take(rowsToShow)) { sb.AppendLine(source.Count + " " + source.Command.Substring(0, source.Command.Length < stringLimit ? source.Command.Length : stringLimit)); } sb.AppendLine("#^^^^^^ with ids"); } sb.AppendLine(@"#====== without ids \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/"); foreach (var source in analysis.CleanGrouped) { sb.AppendLine(source.Count + " " //+ " [ " + source.TotalDuration / 1000 + " ] " + source.Command.Substring(0, source.Command.Length < stringLimit ? source.Command.Length : stringLimit)); } sb.AppendLine(@"#^^^^^^ without ids ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); sb.AppendLine("#====== longest"); foreach (var source in analysis.CleanGrouped.OrderByDescending(o => o.TotalDuration).Take(10)) { sb.AppendLine(source.Count + " [ " + source.TotalDuration / 1000 + " ] " + source.Command.Substring(0, source.Command.Length < stringLimit ? source.Command.Length : stringLimit)); } sb.AppendLine("#^^^^^^ longest"); sb.AppendLine(); return(sb.ToString()); }