AuroraRuntime/Include/Aurora/HWInfo/CpuLoadSampler.hpp

33 lines
1.4 KiB
C++

/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: CpuLoadSampler.hpp
Date: 2023-10-28
Author: Reece
Note: This API does not query system-wide CPU utilization
These APIs belong to the AuProcess subsystem just about as much as our memory-usage stat APIs do.
(I think it's fine to keep hardware perf query apis under AuHwInfo, even if they are process rel)
***/
#pragma once
namespace Aurora::HWInfo
{
struct ICpuLoadSampler
{
/**
* @brief
* @return a percentage (0 - 100; as a decimal) of the local process or thread CPU usage between ::GetLoad() calls, with respect to a uMinSamplePeriod averaging period.
*/
virtual double GetLoad() = 0;
};
AUKN_SHARED_SOO2_NCM(CpuLoadSampler, ICpuLoadSampler, 64,
((AuUInt32, uMinSamplePeriodMS), (bool, bThreadMode), (bool, bCountKernelUsage)),
AuUInt32 uMinSamplePeriodMS = AuSToMS<AuUInt32>(1), // May be zero
bool bThreadMode = false, // False = Sample Process Usage | True = Sample Thread Usage
bool bCountKernelUsage = false); // False = Ignore kernel work under our callstack
AUKN_SYM double GetProcessCPUUtilization();
AUKN_SYM double GetThreadCPUUtilization(AuOptional<bool> optIncludeKernel = { true });
}