Thank you all for the 12k+ downloads on the alpha ver! And a big thanks for the 1,400+ nuget downloads on this current ver!
A tiny, singleton (static) class that reads HWiNFO Shared Memory and packs it to a Dictionary.
Nuget package is available:
NuGet\Install-Package HWHash
It is as simple as:
HWHash.Launch();
There are three startup options for HWHash.
Option | Default |
---|---|
HighPrecision | |
HighPriority | |
Delay |
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();
//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();
//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);
This is the base struct, it contains all HWiNFO sensor data, such as min, max and avg values.
public record 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; }
}
The minified version is more suitable for 'realtime' monitoring, since it is packed in a much smaller package.
public record 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; }
}
In case you want to invoke HWHash from PowerShell, it is possible to do so, follow the steps below:
#Don't forget to change the line below
$Path = "A:\GITHUB\HWHash\bin\Debug\net6.0\HWHash.dll"
$ClassName = "HWHash"
$MethodLaunch = "Launch"
$MethodJsonStringMini = "GetJsonStringMini"
Add-Type -Path $Path
$Type = [System.Reflection.Assembly]::LoadFrom($Path).GetTypes() | Where-Object { $_.Name -eq $ClassName }
if ($Type -ne $null) {
$Instance = [Activator]::CreateInstance($Type)
$Type.GetMethod($MethodLaunch).Invoke($Instance, $null)
function Get-JsonStringMini {
param (
[bool]$Order = $false
)
$result = $Type.GetMethod($MethodJsonStringMini).Invoke($Instance, @($Order))
Write-Host $result
}
Get-JsonStringMini -Order $true
} else {
Write-Host "Type '$ClassName' not found in the assembly."
}
Result:
You can access HWHash performance metrics by invoking the following method:
HWHashStats _Stats = HWHash.GetHWHashStats();
HWHashStats struct
public record 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.
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.
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 am currently using Corsair Vengeance memory sticks, and each memory stick has a temperature sensor, 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 50MS, it is not a problem, but it is definitely something that we should keep an eye on when reading from sensors exposed by our hardware.
CruelMonitor was built using HWHash as its 'data provider.' CruelMonitor uses C# backend data source, it also serves as a WebSockets server to share the content in realtime, messages packed with MessagePack and are delivered with minimal delays.
Performance metrics are drawed directly on the Windows Desktop, 60FPS, <1ms delay and low CPU usage.
This project is licensed under GLWTPL