Ejemplo n.º 1
0
        public static TimerProfile GetProfile( this Timer timer )
        {
            if ( !Environment.Profiling )
                return null;

            string name = timer.ToString();

            TimerProfile prof = (TimerProfile) m_Profiles[name];

            if ( prof == null )
                m_Profiles[name] = prof = new TimerProfile();

            return prof;
        }
Ejemplo n.º 2
0
        public void Start()
        {
            if (!m_Running)
            {
                m_Running = true;
                TimerThread.AddTimer(this);

                TimerProfile prof = GetProfile();

                if (prof != null)
                {
                    prof.Started++;
                }
            }
        }
Ejemplo n.º 3
0
        public void Stop()
        {
            if (m_Running)
            {
                m_Running = false;
                TimerThread.RemoveTimer(this);

                TimerProfile prof = GetProfile();

                if (prof != null)
                {
                    prof.Stopped++;
                }
            }
        }
Ejemplo n.º 4
0
        public TimerProfile GetProfile()
        {
            if (!Core.Profiling)
            {
                return(null);
            }

            string name = ToString();

            if (name == null)
            {
                name = "null";
            }

            return(TimerProfile.Acquire(name));
        }
Ejemplo n.º 5
0
        public void Stop()
        {
            if (m_Running)
            {
                m_Running = false;

                m_Scheduler.RemoveTimer(this);

                TimerProfile prof = this.GetProfile();

                if (prof != null)
                {
                    prof.RegStopped();
                }
            }
        }
Ejemplo n.º 6
0
        public void Start()
        {
            if (!m_Running)
            {
                m_Running = true;

                m_Scheduler.AddTimer(this);

                TimerProfile prof = this.GetProfile();

                if (prof != null)
                {
                    prof.RegStart();
                }
            }
        }
Ejemplo n.º 7
0
        public static void DumpInfo(StreamWriter sw)
        {
            sw.WriteLine("# Dump on {0:f}", DateTime.Now);
            sw.WriteLine("# Core profiling for " + Environment.ProfileTime);
            sw.WriteLine();

            foreach (DictionaryEntry de in m_Profiles)
            {
                string       name = (string)de.Key;
                TimerProfile prof = (TimerProfile)de.Value;

                sw.WriteLine("{6,-100}{0,-12}{1,12} {2,-12}{3,12} {4,-12:F5}{5:F5} {7:F5}", prof.Created, prof.Started, prof.Stopped, prof.Ticked, prof.TotalProcTime.TotalSeconds, prof.AverageProcTime.TotalSeconds, name, prof.PeakProcTime.TotalSeconds);
            }

            sw.WriteLine();
            sw.WriteLine();
        }
Ejemplo n.º 8
0
        public static void Slice()
        {
            lock ( m_Queue )
            {
                m_QueueCountAtSlice = m_Queue.Count;

                int      index = 0;
                DateTime start = DateTime.MinValue;
                //DateTime breakTime = DateTime.Now + m_BreakTime;
                //int saves = World.m_Saves;

                while (index < m_BreakCount && m_Queue.Count != 0)
                {
                    Timer        t    = (Timer)m_Queue.Dequeue();
                    TimerProfile prof = t.GetProfile();

                    if (prof != null)
                    {
                        start = DateTime.UtcNow;
                    }

                    t.OnTick();
                    t.m_Queued = false;
                    ++index;

                    if (prof != null)
                    {
                        prof.RegTicked(DateTime.UtcNow - start);
                    }

                    /*if ( saves == World.m_Saves && DateTime.Now >= breakTime )
                     * {
                     *      Console.WriteLine( "Timer stall detected, dumping timers" );
                     *
                     *      using ( StreamWriter sw = new StreamWriter( "timerdump_stall.log", true ) )
                     *      {
                     *              sw.WriteLine( "PROBLEM TIMER: {0}", t );
                     *              Timer.DumpInfo( sw );
                     *      }
                     *
                     *      break;
                     * }*/
                }                //while !empty
            }
        }
Ejemplo n.º 9
0
        internal void Tick()
        {
            TimerProfile prof = this.GetProfile();

            DateTime start = DateTime.MinValue;

            if (prof != null)
            {
                start = DateTime.Now;
            }

            OnTick();

            if (prof != null)
            {
                prof.RegTicked(DateTime.Now - start);
            }
        }
Ejemplo n.º 10
0
        public static TimerProfile GetProfile(this Timer timer)
        {
            if (!Core.Profiling)
            {
                return(null);
            }

            var name = timer.ToString();

            var prof = (TimerProfile)m_Profiles[name];

            if (prof == null)
            {
                m_Profiles[name] = prof = new TimerProfile();
            }

            return(prof);
        }
Ejemplo n.º 11
0
        public static TimerProfile GetProfile(this Timer timer)
        {
            if (!Environment.Profiling)
            {
                return(null);
            }

            string name = timer.ToString();

            TimerProfile prof = (TimerProfile)m_Profiles[name];

            if (prof == null)
            {
                m_Profiles[name] = prof = new TimerProfile();
            }

            return(prof);
        }
Ejemplo n.º 12
0
        public TimerProfile GetProfile()
        {
            if (!Core.Profiling)
            {
                return(null);
            }
            string text1 = this.ToString();

            if (text1 == null)
            {
                text1 = "null";
            }
            TimerProfile profile1 = ((TimerProfile)Server.Timer.m_Profiles[text1]);

            if (profile1 == null)
            {
                Server.Timer.m_Profiles[text1] = (profile1 = new TimerProfile());
            }
            return(profile1);
        }
Ejemplo n.º 13
0
        public static void Slice()
        {
            lock ( m_Queue )
            {
                m_QueueCountAtSlice = m_Queue.Count;

                int index = 0;

                Stopwatch watch = null;

                while (index < m_BreakCount && m_Queue.Count != 0)
                {
                    Timer        t    = m_Queue.Dequeue();
                    TimerProfile prof = t.GetProfile();

                    if (prof != null)
                    {
                        if (watch == null)
                        {
                            watch = Stopwatch.StartNew();
                        }
                        else
                        {
                            watch.Start();
                        }
                    }

                    t.OnTick();
                    t.m_Queued = false;
                    ++index;

                    if (prof != null)
                    {
                        prof.RegTicked(watch.Elapsed);
                        watch.Reset();
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public TimerProfile GetProfile()
        {
            if (!Core.Profiling)
            {
                return(null);
            }

            string name = ToString();

            if (name == null)
            {
                name = "null";
            }

            TimerProfile prof = (TimerProfile)m_Profiles[name];

            if (prof == null)
            {
                m_Profiles[name] = prof = new TimerProfile();
            }

            return(prof);
        }
Ejemplo n.º 15
0
 public TimerProfile GetProfile()
 {
     return(Core.Profiling ? TimerProfile.Acquire(ToString()) : null);
 }
Ejemplo n.º 16
0
		public TimerProfile GetProfile()
		{
			if ( !Core.Profiling )
				return null;

			string name = ToString();

			if ( name == null )
				name = "null";

			TimerProfile prof = (TimerProfile)m_Profiles[name];

			if ( prof == null )
				m_Profiles[name] = prof = new TimerProfile();

			return prof;
		}