HWHash 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package HWHash --version 1.2.0
NuGet\Install-Package HWHash -Version 1.2.0
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="HWHash" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HWHash --version 1.2.0
#r "nuget: HWHash, 1.2.0"
#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 HWHash as a Cake Addin
#addin nuget:?package=HWHash&version=1.2.0

// Install HWHash as a Cake Tool
#tool nuget:?package=HWHash&version=1.2.0

HWHash

Grab all HWiNFO realtime sensor information via shared memory and updates them directly to a easily accessible Dictionary.

N|Solid

GLWTPL

A tiny, singleton (static) class that reads HWiNFO Shared Memory and packs it to a Dictionary.

  • 🦄 Single file static class with no external dependencies.
  • 😲 Tiny footprint, no memory leaks and 0.01% CPU Usage.
  • 💨Blazing fast, <1millisecond to iterate over 300 sensors.
  • ✨It simply works.

Features

  • Unique ID for each sensor avoid duplicate name collision
  • Compatible with all HWiNFO versions with Shared Memory Support
  • Collects "Parent Sensor" information such as Name, ID and Instance
  • Hashes both the Sensor's Original name and the User Defined name
  • Exports sensor information in the same order HWiNFO UI
  • Exports to a List or JSON string in both Full and Minified versions *check the minified struct version below.

Installation

Nuget package is available:

NuGet\Install-Package HWHash -Version 1.1.0

Usage

It is as simple as:

HWHash.Launch();

Options

There are three startup options for HWHash.

Option Default
HighPrecision alternate text is missing from this package README image
HighPriority alternate text is missing from this package README image
Delay alternate text is missing from this package README image

How to configure

Make sure you set the parameters before Lauching the HWHash thread.

High Precision:

HWHash.HighPrecision = true;

High Priority:

HWHash.HighPriority = true;

Delay:

//update the Dictionary every 500ms (twice per second)
HWHash.SetDelay(500);

Then → Launch()

HWHash.HighPrecision = true;
HWHash.HighPriority = true;
HWHash.SetDelay(500);
HWHash.Launch();

Basic Functions

//Returns a List<HWINFO_HASH> in the same order as HWiNFO UI
List<HWiNFO_HASH> MyHWHashList = HWHash.GetOrderedList();
//Same as above but in a minified version
List<HWINFO_HASH_MINI> MyHWHashListMini = HWHash.GetOrderedListMini();

JSON Functions

//Returns a JSON string containing all sensors information (full/mini)
string _HWHashJson = HWHash.GetJsonString();
string _HWHashJsonMini = HWHash.GetJsonStringMini();
//If set to true, it will return a ordered list*
string _HWHashJsonOrdered = HWHash.GetJsonString(true);
//Same for the minified version
string _HWHashJsonMiniOrdered = HWHash.GetJsonStringMini(true);

Default Struct

This is the base struct, it contains all HWiNFO sensor data, such as min, max and avg values.

 public struct HWINFO_HASH
    {
        public string ReadingType { get; set; }
        public uint SensorIndex { get; set; }
        public uint SensorID { get; set; }
        public ulong UniqueID { get; set; }
        public string NameDefault { get; set; }
        public string NameCustom { get; set; }
        public string Unit { get; set; }
        public double ValueNow { get; set; }
        public double ValueMin { get; set; }
        public double ValueMax { get; set; }
        public double ValueAvg { get; set; }
        public string ParentNameDefault { get; set; }
        public string ParentNameCustom { get; set; }
        public uint ParentID { get; set; }
        public uint ParentInstance { get; set; }
        public ulong ParentUniqueID { get; set; }
        public int IndexOrder { get; set; }
    }

Minified Struct

The minified version is more suitable for 'realtime' monitoring, since it is packed in a much smaller package.

public struct HWINFO_HASH_MINI
    {
        public ulong UniqueID { get; set; }
        public string NameCustom { get; set; }
        public string Unit { get; set; }
        public double ValueNow { get; set; }
        [JsonIgnore(Condition = JsonIgnoreCondition.Always)]
        public int IndexOrder { get; set; }
    }

Performance

You can access HWHash performance metrics by invoking the following method:

HWHashStats _Stats = HWHash.GetHWHashStats();

HWHashStats struct

public struct HWHashStats
    {
        public long CollectionTime { get; set; }
        public uint TotalCategories { get; set; }
        public uint TotalEntries { get; set; }
    }

The most critical information we want to inspect is

...
long ProfilingTime = _Stats.CollectionTime;
...

On a decent modern system, even if there are over 300 sensors, profiling times should stay <1 millisecond. Which is not a concern since HWiNFO will flush new data with a minimum delay of 100ms between readings.

N|Solid

CollectionTime returns the time in milliseconds between each full loop, in the screenshot above, there are 359 distinct sensor readings.

We know that for Overclockers and Hardware enthusiasts, it is important to have fast, reliable and accurate readings, and a 1 millisecond overhead is well within what is considered a safe margin.

Notes on Sensor Poll Rate

This library relies on a third party application, which is HWiNFO, and HWiNFO relies on the exposed sensors from your hardware, such as motherboard sensors, CPU, GPU sensors, etc.

Usually sensor access/read is deadly fast (nanoseconds) and it is never a bottleneck. There are few rare examples, for instance, on my personal system I have 8 Corsair Memory sticks, and they have a temperature sensor on each stick, out of 359 different readings on my system, the DIMMs are the only ones who take more than nanoseconds to be read, in my case, HWiNFO takes around 6MS to poll the Memory Temperature from all chips.

Since HWiNFO fastest "poll rate" is 100MS, it is not a problem, but it is definitely something that we should keep an eye upon when reading from sensors exposed by our hardware.

License

This project is licensed under GLWTPL

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.3.0 88,024 4/2/2024
1.2.0 13,872 10/22/2022