private static void SetCpuDetails(CpuModel cpu) { ushort fms = (ushort)(cpu.CpuFamilyModelStepping.FullFamily * 0x100 + cpu.CpuFamilyModelStepping.FullModel); if (FamilyModel.X86FamilyModelSteppingTable.ContainsKey(fms)) { var fmsData = FamilyModel.X86FamilyModelSteppingTable[fms]; cpu.CodeName = fmsData.CodeName; cpu.Technology = fmsData.Technology; } }
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(); }
/// <summary> /// CPU /// </summary> /// <returns></returns> public CpuModel CPU() { var result = new CpuModel(); ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor"); foreach (ManagementObject queryObj in searcher.Get()) { result.AddressWidth = queryObj["AddressWidth"].ToString(); result.Caption = queryObj["Caption"].ToString(); } return(result); }
public static CpuDto ToDto(this CpuModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } return(new CpuDto { Brand = model.Brand, Caches = model.Caches.Select(c => c.ToDto()).ToList(), Features = model.Features, Frequency = model.Frequency, Smt = model.Smt, Vendor = model.Vendor, AdditionalInfo = model.AdditionalInfo }); }
private void BuildCPUCombinationList() { this.CPUList = new ObservableCollection <CpuModel>(); foreach (PerformanceSetting performanceSetting in Enum.GetValues(typeof(PerformanceSetting))) { CpuModel cpuModel = new CpuModel(); if (performanceSetting != PerformanceSetting.Custom) { string str1 = ""; switch (performanceSetting) { case PerformanceSetting.High: str1 = LocaleStrings.GetLocalizedString("STRING_HIGH", ""); cpuModel.CoreCount = Math.Min(this.currentUserSuppeortedVCpus, 4); break; case PerformanceSetting.Medium: str1 = LocaleStrings.GetLocalizedString("STRING_MEDIUM", ""); cpuModel.CoreCount = Math.Min(this.currentUserSuppeortedVCpus, 2); break; case PerformanceSetting.Low: str1 = LocaleStrings.GetLocalizedString("STRING_LOW", ""); cpuModel.CoreCount = Math.Min(this.currentUserSuppeortedVCpus, 1); break; } string str2 = cpuModel.CoreCount == 1 ? LocaleStrings.GetLocalizedString("STRING_CPU_CORE", "") : LocaleStrings.GetLocalizedString("STRING_CPU_CORES", ""); string str3 = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0} {1}", (object)cpuModel.CoreCount, (object)str2); cpuModel.CpuDisplayText = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0} {1}", (object)str1, (object)string.Format((IFormatProvider)CultureInfo.InvariantCulture, LocaleStrings.GetLocalizedString("STRING_BRACKETS_0", ""), (object)str3)); } else { cpuModel.CpuDisplayText = LocaleStrings.GetLocalizedString("STRING_CUSTOM1", ""); cpuModel.CoreCount = 1; } cpuModel.PerformanceSettingType = performanceSetting; this.CPUList.Add(cpuModel); } }
private static CpuCaches SetCaches(CpuModel cpu) { var cachesData = WindowsProcessor.GetCacheByLevel(); var caches = new CpuCaches(); if (cachesData.ContainsKey(1)) { var l1Cache = cachesData[1]; WindowsProcessor.SYSTEM_LOGICAL_PROCESSOR_INFORMATION?l1Data = l1Cache.FirstOrDefault(c => c.ProcessorInformation.Cache.Type == WindowsProcessor.PROCESSOR_CACHE_TYPE.CacheData); if (l1Data != null) { caches.Level1Data = MapCacheItem(l1Data, cpu.NumberOfCores); } WindowsProcessor.SYSTEM_LOGICAL_PROCESSOR_INFORMATION?l1Instruction = l1Cache.FirstOrDefault(c => c.ProcessorInformation.Cache.Type == WindowsProcessor.PROCESSOR_CACHE_TYPE.CacheInstruction); if (l1Instruction != null) { caches.Level1Instructions = MapCacheItem(l1Instruction, cpu.NumberOfCores); } } if (cachesData.ContainsKey(2)) { var l2Cache = cachesData[2]; caches.Level2 = MapCacheItem(l2Cache.FirstOrDefault(), cpu.NumberOfCores); } if (cachesData.ContainsKey(3)) { var l3Cache = cachesData[3]; caches.Level3 = MapCacheItem(l3Cache.FirstOrDefault()); } cpu.Caches = caches; return(caches); }
private CpuModel SetModelFamilyStepping(CpuModel cpu, string text) { if (!text.Contains("Family") || !text.Contains("Model") || !text.Contains("Stepping")) { cpu.CpuFamilyModelStepping = new CpuFamilyModelStepping() { FullFamily = 0, FullModel = 0, Stepping = 0 }; } var mfsCOmponents = text.Split(' '); cpu.CpuFamilyModelStepping = new CpuFamilyModelStepping() { FullFamily = byte.Parse(mfsCOmponents[2]), FullModel = byte.Parse(mfsCOmponents[4]), Stepping = byte.Parse(mfsCOmponents[6]) }; return(cpu); }
/// <summary> /// Build the RedisModel for dashboard presentation /// </summary> /// <param name="redisResult"></param> /// <returns></returns> public static RedisModel GetRedisModel(RedisResult redisResult) { if (redisResult == null) { // return an empty model return(new RedisModel()); } var dictionary = redisResult.ToCustomDictionary(); // build the ServerModel var serverModel = new ServerModel() { RedisVersion = dictionary["redis_version"], RedisMode = dictionary["redis_mode"], Os = dictionary["os"], Architecture = dictionary["arch_bits"], MultiplexingApi = dictionary["multiplexing_api"], UptimeDays = dictionary["uptime_in_days"] }; // build the ClientsModel var clientsModel = new ClientsModel() { ConnectedClients = dictionary["connected_clients"] }; // build the MemoryModel var memoryModel = new MemoryModel() { UsedMemory = GetPercentage(dictionary["used_memory_dataset_perc"], true) }; // build the CPU model var cpuModel = new CpuModel() { ServerLoad = GetPercentage(dictionary["server_load"]) }; // build the KeyspaceModel var keyspaceModel = new KeyspaceModel() { Hits = dictionary["keyspace_hits"], Misses = dictionary["keyspace_misses"], Expired = dictionary["expired_keys"] }; // build the CommandModel var commandModel = new CommandModel() { OperationPerSec = Convert.ToInt32(dictionary["instantaneous_ops_per_sec"]), BytesReceivedPerSec = Convert.ToInt32(dictionary["bytes_received_per_sec"]) }; var redisStatsModel = new RedisModel { ServerModel = serverModel, ClientsModel = clientsModel, MemoryModel = memoryModel, CpuModel = cpuModel, KeyspaceModel = keyspaceModel, CommandModel = commandModel }; return(redisStatsModel); }
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, } }); }
public ComputerModel GetAllData() { computer.Open(); computer.CpuEnabled = true; computer.MainboardEnabled = true; computer.RAMEnabled = true; computer.GPUEnabled = true; hardware = computer.Hardware; CpuModel[] cpus = new CpuModel[] { }; var hwd = hardware.OfType <GenericCPU>().ToArray(); var hwCpus = hwd.OfType <GenericCPU>(); var hwBios = hardware.OfType <Mainboard>()?.FirstOrDefault()?.BIOS; cpus = hwCpus.Select(cp => { var l1CacheData = cp.Caches.ContainsKey(CacheLevels.Level1) ? cp.Caches[CacheLevels.Level1].FirstOrDefault(ch => ch.CacheType == CacheType.Data) : null; var l1CacheInstructions = cp.Caches.ContainsKey(CacheLevels.Level1) ? cp.Caches[CacheLevels.Level1].FirstOrDefault(ch => ch.CacheType == CacheType.Instructions) : null; var l2Cache = cp.Caches.ContainsKey(CacheLevels.Level2) ? cp.Caches[CacheLevels.Level2].FirstOrDefault() : null; var l3Cache = cp.Caches.ContainsKey(CacheLevels.Level3) ? cp.Caches[CacheLevels.Level3].FirstOrDefault() : null; IntelCPU intelCpu = cp as IntelCPU; var specificCpu = (intelCpu != null) ? intelCpu : ((cp is AMDCPU amdCPu) ? amdCPu : cp); var cpuModel = new CpuModel() { Architecture = ArchitectureHelper.GetArchitecture((uint)(specificCpu.Is64bit ? 9 : 0), 0), Name = specificCpu.Name, CodeName = specificCpu.CodeName, Specification = cp.BrandString, NumberOfCores = (uint)cp.Cores, NumberOfLogicalProcessors = (uint)cp.Threads, Technology = cp.Technology, CpuClocks = new CpuClocks() { }, CpuFamilyModelStepping = new CpuFamilyModelStepping() { FullFamily = (byte)cp.Family, Family = (byte)cp.FamilyId, FullModel = (byte)cp.Model, Stepping = (byte)cp.Stepping, }, Instructions = GetInstructions(specificCpu, cp.InstructionsExtensions), Caches = new CpuCaches() { Level1Data = l1CacheData != null ? new CpuCacheItem() { Level = 1, Associativity = (byte)l1CacheData.Associativity, Size = l1CacheData.SizeKbytes * 1024, LineSize = l1CacheData.LineSize, NumberOfCores = (uint)cp.Cores } : new CpuCacheItem() { }, Level1Instructions = l1CacheInstructions != null ? new CpuCacheItem() { Level = 1, Associativity = (byte)l1CacheInstructions.Associativity, Size = l1CacheInstructions.SizeKbytes * 1024, LineSize = l1CacheInstructions.LineSize, NumberOfCores = (uint)cp.Cores } : new CpuCacheItem() { }, Level2 = l2Cache != null ? new CpuCacheItem() { Level = 2, Associativity = (byte)l2Cache.Associativity, Size = l2Cache.SizeKbytes * 1024, LineSize = l2Cache.LineSize, NumberOfCores = (uint)cp.Cores } : new CpuCacheItem() { }, Level3 = l3Cache != null ? new CpuCacheItem() { Level = 3, Associativity = (byte)l3Cache.Associativity, LineSize = l3Cache.LineSize, Size = l3Cache.SizeKbytes * 1024 } : new CpuCacheItem() { }, } }; SetCpuClocks(cp, hwBios, cpuModel.CpuClocks); return(cpuModel); }).ToArray(); Motherboard motherboard = null; if (hwBios != null && hwBios.Board != null) { motherboard = new Motherboard() { Manufacturer = hwBios.Board.ManufacturerName, Model = hwBios.Board.ProductName, Version = hwBios.Board.Version }; } else { motherboard = new Motherboard() { Manufacturer = string.Empty, Model = string.Empty, Version = string.Empty }; } Bios bios = null; if (hwBios != null && hwBios.BIOS != null) { bios = new Bios() { Brand = hwBios.BIOS.Vendor, Date = hwBios.BIOS.Date, Version = hwBios.BIOS.Version }; } else { bios = new Bios() { Brand = string.Empty, Date = string.Empty, Version = string.Empty }; } return(new ComputerModel() { Cpus = new AllCpus() { Cpus = cpus, RootCpu = cpus?[0], TotalOfCores = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfCores) : (cpus?[0]?.NumberOfCores ?? 0), TotalOfLogicalProcessors = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfLogicalProcessors) : (cpus?[0]?.NumberOfLogicalProcessors ?? 0), }, Motherboard = motherboard, Bios = bios }); }
private void PreloadDataFromCloneInstance(string vmName) { this.Dpi = Utils.GetDpiFromBootParameters(RegistryManager.RegistryManagers[this.OEM].Guest[vmName].BootParameters); if (this.Is64BitABIValuesValid()) { this.Is64BitABIValid = true; } string valueInBootParams = Utils.GetValueInBootParams("abivalue", vmName, string.Empty, this.OEM); if (!string.IsNullOrEmpty(valueInBootParams)) { if (this.Is64BitABIValuesValid()) { switch (valueInBootParams) { case "7": this.AbiValue = ABISetting.Auto64; break; case "15": this.AbiValue = ABISetting.ARM64; break; default: this.AbiValue = ABISetting.Custom; break; } } else { switch (valueInBootParams) { case "15": this.AbiValue = ABISetting.Auto; break; case "4": this.AbiValue = ABISetting.ARM; break; default: this.AbiValue = ABISetting.Custom; break; } } } else if (this.Is64BitABIValuesValid()) { Utils.UpdateValueInBootParams("abivalue", ABISetting.Auto64.GetDescription(), vmName, true, this.OEM); } else { Utils.UpdateValueInBootParams("abivalue", ABISetting.Auto.GetDescription(), vmName, true, this.OEM); } if (this.AbiValue == ABISetting.Custom) { this.IsCustomABI = true; } int currentCpucount = RegistryManager.RegistryManagers[this.OEM].CurrentEngine == "raw" ? 1 : RegistryManager.RegistryManagers[this.OEM].Guest[vmName].VCPUs; CpuModel cpuModel = this.CPUList.FirstOrDefault <CpuModel>((Func <CpuModel, bool>)(x => x.CoreCount == currentCpucount)); if (cpuModel == null) { cpuModel = this.CPUList.First <CpuModel>((Func <CpuModel, bool>)(x => x.PerformanceSettingType == PerformanceSetting.Custom)); cpuModel.CoreCount = currentCpucount; this.CoreCount = currentCpucount; } this.SelectedCPU = cpuModel; RamModel ramModel = this.RamList.FirstOrDefault <RamModel>((Func <RamModel, bool>)(x => x.RAM == RegistryManager.RegistryManagers[this.OEM].Guest[vmName].Memory)); if (ramModel == null) { ramModel = this.RamList.First <RamModel>((Func <RamModel, bool>)(x => x.PerformanceSettingType == PerformanceSetting.Custom)); ramModel.RAM = RegistryManager.RegistryManagers[this.OEM].Guest[vmName].Memory; } this.SelectedRAM = ramModel; ResolutionModel resolutionModel = this.ResolutionsList.FirstOrDefault <ResolutionModel>((Func <ResolutionModel, bool>)(x => x.AvailableResolutionsDict.Keys.Contains <string>(string.Format("{0} x {1}", (object)RegistryManager.RegistryManagers[this.OEM].Guest[vmName].GuestWidth, (object)RegistryManager.RegistryManagers[this.OEM].Guest[vmName].GuestHeight)))) ?? this.ResolutionsList.First <ResolutionModel>((Func <ResolutionModel, bool>)(x => x.OrientationType == OrientationType.Custom)); resolutionModel.CombinedResolution = string.Format("{0} x {1}", (object)RegistryManager.RegistryManagers[this.OEM].Guest[vmName].GuestWidth, (object)RegistryManager.RegistryManagers[this.OEM].Guest[vmName].GuestHeight); this.ResolutionType = resolutionModel; }
public static ResultDto ToDto(this ResultModel resultModel, CpuModel cpuModel, TopologyModel topologyModel) { if (resultModel == null) { throw new ArgumentNullException(nameof(resultModel)); } if (cpuModel == null) { throw new ArgumentNullException(nameof(cpuModel)); } if (topologyModel == null) { throw new ArgumentNullException(nameof(topologyModel)); } var resultDto = new ResultDto { TimeStamp = resultModel.TimeStamp, Id = resultModel.Id, Elpida = new ElpidaDto { Compiler = new CompilerDto { Name = resultModel.Elpida.Compiler.Name, Version = resultModel.Elpida.Compiler.Version }, Version = new VersionDto { Build = resultModel.Elpida.Version.Build, Major = resultModel.Elpida.Version.Major, Minor = resultModel.Elpida.Version.Minor, Revision = resultModel.Elpida.Version.Revision } }, Affinity = resultModel.Affinity.ToList(), Result = new BenchmarkResultDto { Name = resultModel.Result.Name, TaskResults = resultModel.Result.TaskResults.Select(d => new TaskResultDto { Description = d.Description, Name = d.Name, Suffix = d.Suffix, Time = d.Time, Type = d.Type, Value = d.Value, InputSize = d.InputSize, Outliers = d.Outliers.Select(o => o.ToDto()).ToList(), Statistics = d.Statistics.ToDto() }).ToList() }, System = new SystemDto { Os = new OsDto { Category = resultModel.System.Os.Category, Name = resultModel.System.Os.Name, Version = resultModel.System.Os.Version }, Cpu = cpuModel.ToDto(), Timing = resultModel.System.Timing.ToDto(), Memory = new MemoryDto { PageSize = resultModel.System.Memory.PageSize, TotalSize = resultModel.System.Memory.TotalSize }, Topology = topologyModel.ToDto(), } }; return(resultDto); }