#!/usr/bin/perl

use POSIX;

$filename = shift or die "usage: analyze_backlog.pl <backlog file>";

open BACKLOG, $filename;

$binning = 0.1;
$ntx = 0;
$nrx = 0;

while (<BACKLOG>) {

    ($start, $direction, $date, $time) = split;

    #print "$direction $date $time\n";
    
    ($hour, $min, $sec) = split /:/, $time;
    $daysec = 3600*$hour + 60*$min + $sec;

    $ntx++ if ($direction eq 'TX');
    $nrx++ if ($direction eq 'RX');
    

    $binspec = floor( $daysec / $binning );

    if ( $olddate ne $date or $oldbinspec ne $binspec ) {
	print "$date $time $nrx $ntx\n";
	$olddate = $date;
	$oldbinspec = $binspec;
	$ntx = 0;
	$nrx = 0;
    }

    

    
}
