/// <summary> /// Ends the current active profiling block. /// </summary> public static void EndBlock() { if (rootBlock != currentBlock) { currentBlock.End(); currentBlock = currentBlock.Parent; } }
private Stopwatch _timer; // Internal timer for getting real time information #endregion Fields #region Constructors internal ProfileBlock(ProfileBlock p, string name) { _timer = new Stopwatch(); Parent = p; Children = new List<ProfileBlock>(); Time = MaxTime = LastTime = LastMaxTime = TotalTime = TotalMaxTime = TimeSpan.Zero; Count = LastCount = TotalCount = 0; int num = count++; if (String.IsNullOrEmpty(name)) Name = "ProfileBlock" + num; else Name = name; }
// Gets a child block with the given name, or creates a new child if none exists. public ProfileBlock GetChild(string name) { foreach (ProfileBlock p in Children) if (p.Name == name) return p; ProfileBlock np = new ProfileBlock(this, name); Children.Add(np); return np; }
static Debug() { currentBlock = rootBlock = new Debugging.ProfileBlock(null, "Root"); TotalFrames = 0; UseProfilerFileDump = true; }
internal static void EndFrame() { if (currentBlock != rootBlock) { EndBlock(); ++TotalFrames; if (TotalFrames == 0) ++TotalFrames; rootBlock.EndFrame(); currentBlock = rootBlock; } }
/// <summary> /// Begins timing the block with the given name. /// </summary> /// <param name="name">The name of the block to start timing.</param> public static void BeginBlock(string name) { currentBlock = currentBlock.GetChild(name); currentBlock.Begin(); }