Created
November 5, 2016 00:10
-
-
Save mqp/0fff4a03f12214c1775c9d302c830c10 to your computer and use it in GitHub Desktop.
Incremental mystery metric computation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal void UpdateRoundTripTimeAndVariance(int lastRoundtripTime) | |
{ | |
if (lastRoundtripTime < 0) | |
{ | |
return; | |
} | |
this.roundTripTimeVariance -= this.roundTripTimeVariance / 4; | |
if (lastRoundtripTime >= this.roundTripTime) | |
{ | |
this.roundTripTime += (lastRoundtripTime - this.roundTripTime) / 8; | |
this.roundTripTimeVariance += (lastRoundtripTime - this.roundTripTime) / 4; | |
} | |
else | |
{ | |
this.roundTripTime += (lastRoundtripTime - this.roundTripTime) / 8; | |
this.roundTripTimeVariance -= (lastRoundtripTime - this.roundTripTime) / 4; | |
} | |
if (this.roundTripTime < this.lowestRoundTripTime) | |
{ | |
this.lowestRoundTripTime = this.roundTripTime; | |
} | |
if (this.roundTripTimeVariance <= this.highestRoundTripTimeVariance) | |
{ | |
return; | |
} | |
this.highestRoundTripTimeVariance = this.roundTripTimeVariance; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment