// Ends the current active profiling block.
 public static void EndBlock()
 {
     if (rootBlock != currentBlock)
     {
         currentBlock.End();
         currentBlock = currentBlock.Parent;
     }
 }
 public static void EndFrame()
 {
     if (currentBlock != rootBlock)
     {
         EndBlock();
         ++TotalFrames;
         if (TotalFrames == 0)
             ++TotalFrames;
         rootBlock.EndFrame();
         currentBlock = rootBlock;
     }
 }
        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;
        }
Example #4
0
 static Debug()
 {
     currentBlock = rootBlock = new Debugging.ProfileBlock(null, "Root");
     TotalFrames = 0;
     UseProfilerFileDump = true;
 }
        // 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;
        }
 // Begins timing the block with the given name.
 public static void BeginBlock(string name)
 {
     currentBlock = currentBlock.GetChild(name);
     currentBlock.Begin();
 }