#!/usr/bin/perl

$start = -1;
$end = -1;

while (<>) {

	if (/Pulse begin (\d+)/) {
		$start = $1;
	}
	next if ($start < 0);

	if (/Pulse end (\d+)/) {
		$time = int(($1 - $start) / 2) * 2;
		$TIMES{$time} = 1;
		$END{$time}++;
		$end = $time;
	}
	if (/DATA LOCAL SET\t.*\t(\d+)/) {
		$time = int(($1 - $start) / 2) * 2;
		$TIMES{$time} = 1;
		$SET{$time}++;
	}
	if (/DATA REMOTE GET\t.*\t(\d+)/) {
		$time = int(($1 - $start) / 2) * 2;
		$TIMES{$time} = 1;
		$GET{$time}++;
	}
	if (/Pulse complete (\d+)/) {
		$time = int(($1 - $start) / 2) * 2;
		$TIMES{$time} = 1;
		$COM{$time}++;
		$time -= $end;
		$TIMES{$time} = 1;
		$DUR{$time}++;
	}
}

foreach $key (sort bynum keys %TIMES) {
	next if ($key > 600);
	print join("\t", $key,
		$END{$key} || 0,
		$SET{$key} || 0,
		$GET{$key} || 0,
		$COM{$key} || 0,
		$DUR{$key} || 0
	) . "\n";
}

sub bynum {
	return $a <=> $b;
}
