#!/usr/local/bin/perl -w

$filename = $ARGV[0];

open(IN, "<$filename");

$next_line=0;
while(<IN>) {
  (print "Avg uSec (Pack/Send) $_"), $next_line=0 if $next_line;
  print $_ if /Running test/ || /Round Trip Test/;

  if (/Round Trip Test Avg uSec\s*(\d+)/) {
    $sum += $1;
    $n++;
  }

  $next_line=1 if /^Avg uSec/;
}

print "Round Trip Test All Avg uSec ", $sum/$n, "\n";
close(IN);

