$ perl -e '$x=time; $SIG{ALRM}=sub{$y=time; close STDIN}; alarm 2; <>; print STDERR $y-$x," ",time-$x,"\n"' 2 2