예제 #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;
        }
예제 #2
0
        public void Start()
        {
            if (!m_Running)
            {
                m_Running = true;
                TimerThread.AddTimer(this);

                TimerProfile prof = GetProfile();

                if (prof != null)
                {
                    prof.Started++;
                }
            }
        }
예제 #3
0
        public void Stop()
        {
            if (m_Running)
            {
                m_Running = false;
                TimerThread.RemoveTimer(this);

                TimerProfile prof = GetProfile();

                if (prof != null)
                {
                    prof.Stopped++;
                }
            }
        }
예제 #4
0
        public TimerProfile GetProfile()
        {
            if (!Core.Profiling)
            {
                return(null);
            }

            string name = ToString();

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

            return(TimerProfile.Acquire(name));
        }
예제 #5
0
        public void Stop()
        {
            if (m_Running)
            {
                m_Running = false;

                m_Scheduler.RemoveTimer(this);

                TimerProfile prof = this.GetProfile();

                if (prof != null)
                {
                    prof.RegStopped();
                }
            }
        }
예제 #6
0
        public void Start()
        {
            if (!m_Running)
            {
                m_Running = true;

                m_Scheduler.AddTimer(this);

                TimerProfile prof = this.GetProfile();

                if (prof != null)
                {
                    prof.RegStart();
                }
            }
        }
예제 #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();
        }
예제 #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
            }
        }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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();
                    }
                }
            }
        }
예제 #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);
        }
예제 #15
0
파일: Timer.cs 프로젝트: Tauriella/ServUO-1
 public TimerProfile GetProfile()
 {
     return(Core.Profiling ? TimerProfile.Acquire(ToString()) : null);
 }
예제 #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;
		}