private static void generateProfileString(ProfilingPoint profilingPoint, StringBuilder builder, string prefix, float parentTime, Func <ProfilingPoint, bool> filter) { if (!filter(profilingPoint)) { return; } var ms = calculateAverageMilliseconds(profilingPoint); appendOutputLine(builder, prefix, ms, parentTime, profilingPoint.Name, profilingPoint.TimesEnteredNonRecursive); float childrenTotal = 0; var additionalPrefix = "| "; foreach (var child in profilingPoint.NonRecursiveChildren) { generateProfileString(child, builder, prefix + additionalPrefix, ms, filter); childrenTotal += calculateAverageMilliseconds(child); } var remainder = ms - childrenTotal; if (remainder / ms > 0.1 && profilingPoint.NonRecursiveChildren.Count != 0) { appendOutputLine(builder, prefix + additionalPrefix, remainder, ms, "[...]", 1); } }
/// <summary> /// Returns a string with recursive profiling information /// </summary> /// <returns></returns> public static string GenerateProfileString(ProfilingPoint profilingPoint, Func <ProfilingPoint, bool> filter) { var builder = new StringBuilder(); generateProfileString(profilingPoint, builder, "", calculateAverageMilliseconds(profilingPoint), filter); return(builder.ToString()); }
public void Begin() { if (shouldSkip()) { return; } ProfilingPoint prev = null; if (pointStack.Count != 0) { prev = pointStack.Peek(); } pointStack.Push(this); log.Add(this); checkNeedsReset(); // Check if the data needs a reset depth++; if (depth != 1) { return; } startProfiling(); if (prev != null) { prev.NonRecursiveChildren.Add(this); } }
public static string GenerateProfileString(ProfilingPoint profilingPoint) { return(GenerateProfileString(profilingPoint, p => true)); }
private static float calculateAverageMilliseconds(ProfilingPoint profilingPoint) { return(profilingPoint.TotalTime * 1000); }
public static ProfilingPoint CreateElement(string name) { var el = new ProfilingPoint(instance, name); return(el); }