Skip to content

Commit

Permalink
Minor improvement to jitter test
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfintel committed Sep 20, 2018
1 parent 228d137 commit 4b54e4b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion speedtest_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ function pingTest (done) {
var instjitter = Math.abs(instspd - prevInstspd)
if (i === 1) ping = instspd; /* first ping, can't tell jitter yet*/ else {
ping = instspd < ping ? instspd : ping * 0.8 + instspd * 0.2 // update ping, weighted average. if the instant ping is lower than the current average, it is set to that value instead of averaging
jitter = instjitter > jitter ? (jitter * 0.3 + instjitter * 0.7) : (jitter * 0.8 + instjitter * 0.2) // update jitter, weighted average. spikes in ping values are given more weight.
if(i === 2) jitter=instjitter //discard the first jitter measurement because it might be much higher than it should be
else
jitter = instjitter > jitter ? (jitter * 0.3 + instjitter * 0.7) : (jitter * 0.8 + instjitter * 0.2) // update jitter, weighted average. spikes in ping values are given more weight.
}
prevInstspd = instspd
}
Expand Down
Loading

0 comments on commit 4b54e4b

Please sign in to comment.