update profiling code to decay instead of clearing all stats

pull/380/head
Jeff Becker 5 years ago
parent 8331449ab9
commit a1bd26a165
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -46,24 +46,24 @@ namespace llarp
}
void
RouterProfile::Clear()
RouterProfile::Decay()
{
connectGoodCount = 0;
connectTimeoutCount = 0;
pathSuccessCount = 0;
pathFailCount = 0;
lastUpdated = llarp::time_now_ms();
connectGoodCount /= 2;
connectTimeoutCount /= 2;
pathSuccessCount /= 2;
pathFailCount /= 2;
lastUpdated = llarp::time_now_ms();
}
void
RouterProfile::Tick()
{
// 10 minutes
static constexpr llarp_time_t updateInterval = DEFAULT_PATH_LIFETIME;
// 20 minutes
static constexpr llarp_time_t updateInterval = DEFAULT_PATH_LIFETIME * 2;
auto now = llarp::time_now_ms();
if(lastUpdated < now && now - lastUpdated > updateInterval)
{
Clear();
Decay();
}
}

@ -32,9 +32,9 @@ namespace llarp
bool
IsGood(uint64_t chances) const;
/// clear stats
/// decay stats
void
Clear();
Decay();
// rotate stats if timeout reached
void

Loading…
Cancel
Save