public void StoppedTest() { TimerProfile target = new TimerProfile(); // TODO: 初始化为适当的值 int actual; actual = target.Stopped; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public void TotalProcTimeTest() { TimerProfile target = new TimerProfile(); // TODO: 初始化为适当的值 TimeSpan actual; actual = target.TotalProcTime; Assert.Inconclusive( "验证此测试方法的正确性。" ); }
/// <summary> /// 给出某种时间片的处理信息 /// </summary> /// <returns></returns> public TimerProfile GetProfile() { if (OneServer.Profiling == false) { return(null); } string strName = ToString(); if (strName == null || strName == string.Empty) { strName = "null"; } TimerProfile timerProfile = s_Profiles.GetValue(strName); if (timerProfile == null) { timerProfile = new TimerProfile(); s_Profiles.Add(strName, timerProfile); } return(timerProfile); }
/// <summary> /// 运行时间片(Lowest 调度优先级) /// </summary> private static bool Slice_Lowest() { if (s_LowestTimeSliceQueue.Count <= 0) { return(false); } TimeSlice[] timeSliceArray = null; // 使用数组减少锁定时间 s_LockLowestTimeSliceQueue.Enter(); { if (s_LowestTimeSliceQueue.Count > 0) { // 时间片先进先出列队集合的数量(和中断处理比较) long iQueueCountAtSlice = s_LowestTimeSliceQueue.Count; if (iQueueCountAtSlice <= s_BreakSliceAtNumber) { timeSliceArray = s_LowestTimeSliceQueue.ToArray(); s_LowestTimeSliceQueue.Clear(); } else { timeSliceArray = new TimeSlice[s_BreakSliceAtNumber]; for (long iIndex = 0; iIndex < s_BreakSliceAtNumber; iIndex++) { timeSliceArray[iIndex] = s_LowestTimeSliceQueue.Dequeue(); } // 如果没有全部处理完,再发一次事件消息,让下一个线程来处理 } } } s_LockLowestTimeSliceQueue.Exit(); if (timeSliceArray == null) { return(false); } Stopwatch stopWatch = null; for (int iIndex = 0; iIndex < timeSliceArray.Length; iIndex++) { TimeSlice timeSlice = timeSliceArray[iIndex]; // 线程安全的 TimerProfile timerProfile = timeSlice.GetProfile(); if (timerProfile != null) { if (stopWatch == null) { stopWatch = Stopwatch.StartNew(); } else { stopWatch.Start(); } } timeSlice.OnTick(); timeSlice.m_InQueued = false; // 表示当前已不在列表中,用于在TimerThread线程中检测,如果已在列表中则不许要再次加入了 if (timerProfile != null) { timerProfile.RegTicked(stopWatch.Elapsed); stopWatch.Reset(); } } return(true); }
public void TimerProfileConstructorTest() { TimerProfile target = new TimerProfile(); Assert.Inconclusive( "TODO: 实现用来验证目标的代码" ); }
public void RegCreationTest() { TimerProfile target = new TimerProfile(); // TODO: 初始化为适当的值 target.RegCreation(); Assert.Inconclusive( "无法验证不返回值的方法。" ); }
public void RegTickedTest() { TimerProfile target = new TimerProfile(); // TODO: 初始化为适当的值 TimeSpan procTime = new TimeSpan(); // TODO: 初始化为适当的值 target.RegTicked( procTime ); Assert.Inconclusive( "无法验证不返回值的方法。" ); }