Syntalos::ResourceTrend
Syntalos::ResourceTrend
Estimate how fast a finite resource is being used up. More…
#include <resourceinfo.h>
Public Functions
| Name | |
|---|---|
| ResourceTrend(double minRelevantRate =0.0, double smoothing =0.5) | |
| void | reset() Forget all previous samples. |
| void | addSample(qint64 remaining) Add a sample of the remaining amount, timed against the previous sample. |
| void | addSample(qint64 remaining, double elapsedSec) Add a sample of the remaining amount taken elapsedSec after the previous one. |
| bool | hasRate() const Whether enough samples were seen to give a meaningful rate. |
| double | consumptionRate() const Smoothed consumption rate in units per second, negative if unknown. |
| double | secondsUntilDepleted() const Projected time in seconds until the resource is depleted at the current rate, negative if unknown. |
| qint64 | lastRemaining() const The most recently sampled remaining amount, negative if no sample was seen. |
Detailed Description
class Syntalos::ResourceTrend;Estimate how fast a finite resource is being used up.
Periodic samples of the remaining amount of a resource (free disk space, available memory, …) are fed in, and the consumption rate is tracked as an exponential moving average, so that the time until the resource is depleted can be projected.
Samples where the remaining amount grew count as a rate of zero, so the estimate recovers quickly once consumption stops.
Public Functions Documentation
function ResourceTrend
explicit ResourceTrend(
double minRelevantRate =0.0,
double smoothing =0.5
)Parameters:
- minRelevantRate Consumption rates (units/sec) below this value are treated as “unknown”, so no depletion time is projected from noise.
- smoothing Weight of the newest sample in the moving average (0..1).
function reset
void reset()Forget all previous samples.
function addSample
void addSample(
qint64 remaining
)Add a sample of the remaining amount, timed against the previous sample.
function addSample
void addSample(
qint64 remaining,
double elapsedSec
)Add a sample of the remaining amount taken elapsedSec after the previous one.
function hasRate
bool hasRate() constWhether enough samples were seen to give a meaningful rate.
function consumptionRate
double consumptionRate() constSmoothed consumption rate in units per second, negative if unknown.
function secondsUntilDepleted
double secondsUntilDepleted() constProjected time in seconds until the resource is depleted at the current rate, negative if unknown.
function lastRemaining
qint64 lastRemaining() constThe most recently sampled remaining amount, negative if no sample was seen.
Updated on 2026-09-06 at 20:30:11 +0000