private void SetSupportedInstructions(CpuModel cpu, ushort architecture) { var cpuFeatures = WindowsProcessor.GetSupportedInstructions().ToList(); if (architecture == 9) { cpuFeatures.Add(cpu.Manufacturer == "GenuineIntel" ? "EM64T" : "x86-64"); } cpu.Instructions = cpuFeatures.ToArray(); }
public ComputerModel GetAllData() { CpuModel[] cpus = null; try { var cpusProperties = devicePropertiesAdapter.GetMultipleProperties("Win32_Processor"); cpus = cpusProperties.Select(cp => { var cpu = new CpuModel() { Specification = cp["Name"].ToString() ?? "Unknown", CpuClocks = new CpuClocks() { CoreSpeed = cp["CurrentClockSpeed"] != null ? Convert.ToSingle((uint)(cp["CurrentClockSpeed"])) : 0f, BusSpeed = cp["ExtClock"] != null ? Convert.ToSingle((uint)(cp["ExtClock"])) : 0f, }, NumberOfCores = cp["NumberOfCores"] != null ? (uint)(cp["NumberOfCores"]) : 1, NumberOfLogicalProcessors = cp["NumberOfLogicalProcessors"] != null ? (uint)(cp["NumberOfLogicalProcessors"]) : 1, Architecture = ArchitectureHelper.GetArchitecture((ushort)cp["Architecture"], (ushort)cp["DataWidth"]), Manufacturer = cp["Manufacturer"]?.ToString() }; cpu = SetModelFamilyStepping(cpu, cp["Caption"].ToString()); SetSupportedInstructions(cpu, (ushort)cp["Architecture"]); SetCaches(cpu); SetCpuDetails(cpu); return(cpu); }).ToArray(); WindowsProcessor.GetSupportedInstructions(); } finally { if (cpus == null || cpus.Length == 0) { cpus = new CpuModel[] { new CpuModel() { CpuClocks = new CpuClocks() { }, Caches = new CpuCaches() { Level1Data = new CpuCacheItem(), Level1Instructions = new CpuCacheItem(), Level2 = new CpuCacheItem(), Level3 = new CpuCacheItem() }, CpuFamilyModelStepping = new CpuFamilyModelStepping() { } }, }; } } return(new ComputerModel() { Cpus = new AllCpus() { Cpus = cpus, RootCpu = cpus[0], TotalOfCores = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfCores) : cpus[0].NumberOfCores, TotalOfLogicalProcessors = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfLogicalProcessors) : cpus[0].NumberOfLogicalProcessors, } }); }