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; }
public void Start() { if (!m_Running) { m_Running = true; TimerThread.AddTimer(this); TimerProfile prof = GetProfile(); if (prof != null) { prof.Started++; } } }
public void Stop() { if (m_Running) { m_Running = false; TimerThread.RemoveTimer(this); TimerProfile prof = GetProfile(); if (prof != null) { prof.Stopped++; } } }
public TimerProfile GetProfile() { if (!Core.Profiling) { return(null); } string name = ToString(); if (name == null) { name = "null"; } return(TimerProfile.Acquire(name)); }
public void Stop() { if (m_Running) { m_Running = false; m_Scheduler.RemoveTimer(this); TimerProfile prof = this.GetProfile(); if (prof != null) { prof.RegStopped(); } } }
public void Start() { if (!m_Running) { m_Running = true; m_Scheduler.AddTimer(this); TimerProfile prof = this.GetProfile(); if (prof != null) { prof.RegStart(); } } }
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(); }
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 } }
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); } }
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); }
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); }
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); }
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(); } } } }
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); }
public TimerProfile GetProfile() { return(Core.Profiling ? TimerProfile.Acquire(ToString()) : null); }
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; }