iCPUID 1.0.6

dotnet add package iCPUID --version 1.0.6                
NuGet\Install-Package iCPUID -Version 1.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="iCPUID" Version="1.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add iCPUID --version 1.0.6                
#r "nuget: iCPUID, 1.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install iCPUID as a Cake Addin
#addin nuget:?package=iCPUID&version=1.0.6

// Install iCPUID as a Cake Tool
#tool nuget:?package=iCPUID&version=1.0.6                

What is iCPUID?

iCPUID is a lightweight cross-platform implementation that allows us to obtain the CPUID information.

Works on Windows, Mac and Linux

Usage

Call CPUID.Instance.Leafs for getting all CPUID implemented leafs.

For more info, please see CHANGELOG file.

Examples

  1. Detection of the availability of the CPUID instruction.

    CPUID cpuid = CPUID.Instance;
    Console.WriteLine($@" Is Available > {cpuid.IsAvailable}");
    
  2. 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}");
    }
    
  3. 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})");
        }
    }
    
  4. 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}");
            }
        }
    }
    
  5. 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}");
                }
            }
        }
    }
    
  6. 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}");
    }
    
  7. 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}");
            }
        }
    }
    

Documentation

  • For full code documentation, please see next link documentation.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard is compatible.  netstandard1.0 was computed.  netstandard1.1 was computed.  netstandard1.2 was computed.  netstandard1.3 was computed.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wp8 was computed.  wp81 was computed.  wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.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.

Version Downloads Last updated
1.0.6 357 1/4/2024
1.0.5 1,468 10/15/2022
1.0.4 423 10/13/2022
1.0.3 569 12/11/2020
1.0.2 445 10/12/2020
1.0.1 438 10/9/2020