Permalink
Browse files

Fix Issue #9: Skip first latency before processing

We need to skip the first item in the latency array before we do IQR
filtering.  The IQR filtering runs on a sorted array, which means we
lose information about which item was first.

This change drops that item before doing any other processing.
  • Loading branch information...
1 parent 9b59b2c commit 44f7074bdf4a221efa79f2ebdc68f52b8952f86d @bluesmoon committed Aug 13, 2013
Showing with 7 additions and 8 deletions.
  1. +7 −8 plugins/bw.js
View
@@ -94,7 +94,12 @@ impl = {
sum=0, sumsq=0,
amean, median,
std_dev, std_err,
- lat_filtered;
+ lat_filtered,
+ first;
+
+ // We ignore the first since it paid the price of DNS lookup, TCP connect
+ // and slow start
+ first = this.latencies.shift();
// We first do IQR filtering and use the resulting data set
// for all calculations
@@ -104,15 +109,11 @@ impl = {
BOOMR.debug(lat_filtered, "bw");
// First we get the arithmetic mean, standard deviation and standard error
- // We ignore the first since it paid the price of DNS lookup, TCP connect
- // and slow start
- for(i=1; i<n; i++) {
+ for(i=0; i<n; i++) {
sum += lat_filtered[i];
sumsq += lat_filtered[i] * lat_filtered[i];
}
- n--; // Since we started the loop with 1 and not 0
-
amean = Math.round(sum / n);
std_dev = Math.sqrt( sumsq/n - sum*sum/(n*n));
@@ -123,8 +124,6 @@ impl = {
std_dev = std_dev.toFixed(2);
- n = lat_filtered.length-1;
-
median = Math.round(
(lat_filtered[Math.floor(n/2)] + lat_filtered[Math.ceil(n/2)]) / 2
);

0 comments on commit 44f7074

Please sign in to comment.