Exemplo n.º 1
0
 private static void AddWarningToCurrent(MySimpleProfilingBlock block)
 {
     if (m_currentWarnings.ContainsKey(block.Name))
     {
         m_currentWarnings[block.Name].Time = 0;
     }
     else
     {
         m_currentWarnings.Add(block.Name, new PerformanceWarning(block));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Unused, but returns the area which is the most above threshold, null if none is
        /// </summary>
        private static MySimpleProfilingBlock FindWorstPerformanceBlock()
        {
            MySimpleProfilingBlock worstPerformanceBlock = null;
            double worstPerformance = 0;
            double performance;

            foreach (MySimpleProfilingBlock block in m_profilingBlocks.Values)
            {
                performance = 0;

                if (block.ThresholdFrameMilliseconds > 0)
                {
                    performance = block.Time.Miliseconds / block.ThresholdFrameMilliseconds;
                }
                else if (block.ThresholdFrameMilliseconds < 0)
                {
                    performance = -block.ThresholdFrameMilliseconds / block.Time.Miliseconds;
                }
                if (performance > worstPerformance)
                {
                    worstPerformance      = performance;
                    worstPerformanceBlock = block;
                }

                if (block.Frames == 59)
                {
                    if (block.ThresholdSecondMilliseconds > 0)
                    {
                        performance = block.Average / block.ThresholdFrameMilliseconds;
                    }
                    else if (block.ThresholdSecondMilliseconds < 0)
                    {
                        performance = -block.ThresholdFrameMilliseconds / block.Average;
                    }
                }
                if (performance > worstPerformance)
                {
                    worstPerformance      = performance;
                    worstPerformanceBlock = block;
                }
            }
            if (worstPerformance > 1)
            {
                return(worstPerformanceBlock);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Show performance warning received from server
        /// </summary>
        public static void ShowServerPerformanceWarning(string key)
        {
            MySimpleProfilingBlock block;

            if (!m_profilingBlocks.TryGetValue(key, out block))
            {
                block      = new MySimpleProfilingBlock();
                block.Name = key;
            }
            if (ShowPerformanceWarning != null)
            {
                ShowPerformanceWarning(block);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Begin new profiling block
        /// </summary>
        public static void Begin(string key)
        {
            if (String.IsNullOrEmpty(key))
            {
                return;
            }
            MySimpleProfilingBlock block;

            if (!m_profilingBlocks.TryGetValue(key, out block))
            {
                block      = new MySimpleProfilingBlock();
                block.Name = key;
                m_profilingBlocks.Add(key, block);
            }
            block.TimeStamp = new MyTimeSpan(Stopwatch.GetTimestamp());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Set special settings for a profiling block
        /// </summary>
        public static void SetBlockSettings(string key, int thresholdFrame = 100, int thresholdSecond = 10, bool gpu = false, MySimpleProfilingBlock.ProfilingBlockType type = MySimpleProfilingBlock.ProfilingBlockType.BLOCK)
        {
            MySimpleProfilingBlock block;

            if (!m_profilingBlocks.TryGetValue(key, out block))
            {
                block      = new MySimpleProfilingBlock();
                block.Name = key;
                m_profilingBlocks.Add(key, block);
            }

            block.LocalizedName = MyStringId.GetOrCompute("PerformanceWarningArea" + key);
            block.Description   = MyStringId.GetOrCompute("PerformanceWarningArea" + key + "Description");
            block.ThresholdFrameMilliseconds  = thresholdFrame;
            block.ThresholdSecondMilliseconds = thresholdSecond;
            block.GPU  = gpu;
            block.type = type;
        }
Exemplo n.º 6
0
        /// <summary>
        /// End profiling block
        /// </summary>
        public static void End(string key)
        {
            if (String.IsNullOrEmpty(key))
            {
                return;
            }
            MySimpleProfilingBlock block;

            if (m_profilingBlocks.TryGetValue(key, out block))
            {
                block.Log(new MyTimeSpan(Stopwatch.GetTimestamp()));
            }
            else
            {
                block      = new MySimpleProfilingBlock();
                block.Name = key;
                using (m_blockLock.AcquireExclusiveUsing())
                {
                    m_profilingBlocks.Add(key, block);
                }
            }
        }
Exemplo n.º 7
0
 public PerformanceWarning(MySimpleProfilingBlock block)
 {
     Block = block;
     Time = 0;
 }
Exemplo n.º 8
0
 private static void AddWarningToCurrent(MySimpleProfilingBlock block)
 {
     if (m_currentWarnings.ContainsKey(block.Name))
         m_currentWarnings[block.Name].Time = 0;
     else
         m_currentWarnings.Add(block.Name, new PerformanceWarning(block));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Show performance warning received from server
 /// </summary>
 public static void ShowServerPerformanceWarning(string key)
 {
     MySimpleProfilingBlock block;
     if (!m_profilingBlocks.TryGetValue(key, out block))
     {
         block = new MySimpleProfilingBlock();
         block.Name = key;
     }
     if (ShowPerformanceWarning != null)
     {
         ShowPerformanceWarning(block);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Set special settings for a profiling block
        /// </summary>
        public static void SetBlockSettings(string key, int thresholdFrame = 100, int thresholdSecond = 10, bool gpu = false, MySimpleProfilingBlock.ProfilingBlockType type = MySimpleProfilingBlock.ProfilingBlockType.BLOCK)
        {
            MySimpleProfilingBlock block;
            if (!m_profilingBlocks.TryGetValue(key, out block))
            {
                block = new MySimpleProfilingBlock();
                block.Name = key;
                m_profilingBlocks.Add(key, block);
            }

            block.LocalizedName = MyStringId.GetOrCompute("PerformanceWarningArea" + key);
            block.Description = MyStringId.GetOrCompute("PerformanceWarningArea" + key + "Description");
            block.ThresholdFrameMilliseconds = thresholdFrame;
            block.ThresholdSecondMilliseconds = thresholdSecond;
            block.GPU = gpu;
            block.type = type;
        }
Exemplo n.º 11
0
 /// <summary>
 /// End profiling block
 /// </summary>
 public static void End(string key)
 {
     if (String.IsNullOrEmpty(key))
         return;
     MySimpleProfilingBlock block;
     if (m_profilingBlocks.TryGetValue(key, out block))
     {
         block.Log(new MyTimeSpan(Stopwatch.GetTimestamp()));
     }
     else
     {
         block = new MySimpleProfilingBlock();
         block.Name = key;
         m_profilingBlocks.Add(key, block);
     }
 }
Exemplo n.º 12
0
 public PerformanceWarning(MySimpleProfilingBlock block)
 {
     Block = block;
     Time  = 0;
 }