public Profiler(Profiler parent)
 {
     Children = new List<Profiler>();
     Parent = parent; parent.Children.Add(this);
     Root = parent;
     Indentation = 1;
     while (Root.Parent != null)
     {
         Root = Root.Parent;
         Indentation++;
     }
 }
        static ClientProfilers()
        {
#if ENABLE_PROFILERS
            Program = new Profiler();
            Update = new Profiler(Program);
            SoundUpdate = new Profiler(Update);
            StateUpdate = new Profiler(Update);
            ProcessMessage = new Profiler(Update);
            HPBars = new Profiler(ProcessMessage);
#if PROFILE_PARTICLESYSTEM
            ParticleUpdate = new Profiler(ProcessMessage);
            Graphics.ParticleEffect.UpdateStart += new Action(() => ParticleUpdate.Start());
            Graphics.ParticleEffect.UpdateEnd += new Action(() => ParticleUpdate.Stop());
            Add = new Profiler(ParticleUpdate);
            Graphics.ParticleEffect.AddStart += new Action(() => Add.Start());
            Graphics.ParticleEffect.AddEnd += new Action(() => Add.Stop());
            Logic = new Profiler(ParticleUpdate);
            Graphics.ParticleEffect.LogicStart += new Action(() => Logic.Start());
            Graphics.ParticleEffect.LogicEnd += new Action(() => Logic.Stop());
            //CleanUp = new Profiler(Logic);
            //Graphics.ParticleEffect.CleanUpStart += new Action(() => CleanUp.Start());
            //Graphics.ParticleEffect.CleanUpEnd += new Action(() => CleanUp.Stop());
            //Random = new Profiler(CleanUp);
            //Graphics.ParticleEffect.RandomStart += new Action(() => Random.Start());
            //Graphics.ParticleEffect.RandomEnd += new Action(() => Random.Stop());
            //Cleaner = new Profiler(CleanUp);
            //Graphics.ParticleEffect.CleanerStart += new Action(() => Cleaner.Start());
            //Graphics.ParticleEffect.CleanerEnd += new Action(() => Cleaner.Stop());
            //RemoveCheck = new Profiler(CleanUp);
            //Graphics.ParticleEffect.RemoveCheckStart += new Action(() => RemoveCheck.Start());
            //Graphics.ParticleEffect.RemoveCheckEnd += new Action(() => RemoveCheck.Stop());
            Interpolate = new Profiler(Logic);
            Graphics.ParticleEffect.InterpolateStart += new Action(() => Interpolate.Start());
            Graphics.ParticleEffect.InterpolateEnd += new Action(() => Interpolate.Stop());
            //Physics = new Profiler(Logic);
            //Graphics.ParticleEffect.MathStart += new Action(() => Physics.Start());
            //Graphics.ParticleEffect.MathEnd += new Action(() => Physics.Stop());
            UpdateWorld = new Profiler(Logic);
            Graphics.ParticleEffect.ParticleUpdateWorldStart += new Action(() => UpdateWorld.Start());
            Graphics.ParticleEffect.ParticleUpdateWorldEnd += new Action(() => UpdateWorld.Stop());
            Remove = new Profiler(ParticleUpdate);
            Graphics.ParticleEffect.RemoveStart += new Action(() => Remove.Start());
            Graphics.ParticleEffect.RemoveEnd += new Action(() => Remove.Stop());
#endif
            NearestNeighbours = new Profiler(StateUpdate);
            GameEntityUpdate = new Profiler(StateUpdate);
            Animations = new Profiler(StateUpdate);
#if PROFILE_ANIMATIONS
            ResetMatrices = new Profiler(Animations);
            Graphics.Renderer.Renderer.EntityAnimation.ResetMatricesStart += new Action(() => ResetMatrices.Start());
            Graphics.Renderer.Renderer.EntityAnimation.ResetMatricesStop += new Action(() => ResetMatrices.Stop());
            SetupAC = new Profiler(Animations);
            Graphics.Renderer.Renderer.EntityAnimation.SetupACStrat += new Action(() => SetupAC.Start());
            Graphics.Renderer.Renderer.EntityAnimation.SetupACStop += new Action(() => SetupAC.Stop());
            AdvanceTime = new Profiler(Animations);
            Graphics.Renderer.Renderer.EntityAnimation.AdvanceTimeStart += new Action(() => AdvanceTime.Start());
            Graphics.Renderer.Renderer.EntityAnimation.AdvanceTimeStop += new Action(() => AdvanceTime.Stop());
            AdjustFrames = new Profiler(Animations);
            Graphics.Renderer.Renderer.EntityAnimation.AdjustFrameMatricesStrat += new Action(() => AdjustFrames.Start());
            Graphics.Renderer.Renderer.EntityAnimation.AdjustFrameMatricesStop += new Action(() => AdjustFrames.Stop());
            UpdateMatrices = new Profiler(Animations);
            Graphics.Renderer.Renderer.EntityAnimation.UpdateMatricesStart += new Action(() => UpdateMatrices.Start());
            Graphics.Renderer.Renderer.EntityAnimation.UpdateMatricesStop += new Action(() => UpdateMatrices.Stop());
            StoreMatrices = new Profiler(Animations);
            Graphics.Renderer.Renderer.EntityAnimation.StoreMatricesStart += new Action(() => StoreMatrices.Start());
            Graphics.Renderer.Renderer.EntityAnimation.StoreMatricesStop += new Action(() => StoreMatrices.Stop());
#endif
            PreRender = new Profiler(Update);
            Render = new Profiler(Update);
            Culling = new Profiler(Render);
            Renderer = new Profiler(Render);
#if PROFILE_RENDERER
            RenderAlpha = new Profiler(Renderer);
            Graphics.Renderer.Renderer.RenderAlphaStart += new Action(() => RenderAlpha.Start());
            Graphics.Renderer.Renderer.RenderAlphaStop += new Action(() => RenderAlpha.Stop());
            RenderSkinnedMeshes = new Profiler(Renderer);
            Graphics.Renderer.Renderer.RenderSkinnedMeshesStart += new Action(() => RenderSkinnedMeshes.Start());
            Graphics.Renderer.Renderer.RenderSkinnedMeshesStop += new Action(() => RenderSkinnedMeshes.Stop());
            RenderGround = new Profiler(Renderer);
            Graphics.Renderer.Renderer.RenderSplatMapStart += new Action(() => RenderGround.Start());
            Graphics.Renderer.Renderer.RenderSplatMapStop += new Action(() => RenderGround.Stop());
            RenderXMeshes = new Profiler(Renderer);
            Graphics.Renderer.Renderer.RenderXMeshesStart += new Action(() => RenderXMeshes.Start());
            Graphics.Renderer.Renderer.RenderXMeshesStop += new Action(() => RenderXMeshes.Stop());
#endif

#if PROFILE_INTERFACERENDERER
            InterfaceRender = new Profiler(Update);
            IRPeek = new Profiler(InterfaceRender);
#endif
            Present = new Profiler(Program);
#endif
        }
 static PhysicsProfilers()
 {
     Step = new Profiler();
     UnitStep = new Profiler(Step);
     USWalk = new Profiler(UnitStep);
     WalkSlide = new Profiler(USWalk);
     USFly = new Profiler(UnitStep);
     USFindState = new Profiler(UnitStep);
     StaticBndUpd = new Profiler(Step);
     UnitBndUpd = new Profiler(Step);
     ProjStep = new Profiler(Step);
     UnitColDet = new Profiler(Step);
     UnitColRes = new Profiler(Step);
     UnitHeightAdj = new Profiler(Step);
     Interpolation = new Profiler();
 }