예제 #1
0
        private static void TimerElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            var cpuUsage = CpuMonitor.Instance.GetUsage();

            if (cpuUsage > HighestCpuUsage)
            {
                HighestCpuUsage = cpuUsage;
            }

            if (CpuUsageSamples.Count > 60 * 60)
            {
                CpuUsageSamples.RemoveAt(0);
            }

            CpuUsageSamples.Insert(0, CpuMonitor.Instance.GetUsage());

            var apps = Math.Max(1, YiCore.ActualPacketsPerSecond);
            var pps  = Math.Max(1, YiCore.PacketsPerSecond);

            ServerProcess.Refresh();
            var increase = Math.Max(100, (float)Math.Max(1, Math.Round(pps / (float)apps, 2) * 100));

            UserInterface.Reference.Invoke(new MethodInvoker(delegate
            {
                UserInterface.Reference.label8.Text  = YiScheduler.Instance.WorkItemCount.ToString();
                UserInterface.Reference.label10.Text = $@"{increase}% ({pps}->{apps})";
                UserInterface.Reference.label12.Text = $@"{GCMonitor.Get(0)},{GCMonitor.Get(1)},{GCMonitor.Get(2)} = {GCMonitor.Get(-1)}";
                UserInterface.Reference.label11.Text = $@"{ServerProcess.WorkingSet64 / 1024 / 1024} MB Private: {ServerProcess.PrivateMemorySize64 / 1024 / 1024} MB";
                UserInterface.Reference.label13.Text = $@"Current: {cpuUsage:00.00}%    Avg: {AverageCpuUsage:00.00}%   Max: {HighestCpuUsage:00.00}%";
                UserInterface.Reference.label14.Text = $@"Current: {cpuUsage / Environment.ProcessorCount:00.00}%    Avg: {AverageCpuUsage / Environment.ProcessorCount:00.00}%   Max: {HighestCpuUsage / Environment.ProcessorCount:00.00}%";
            }));
        }
예제 #2
0
 public static void Start()
 {
     GCMonitor.Calibrate();
     PacketTimer          = new Timer(1000);
     PacketTimer.Elapsed += TimerElapsed;
     PacketTimer.Start();
 }