move util functions into respective modules

This commit is contained in:
Nils Andreas Svee committed 2022-10-19 21:23:52 +02:00
1 parent 1c38d8ff48
commit befccc0d6f
4 files changed
+11 -20

No files matched your search

+6 -3
View File
@@ -1,5 +1,4 @@
use crate::pinger::PingReply;
use crate::utils::Utils;
use crate::Config;
use log::info;
use std::collections::HashMap;
@@ -22,6 +21,10 @@ pub struct Baseliner {
pub stats_receiver: Receiver<PingReply>,
}
fn ewma_factor(tick: f64, dur: f64) -> f64 {
((0.5_f64).ln() / (dur / tick)).exp()
}
impl Baseliner {
pub fn run(&self) -> anyhow::Result<()> {
/*
@@ -32,8 +35,8 @@ impl Baseliner {
* aren't bloat related, with less sensitivity (bigger numbers) we smooth through quick spikes
* but take longer to respond to real bufferbloat
*/
let slow_factor = Utils::ewma_factor(self.config.tick_interval, 135.0);
let fast_factor = Utils::ewma_factor(self.config.tick_interval, 0.4);
let slow_factor = ewma_factor(self.config.tick_interval, 135.0);
let fast_factor = ewma_factor(self.config.tick_interval, 0.4);
loop {
let time_data = self.stats_receiver.recv()?;