mirror of
https://github.com/usatiuk/backup.git
synced 2025-10-26 17:37:47 +01:00
init
This commit is contained in:
30
src/RunningDiffAverage.h
Normal file
30
src/RunningDiffAverage.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Created by Stepan Usatiuk on 12.05.2023.
|
||||
//
|
||||
|
||||
#ifndef SEMBACKUP_RUNNINGDIFFAVERAGE_H
|
||||
#define SEMBACKUP_RUNNINGDIFFAVERAGE_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "RunningAverage.h"
|
||||
|
||||
/// Computes the rolling average of differences between last sampled and currently sampled numbers
|
||||
class RunningDiffAverage {
|
||||
public:
|
||||
///
|
||||
/// \param getFunc Function that samples the value
|
||||
/// \param max Max number of samples to average
|
||||
/// \param ms Sampling period
|
||||
RunningDiffAverage(std::function<unsigned long long()> getFunc, int max, int ms);
|
||||
|
||||
/// Returns the average
|
||||
unsigned long long get();
|
||||
|
||||
private:
|
||||
unsigned long long prev = 0; ///< Previously sampled value
|
||||
RunningAverage runningAverage;///< Backing RunningAverage
|
||||
};
|
||||
|
||||
|
||||
#endif//SEMBACKUP_RUNNINGDIFFAVERAGE_H
|
||||
Reference in New Issue
Block a user