/// <summary> /// add child /// </summary> /// <param name="child"></param> public void AddChild(ProfileResultItem child) { children.Add(child); }
/// <summary> /// add profiling result /// </summary> /// <param name="fms"></param> public void Add(StackFrame[] fms) { // count increment profileCount++; result.Increment(); // skip if thread is in the top function if (fms.Length <= startLength) { return; } // search algorithm ProfileResultItem find = result; for (int i = fms.Length - startLength; i >= 0; i--) { // function MethodBase bsMethod = fms[i].GetMethod(); // search next string class_name = bsMethod.ReflectedType == null ? "" : bsMethod.ReflectedType.FullName; ProfileResultItem findt = find.SearchChildren(bsMethod.ToString(), class_name); // create if not found if (findt == null) { findt = new ProfileResultItem(item_id++, find, bsMethod.Name, bsMethod.ToString(), class_name); // add to the list resultList.Add(findt); // add to paremt find.AddChild(findt); } // switch the current parent find = findt; // increment find.Increment(); } }
/// <summary> /// constructor /// </summary> /// <param name="id"></param> /// <param name="parent"></param> /// <param name="function_name"></param> /// <param name="function_string"></param> /// <param name="class_name"></param> public ProfileResultItem( int id, ProfileResultItem parent, string function_name, string function_string, string class_name) { this.ID = id; this.parent = parent; this.FunctionName = function_name; this.FunctionString = function_string; this.ClassName = class_name; if (parent != null) { this.Depth = parent.Depth + 1; this.ParentName = parent.FunctionName; this.ParentID = parent.ID; } else { this.Depth = 0; this.ParentName = ""; this.ParentID = -1; } this.ProfileCount = 0; }
/// <summary> /// constructor /// </summary> /// <param name="sfStart"></param> public ProfileResult(StackFrame[] sfStart) { result = new ProfileResultItem(item_id++, null, "<TOP>", "", ""); startLength = sfStart.Length; }