[ale] Measuering Latency

Christopher Fowler cfowler at outpostsentinel.com
Mon Nov 12 12:33:28 EST 2007


By measuring my latency in regards to the SF issue, I've come to the
conclusion that I would like to do it on a permanent basis.  I want to
make sure I'm calculating the numbers correctly.

Here is how I do it now:

sub delay {
  my $target = shift;
  my @v = undef;
  open PING, "ping -w20 -c10 $target 2>&1 |";
  while(<PING>) {
    next unless m/time=(.+?)ms/;
    push @v, $1;
  }

  close PING;
  my $h = 0;
  foreach my $t (@v) { $h = $t if $h <= $t; }
  return int($h);
}

In this example I get the time for 10 packets and I return the highest
since it is pain we feel.  Is that a fair calculation?  Should I return
the average instead?  Is there a better way to get these numbers?





More information about the Ale mailing list