Permalink
Browse files

Minor improvement to jitter test

  • Loading branch information...
adolfintel committed Sep 20, 2018
1 parent 228d137 commit 4b54e4b388ecb9ad63ea0db03c52ba3887f8cb85
Showing with 4 additions and 2 deletions.
  1. +3 −1 speedtest_worker.js
  2. +1 −1 speedtest_worker.min.js
View
@@ -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
}
Oops, something went wrong.

0 comments on commit 4b54e4b

Please sign in to comment.