[*] :/
This commit is contained in:
parent
ad5ff2d783
commit
8005b67d82
@ -41,13 +41,13 @@ namespace Aurora::Async
|
||||
|
||||
AUKN_SYM AuSPtr<IAsyncTimer> NewTimer(AuUInt64 uPeriodNS,
|
||||
const AuSPtr<IAsyncTimerCallback> &pCallback,
|
||||
AuOptional<WorkerPId_t> workerPid,
|
||||
AuOptional<AuUInt64> uStartTime);
|
||||
AuOptional<WorkerPId_t> workerPid = {},
|
||||
AuOptional<AuUInt64> uStartTime = {});
|
||||
|
||||
AUKN_SYM AuSPtr<IAsyncTimer> NewTimer(AuUInt64 uPeriodNS,
|
||||
const AuSupplierConsumer<bool, AuUInt64, AuUInt64, AuUInt64> &callback,
|
||||
AuOptional<WorkerPId_t> workerPid,
|
||||
AuOptional<AuUInt64> uStartTime);
|
||||
AuOptional<WorkerPId_t> workerPid = {},
|
||||
AuOptional<AuUInt64> uStartTime = {});
|
||||
|
||||
static inline AuSPtr<IWorkItem> DispatchOn(const WorkerPId_t &worker, AuVoidFunc func)
|
||||
{
|
||||
|
@ -58,46 +58,93 @@ namespace Aurora::HWInfo
|
||||
double dDeltaProcess = now[1] - this->uPrevTimes[1];
|
||||
double dUsage = 0;
|
||||
double dMinSamplePeriod = double(AuMSToNS<AuUInt64>(uMinSamplePeriod));
|
||||
double dDeltaSteady2;
|
||||
double dThreads = 1.0;
|
||||
|
||||
if (bThread)
|
||||
{
|
||||
dThreads = GetCPUInfo().uThreads;
|
||||
dDeltaSteady2 = dDeltaSteady * dThreads;
|
||||
}
|
||||
else
|
||||
{
|
||||
dDeltaSteady2 = dDeltaSteady;
|
||||
}
|
||||
|
||||
if (!bool(this->uPrevTimes[0]))
|
||||
{
|
||||
this->uPrevTimes[1] = now[1];
|
||||
this->uPrevTimes[0] = now[0];
|
||||
this->uPrevTimes[1] = now[1];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!uMinSamplePeriod ||
|
||||
dDeltaSteady >= dMinSamplePeriod)
|
||||
(dDeltaSteady >= dMinSamplePeriod))
|
||||
{
|
||||
dUsage = dDeltaProcess / dDeltaSteady;
|
||||
dUsage = dDeltaProcess / dDeltaSteady2;
|
||||
this->uPrevTimes[1] = now[1];
|
||||
this->uPrevTimes[0] = now[0];
|
||||
#if 1
|
||||
if (uMinSamplePeriod &&
|
||||
this->dPrevLoad) dUsage = AuMin(dUsage, dUsage + this->dPrevLoad / 2.0);
|
||||
#endif
|
||||
if (uMinSamplePeriod)
|
||||
{
|
||||
if (dUsage > AuNumericLimits<double>::epsilon() &&
|
||||
this->dPrevLoad > AuNumericLimits<double>::epsilon())
|
||||
{
|
||||
dUsage = AuMin(dUsage, dUsage + this->dPrevLoad / 2.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
dUsage = AuMax(this->dPrevLoad / 2.0, 0.0001);
|
||||
}
|
||||
}
|
||||
else if (!dUsage)
|
||||
{
|
||||
dUsage = AuMax(this->dPrevLoad / 2.0, 0.0001);
|
||||
}
|
||||
this->dPrevLoad = dUsage;
|
||||
this->bSet = true;
|
||||
}
|
||||
else
|
||||
else if (!dDeltaProcess &&
|
||||
!this->bSet)
|
||||
{
|
||||
dUsage = dDeltaProcess / dDeltaSteady;
|
||||
// well, we obviously have some uptime. but how much?
|
||||
auto uDeltaNS = AuMin(dDeltaSteady, dMinSamplePeriod);
|
||||
|
||||
if (uDeltaNS > AuMSToNS<double>(1000 / 250))
|
||||
{
|
||||
uDeltaNS = 100;
|
||||
}
|
||||
|
||||
dUsage = uDeltaNS / dDeltaSteady2;
|
||||
}
|
||||
else if (dDeltaProcess &&
|
||||
!this->bSet)
|
||||
{
|
||||
dUsage = dDeltaProcess / dDeltaSteady2;
|
||||
}
|
||||
else if (dDeltaProcess)
|
||||
{
|
||||
dUsage = dDeltaProcess / dDeltaSteady2;
|
||||
#if 0
|
||||
dUsage *= dDeltaSteady / double(dMinSamplePeriod);
|
||||
dUsage *= dDeltaSteady2 / double(dMinSamplePeriod);
|
||||
if (this->dPrevLoad) dUsage = dUsage + this->dPrevLoad / 2.0;
|
||||
#else
|
||||
if (this->dPrevLoad)
|
||||
{
|
||||
double dFrameDelta = dDeltaSteady / double(dMinSamplePeriod);
|
||||
double dFrameDeltaInverse = 1.0 - dFrameDelta;
|
||||
auto dFrameDelta = dDeltaSteady / dMinSamplePeriod;
|
||||
auto dFrameDeltaInverse = 1.0 - dFrameDelta;
|
||||
dUsage *= dFrameDelta;
|
||||
dUsage += this->dPrevLoad * dFrameDeltaInverse;
|
||||
}
|
||||
else
|
||||
{
|
||||
dUsage *= dDeltaSteady / double(dMinSamplePeriod);
|
||||
dUsage *= dDeltaSteady / dMinSamplePeriod;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
dUsage = this->dPrevLoad;
|
||||
}
|
||||
|
||||
{
|
||||
dUsage = dUsage * 100.0;
|
||||
|
@ -15,6 +15,7 @@ namespace Aurora::HWInfo
|
||||
|
||||
AuUInt64 uPrevTimes[2] {};
|
||||
double dPrevLoad {};
|
||||
bool bSet {};
|
||||
};
|
||||
|
||||
struct CpuLoadSamplerImpl : ICpuLoadSampler
|
||||
|
@ -254,6 +254,9 @@ namespace Aurora::Threading::Primitives
|
||||
|
||||
bool ConditionVariableNT::CheckOutNoSpin()
|
||||
{
|
||||
#if defined(AURORA_FORCE_SRW_LOCKS)
|
||||
return false;
|
||||
#else
|
||||
auto uSignalNow = this->signalCount;
|
||||
|
||||
if (uSignalNow == 0)
|
||||
@ -285,6 +288,7 @@ namespace Aurora::Threading::Primitives
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ConditionVariableNT::CheckOut()
|
||||
|
Loading…
Reference in New Issue
Block a user