2023-10-28 15:00:57 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2024-11-16 15:23:41 +00:00
|
|
|
File: AuCpuLoadSampler.hpp
|
2023-10-28 15:00:57 +00:00
|
|
|
Date: 2023-10-28
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Aurora::HWInfo
|
|
|
|
{
|
2024-11-16 15:23:41 +00:00
|
|
|
struct ProcessLoadSamplerState
|
2023-10-28 15:00:57 +00:00
|
|
|
{
|
2023-10-29 20:56:48 +00:00
|
|
|
double GetLoad(AuUInt32 uMinSamplePeriod, bool bThread, bool bCountKernelUsage);
|
2023-10-28 15:00:57 +00:00
|
|
|
|
|
|
|
AuUInt64 uPrevTimes[2] {};
|
|
|
|
double dPrevLoad {};
|
2023-12-08 10:26:12 +00:00
|
|
|
bool bSet {};
|
2023-10-28 15:00:57 +00:00
|
|
|
};
|
|
|
|
|
2024-11-16 15:23:41 +00:00
|
|
|
struct ProcessLoadSamplerImpl : IProcessLoadSampler
|
2023-10-28 15:00:57 +00:00
|
|
|
{
|
2024-11-16 15:23:41 +00:00
|
|
|
ProcessLoadSamplerImpl(AuUInt32 uMinSamplePeriodMS,
|
2023-10-29 20:56:48 +00:00
|
|
|
bool bThreadMode,
|
|
|
|
bool bCountKernelUsage);
|
2023-10-28 15:00:57 +00:00
|
|
|
|
2024-11-16 15:23:41 +00:00
|
|
|
~ProcessLoadSamplerImpl();
|
2023-10-28 15:00:57 +00:00
|
|
|
|
|
|
|
double GetLoad() override;
|
|
|
|
|
|
|
|
AuUInt32 uMinSamplePeriod {};
|
|
|
|
bool bThreadMode {};
|
2023-10-29 20:56:48 +00:00
|
|
|
bool bCountKernelUsage {};
|
2024-11-16 15:23:41 +00:00
|
|
|
ProcessLoadSamplerState processState;
|
|
|
|
AuTLSVariable<ProcessLoadSamplerState> threadState;
|
2023-10-28 15:00:57 +00:00
|
|
|
};
|
|
|
|
}
|