aalta_fn.pl 1.46 KB
Newer Older
Christian Müller's avatar
aalta  
Christian Müller committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
#!/usr/bin/perl

use File::Find;

use POSIX qw/strftime/;
use Time::HiRes qw( time );

#print strftime('%D %T',localtime);
$start = strftime('%D %T',localtime);

my $files;
find(\&wanted, 'benchmarks');
$n = 1;
#open(TIMEOUTFILE, ">timeout_aalta") or die "cannot open the file!";
#open(TIMEOUTFILE, ">error") or die "cannot open the file!";
foreach(@content)
{
  if(-f $_)
  {
    #print "$_\n";
    if($_ =~ /.*\.alaska/)
    {
      open(INFILE, "$_") or die "cannot open the input file!";
      open(OUTFILE, ">output/$_") or die "cannot open the file!";
      #open(TIMEOUTFILE, ">>output/timeout_aalta") or die "cannot open the file!";
      $line = <INFILE>;
      
      while ($line ne "")
      {
        eval
        {
	   local $SIG{ALRM} = sub { die "timeout\n" };
	   alarm(60);
           $t0 = time();
           #print "checking\ $_ ...\n";
	   $output = `./aalta -fn "$line"`;
	   print OUTFILE "$output\n";
	   
           $n = $n + 1;
	   alarm(0);
	};
	if($@)
	{
	  #print TIMEOUTFILE ("$_\n");
          $output = `killall -9 aalta`;
          print OUTFILE "timeout\n";
	  $n = $n + 1;
	  sleep 1;		 
	}
	$line = <INFILE>;
      }
      close(INFILE);
      #close(OUTFILE);
    }
  }
}
close(TIMEOUTFILE);

$end = strftime('%D %T',localtime);
open(TIMEFILE, ">timeinfo") or die "cannot open the file!";
print TIMEFILE ("start time:  $start\n");
print TIMEFILE ("end time:  $end\n");
close(TIMEFILE);

exit;

sub wanted
{
  push @content, $File::Find::name;
  return;
}