#!/usr/bin/perl -w

# A trivial script to re-write strace -ttt output
# to be more readable.

my $first_time = '';
my $last_time = '';

while (<>) {
    if (m/(\d+)\s+([\d\.]+)\s+(.*)$/) {
	my ($pid, $time, $data) = ($1, $2, $3);
	if ($first_time eq '') {
	    $first_time = $time;
	    $last_time = $time;
	}
	my $new_elapsed  = sprintf ("%06f", $time - $last_time);
	my $new_absolute = sprintf ("%02.5f", $time - $first_time);
#	print "Last '$last_time' Time '$time', New '$newtime'\n";
	print "$new_elapsed $new_absolute $data [$pid]\n";
	$last_time = $time;
    } else {
	print "Odd line '$_'\n";
    }
}
