コード例 #1
0
        static void Main(string[] args)
        {
            CpuCollection cpus = Simplified.Environment.CPUv.GetCPUs();

            Console.WriteLine("Total CPUs: " + cpus.TotalCpu);
            Console.WriteLine("Total Cores: " + cpus.TotalCores);
            Console.WriteLine("Total Logical Cores: " + cpus.TotalLogicalCores);

            Console.WriteLine();
            foreach (var cpu in cpus)
            {
                Console.WriteLine("--------------------------------------------------------------------------------");
                Console.WriteLine($"CPU Name: {cpu.Name}");
                Console.WriteLine($"Cores per CPU: {cpu.CoreCount}");
                Console.WriteLine($"Threads per CPU: {cpu.LogicalCoreCount}");
                Console.WriteLine($"Load: {cpu.LoadPercentage}%");
                Console.WriteLine($"Clock Speed: {cpu.CurrentClockSpeed}Mhz");
            }

            Console.ReadLine();
        }
コード例 #2
0
        private void UpdateTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            var collection = new CpuCollection();

            foreach (var s in _instances)
            {
                _performanceCounter.InstanceName = s;

                var calculation = Calculate(_counterSamples[s], _performanceCounter.NextSample());
                var load        = calculation > 0 ? (int)calculation : 0;

                if (s.Contains("Total"))
                {
                    collection.Total = new SingleCpu()
                    {
                        Id   = 0,
                        Load = load
                    };
                }

                else
                {
                    var cpuId  = int.Parse(s.Substring(s.Length - 1, 1));
                    var newCpu = new SingleCpu
                    {
                        Load = load,
                        Id   = cpuId
                    };

                    collection.SingleCpu.Add(newCpu);
                }

                _counterSamples[s] = _performanceCounter.NextSample();
            }

            if (Update != null)
            {
                Update(this, new CpuUpdateEventArgs(collection));
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: kneave/HardwareProviders
        private static void Main(string[] args)
        {
            var cpus = new CpuCollection();

            while (true)
            {
                foreach (var cpu in cpus)
                {
                    cpu.Update();
                    Console.WriteLine("CPU {0} by {1}", cpu.Name, cpu.Vendor);

                    Console.WriteLine("Bus clock {0}", cpu.BusClock);
                    Console.WriteLine("Core temperatures {0}", SensorsToString(cpu.CoreTemperatures));
                    Console.WriteLine("Core powers {0}", SensorsToString(cpu.CorePowers));
                    Console.WriteLine("Core clocks {0}", SensorsToString(cpu.CoreClocks));

                    Console.WriteLine();
                    Console.WriteLine("Core loads {0}", SensorsToString(cpu.CoreLoads));
                    Console.WriteLine("Total load {0}", cpu.TotalLoad);
                }

                Task.Delay(2000).Wait();
            }
        }
コード例 #4
0
 public CpuUpdateEventArgs(CpuCollection collection)
 {
     Data = collection;
 }
コード例 #5
0
 public CpuUpdateEventArgs(CpuCollection collection)
 {
     Data = collection;
 }
コード例 #6
0
 public CpuApi(CpuCollection collection)
 {
     _collection = collection;
 }