iCPUID 1.0.1
See the version list below for details.
dotnet add package iCPUID --version 1.0.1
NuGet\Install-Package iCPUID -Version 1.0.1
<PackageReference Include="iCPUID" Version="1.0.1" />
paket add iCPUID --version 1.0.1
#r "nuget: iCPUID, 1.0.1"
// Install iCPUID as a Cake Addin
#addin nuget:?package=iCPUID&version=1.0.1
// Install iCPUID as a Cake Tool
#tool nuget:?package=iCPUID&version=1.0.1
What is iCPUID?
iCPUID is a lightweight implementation that allows us to obtain the CPUID information.
Usage
Call CPUID.Instance.Leafs for getting all CPUID implemented leafs.
Examples
Detection of the availability of the CPUID instruction.
CPUID cpuid = CPUID.Instance; Console.WriteLine($@" Is Available > {cpuid.IsAvailable}");
Gets and prints all CPUID implemented leafs.
CPUID cpuid = CPUID.Instance; ReadOnlyCollection<Leaf> leafs = cpuid.ImplementedLeafs; foreach (Leaf leaf in leafs) { Console.WriteLine($@" {(int)leaf:X8}-{leaf}"); }
Gets and prints all CPUID implemented leafs > sub-leafs.
CPUID cpuid = CPUID.Instance; ReadOnlyCollection<Leaf> leafs = cpuid.ImplementedLeafs; foreach (var (leaf, subLeafs) in leafs) { Console.WriteLine($@" > {leaf} (EAX={(int)leaf:X8})"); foreach (var subLeaf in subLeafs) { Console.WriteLine($@" > {subLeaf.SubLeaf} (ECX={(int)subLeaf.SubLeaf:X8})"); } }
Gets and prints all CPUID implemented leafs > sub-leafs (shows description).
CPUID cpuid = CPUID.Instance; ReadOnlyCollection<Leaf> leafs = cpuid.ImplementedLeafs; foreach (var (leaf, subLeafs) in leafs) { Console.WriteLine($@" > {leaf} (EAX={(int)leaf:X8})"); foreach (var subLeaf in subLeafs) { Console.WriteLine($@" > {subLeaf.SubLeaf} (ECX={(int)subLeaf.SubLeaf:X8})"); IEnumerable<IPropertyKey> properties = subLeaf.ImplementedProperties; foreach (var property in properties) { string friendlyName = GetFriendlyName(property); PropertyUnit unit = property.PropertyUnit; string description = property.GetPropertyDescription(); Console.WriteLine($@" > {friendlyName} {(unit == PropertyUnit.None ? string.Empty : $"({unit})")}: {description}"); } } }
Gets and prints all CPUID implemented leafs > sub-leafs (values).
CPUID cpuid = CPUID.Instance; ReadOnlyCollection<Leaf> leafs = cpuid.ImplementedLeafs; foreach (var (leaf, subLeafs) in leafs) { Console.WriteLine($@" > {leaf} (EAX={(int)leaf:X8})"); foreach (var subLeaf in subLeafs) { Console.WriteLine($@" > {subLeaf.SubLeaf} (ECX={(int)subLeaf.SubLeaf:X8})"); IEnumerable<IPropertyKey> properties = subLeaf.ImplementedProperties; foreach (var property in properties) { QueryPropertyResult queryResult = subLeaf.GetProperty(property); PropertyItem propertyItem = queryResult.Value; object value = propertyItem.Value; string friendlyName = GetFriendlyName(property); PropertyUnit valueUnit = property.PropertyUnit; string unit = valueUnit == PropertyUnit.None ? string.Empty : valueUnit.ToString(); if (value == null) { Console.WriteLine($@" > {friendlyName}: NULL"); continue; } if (value is bool) { Console.WriteLine($@" > {friendlyName}: {value} [{((bool)value ? 1 : 0)}]"); } else if (value is string) { Console.WriteLine($@" > {friendlyName}: {value} {unit}"); } else if (value is byte) { Console.WriteLine($@" > {friendlyName}: {value} {unit} [{value:X2}h]"); } else if (value is int) { Console.WriteLine($@" > {friendlyName}: {value} {unit} [{value:X4}h]"); } else if (value is uint) { Console.WriteLine($@" > {friendlyName}: {value} {unit} [{value:X4}h]"); } else if (value is ulong) { Console.WriteLine($@" > {friendlyName}: {value} {unit} [{value:X8}h]"); } else if (value.GetType() == typeof(ReadOnlyCollection<string>)) { Console.WriteLine($@" > {friendlyName}"); var collection = (ReadOnlyCollection<string>)value; foreach (var entry in collection) { Console.WriteLine($@" > {entry} {unit}"); } } else { Console.WriteLine($@" > {friendlyName}: {value} {unit}"); } } } }
Gets a single property directly.
CPUID cpuid = CPUID.Instance; QueryPropertyResult manufacturerQueryResult = cpuid.Leafs.GetProperty(LeafProperty.BasicInformation.Manufacturer); if (manufacturerQueryResult.Success) { Console.WriteLine($@" > Manufacturer: {manufacturerQueryResult.Value.Value}"); } QueryPropertyResult avx2 = cpuid.Leafs.GetProperty(LeafProperty.ExtendedFeatures.AVX2); if (avx2.Success) { Console.WriteLine($@" > AVX2: {avx2.Value.Value}"); }
Gets a property in multiple elements directly.
CPUID cpuid = CPUID.Instance; QuerySubLeafPropertyCollectionResult cacheSizesQueryResult = leafs.GetProperties(LeafProperty.DeterministicCacheParameters.CacheSize); if (cacheSizesQueryResult.Success) { CpuidSubLeafDictionary cacheSizes = cacheSizesQueryResult.Value; bool hasCacheSizesEntries = cacheSizes.Any(); if (!hasCacheSizesEntries) { Console.WriteLine($@" > Sorry, The 'LeafProperty.DeterministicCacheParameters.CacheSize' property has not implementes on this system"); } else { foreach (var (subLeaf, propertyItem) in cacheSizes) { Console.WriteLine($@" > Cache Size: ({subLeaf}) > {propertyItem.Value}"); } } }
Changes
For more information, please visit the next link CHANGELOG
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard netstandard1.0 netstandard1.1 netstandard1.2 netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1 |
.NET Framework | net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48 net481 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen30 tizen40 tizen60 |
Universal Windows Platform | uap uap10.0 |
Windows Phone | wp8 wp81 wpa81 |
Windows Store | netcore netcore45 netcore451 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETCoreApp 2.0
- No dependencies.
-
.NETCoreApp 2.1
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.