Пример #1
0
        private void UpdateCpuValues(object sender)
        {
            // Update CPU utilisation values
            Array.Copy(Utilisation, 1, Utilisation, 0, Utilisation.Length - 1);
            Utilisation[Utilisation.Length - 1] = _cpuModel.PercentageProcessorTimeCounter.NextValue();

            Array.Copy(KernalUtilisation, 1, KernalUtilisation, 0, KernalUtilisation.Length - 1);
            KernalUtilisation[KernalUtilisation.Length - 1] = _cpuModel.PercentagePrivilegedTimeCounter.NextValue();
            ;

            CurrentUtilisation = (int)Utilisation.LastOrDefault();

            // Update CPU speed
            var maxSpeed = MaxSpeed / 1000;

            Speed = maxSpeed * _cpuModel.PercentagePerformanceCounter.NextValue() / 100;

            // Update process, thread and handles count
            var procs = Process.GetProcesses();

            Processes = procs.Length;
            Threads   = procs.Sum(p => p.Threads.Count);
            Handles   = procs.Sum(p => p.HandleCount);

            // Get the system up time
            UpTime = TimeSpan.FromSeconds(_cpuModel.SystemUpTimeCounter.NextValue());
        }
Пример #2
0
 public void MyTestInitialize()
 {
     app1     = new Appareil("Ampoule 100 Watts", 100);
     app2     = new Appareil("Plinthe chauffante", 1000);
     ampoule1 = new Utilisation(600, app1);
     ampoule2 = new Utilisation(90, app1);
     plinthe  = new Utilisation(60, app2);
 }