#!/usr/bin/perl -w

if ($#ARGV >= 0) {
    open(STDIN," < $ARGV[0]") || die "can't open file $ARGV[0]\n";
}

my $last_time;
my $count = 0;
my $total = 0;

while (<>) {
    print;
    if (m,\[\s*([\d\.]+)\],) {
	my $time = $1;
	if (defined($last_time)) {
	    my $diff = $time - $last_time;
	    printf "  diff: %.6f\n", $diff;
	    $count++;
	    $total += $diff;
	}
	$last_time = $time;
    }
}

printf "count: %d  total: %.6f\n", $count, $total;
printf "average: %.6f\n", $total / $count;
