primes/autoTest.pl

719 lines
21 KiB
Perl
Raw Normal View History

2011-03-08 07:01:27 +00:00
#!/usr/bin/env perl
# www.mindstab.net/primes
# Run prime number finders
# haplo@mindstab.net
print "Mindstab Development Multi-language Prime Number Project v1.02\n(www.mindstab.net/tag/primes/)\nhaplo\@mindstab.net\n\n";
# results file
$RESULTS="results.txt";
$TIME="time -p";
$os = `uname`;
$debug=0;
@langs = ("c",
# Uncomment for alternat C algorithms
# "c2", "ca", "ca2", "ca3",
2014-01-15 15:53:35 +00:00
"objc", "cpp", "asm", "for", "pas", "go", "ada", "hs", "e", "cbl", "oml", "java", "scala", "cs", "vb", "erl", "awk", "pl", "php", "py", "tcl", "rb1.8", "rb1.9", "cl", "scm", "st", "sml", "4th", "pro", "m3", "pike", "lua", "rexx", "r", "fe", "5c", "m4", "sh");
2011-03-08 07:01:27 +00:00
$llen = $#langs+1;
print "Number of iterations to run tests [3]: ";
$itr = <stdin>;
chomp($itr);
print "\n";
if($itr < 1) { $itr = 3; }
print "Maximun number to search to [100000]: ";
$max = <stdin>;
chomp($max);
print "\n";
if($max < 1) { $max = 100000; }
#sources
$data{'c'}{'name'} = "C";
$data{'c'}{'src'}= "primes.c";
$data{'c'}{'prog'} = "primesc";
$data{'c'}{'compiler0'} = "gcc";
$data{'c'}{'cflags0'} = "-lm -O3 -o " . $data{'c'}{'prog'};
$data{'c2'}{'name'} = "C Sieve";
$data{'c2'}{'src'}= "primes.sieve.c";
$data{'c2'}{'prog'} = "primescsieve";
$data{'c2'}{'compiler0'} = "gcc";
$data{'c2'}{'cflags0'} = "-lm -O3 -o " . $data{'c2'}{'prog'};
$data{'ca'}{'name'} = "C Alternate Algorithm (Variable sqrt monitoring)";
$data{'ca'}{'src'}= "primes.alt.c";
$data{'ca'}{'prog'} = "primesaltc";
$data{'ca'}{'compiler0'} = "gcc";
$data{'ca'}{'cflags0'} = "-lm -O3 -o " . $data{'ca'}{'prog'};
$data{'ca2'}{'name'} = "C Alternate2 Algorithm (Variable sqrt monitoring and c math modulus)";
$data{'ca2'}{'src'}= "primes.alt2.c";
$data{'ca2'}{'prog'} = "primesalt2c";
$data{'ca2'}{'compiler0'} = "gcc";
$data{'ca2'}{'cflags0'} = "-lm -O3 -o " . $data{'ca2'}{'prog'};
$data{'ca3'}{'name'} = "C Alternate3 Algorithm (Variable sqrt monitoring and recursion)";
$data{'ca3'}{'src'}= "primes.alt3.c";
$data{'ca3'}{'prog'} = "primesalt3c";
$data{'ca3'}{'compiler0'} = "gcc";
$data{'ca3'}{'cflags0'} = "-lm -O3 -o " . $data{'ca3'}{'prog'};
$data{'asm'}{'name'} = "x86 Assembly";
$data{'asm'}{'src'} = "primes.x86.s";
$data{'asm'}{'prog'} = "primesasm";
$data{'asm'}{'compiler0'} = "gcc";
$data{'asm'}{'cflags0'} = "-O3 -o ". $data{'asm'}{'prog'};
$data{'asm'}{'pre'} = "echo \"$max\" | ";
$data{'asm'}{'osfilter'} = "OpenBSD";
$data{'objc'}{'name'} = "Objective C";
$data{'objc'}{'src'}= "primes.m";
$data{'objc'}{'compiler0'} = "gcc";
$data{'objc'}{'prog'} = "primesobjc";
$data{'objc'}{'cflags0'} = "-lobjc -lm -O3 -o " . $data{'objc'}{'prog'};
$data{'objc'}{'osfilter'} = "FreeBSD";
$data{'cpp'}{'name'} = "C++";
$data{'cpp'}{'src'}= "primes.cpp";
$data{'cpp'}{'compiler0'} = "g++";
$data{'cpp'}{'prog'} = "primescpp";
$data{'cpp'}{'cflags0'} = "-lm -O3 -o " . $data{'cpp'}{'prog'};
$data{'for'}{'name'} = "Fortran";
$data{'for'}{'src'} = "primes.f";
2013-01-31 06:37:55 +00:00
$data{'for'}{'compiler0'} = "gfortran";
2011-03-08 07:01:27 +00:00
$data{'for'}{'prog'} = "primesfor";
$data{'for'}{'cflags0'} = "-O3 -o $data{'for'}{'prog'}";
$data{'pas'}{'name'} = "Pascal";
$data{'pas'}{'src'} = "primes.pas";
$data{'pas'}{'compiler0'} = "fpc";
$data{'pas'}{'prog'} = "primespas";
$data{'pas'}{'cflags0'} = "-o$data{'pas'}{'prog'}";
$data{'ada'}{'name'} = "Ada";
$data{'ada'}{'src'} = "primes.adb";
$data{'ada'}{'compiler0'} = "gnatmake";
$data{'ada'}{'prog'} = "primesada";
$data{'ada'}{'cflags0'} = "-o $data{'ada'}{'prog'}";
$data{'ada'}{'cflagspre0'} = "rm -f primes.ali primes.o && ";
$data{'e'}{'name'} = "Eiffel";
$data{'e'}{'src'}= "primes.e";
$data{'e'}{'compiler0'} = "compile_to_c";
$data{'e'}{'prog'} = "primese";
$data{'e'}{'cflags0'} = "$data{'e'}{'src'} -boost -O3 -o " . $data{'e'}{'prog'}. " && sh primes.make";
$data{'e'}{'cflagspre0'} = "rm -f primes1.o && ";
$data{'awk'}{'name'} = "AWK";
$data{'awk'}{'src'} = "primes.awk";
$data{'awk'}{'pre0'} = "echo $max | ";
$data{'awk'}{'interp0'} = "awk";
$data{'awk'}{'iflags0'} = "-f " . $data{'awk'}{'src'};
2014-01-15 15:53:35 +00:00
$data{'go'}{'name'} = "Go";
$data{'go'}{'src'} = "primes.go";
$data{'go'}{'compiler0'} = 'go';
$data{'go'}{'cflags0'} = 'build -o primesgo ';
$data{'go'}{'prog'} = 'primesgo';
2011-03-08 07:01:27 +00:00
$data{'sml'}{'name'} = "SML";
$data{'sml'}{'src'} = "primes.sml";
#$data{'sml'}{'iflagspre0'} = "echo primes $max | ";
$data{'sml'}{'iflagspre0'} = "cat $data{'sml'}{'src'} | sed -e 's/.*autotest.*/primes $max/' |";
$data{'sml'}{'interp0'} = "sml";
$data{'sml'}{'filter0'} = "sed -e '/[a-zA-Z\\-\\=]/g'";
$data{'m4'}{'name'} = "M4";
$data{'m4'}{'src'} = "primes.m4";
$data{'m4'}{'iflagspre0'} = "cat $data{'m4'}{'src'} | sed -e 's/.*autotest.*/PRIMES(3,$max,2,4)/' |";
$data{'m4'}{'interp0'} = "m4";
$data{'m4'}{'noarg'} = 1;
$data{'m4'}{'warn'} = "Execution is approximately 20-30 times slower than perl.";
$data{'m4'}{'reprompt'} = 1;
$data{'rexx'}{'name'} = "REXX";
$data{'rexx'}{'interp0'} = "rexx";
$data{'rexx'}{'prog'} = "primes.rexx";
$data{'r'}{'name'} = "REBOL";
$data{'r'}{'src'} = "primes.r";
$data{'r'}{'interp0'} = "rebol";
$data{'r'}{'iflags0'} = "--quiet $data{'r'}{'src'} $max";
$data{'oml'}{'name'} = "OCaml";
$data{'oml'}{'src'} = "primes.ml";
$data{'oml'}{'prog'} = "primesocaml";
$data{'oml'}{'compiler0'} = "ocamlopt";
$data{'oml'}{'cflags0'} = "-o $data{'oml'}{'prog'}";
$data{'oml'}{'cflagspre0'} = "rm -f primes.cmi primes.cmx && ";
$data{'erl'}{'name'} = "Erlang";
$data{'erl'}{'src'} = "primes.erl";
$data{'erl'}{'compiler0'} = "erlc";
$data{'erl'}{'interp0'} = "erl";
$data{'erl'}{'iflags0'} = "-noshell -s primes primes '$max'";
2013-01-31 06:31:08 +00:00
$data{'4th'}{'name'} = "Forth";
2011-03-08 07:01:27 +00:00
$data{'4th'}{'src'} = "primes.fs";
$data{'4th'}{'interp0'} = "gforth-fast";
$data{'4th'}{'iflags0'} = "$data{'4th'}{'src'} -e '$max 2 4 primes bye'";
$data{'cbl'}{'name'} = "COBOL";
$data{'cbl'}{'src'} = "primes.cbl";
$data{'cbl'}{'prog'} = "primescbl";
$data{'cbl'}{'compiler'} = 2;
$data{'cbl'}{'compiler0'} = "cobc";
2013-01-31 05:36:44 +00:00
$data{'cbl'}{'cflags0'} = "-o $data{'cbl'}{'prog'} -x";
2011-03-08 07:01:27 +00:00
$data{'cbl'}{'compiler1'} = "htcobolpp";
$data{'cbl'}{'cflags1'} = "-o $data{'cbl'}{'prog'} -x ";
$data{'cbl'}{'pre'} = "echo \"$max\" | ";
$data{'cbl'}{'warn'} = "Execution is a slower than average, but nothing to worry about";
$data{'scm'}{'name'} = "Scheme";
$data{'scm'}{'src'} = "primes.scm";
$data{'scm'}{'interp'} = 3;
$data{'scm'}{'interp0'} = "scm";
$data{'scm'}{'iflags0'} = "-f ". $data{'scm'}{'src'}." -e \\\\\\\"(primes 3 $max)\\\\\\\"";
$data{'scm'}{'interp1'} = "mzscheme";
$data{'scm'}{'iflags1'} = "-m -f ". $data{'scm'}{'src'}." -e \\\\\\\"(and (primes 3 $max) (exit))\\\\\\\"";
$data{'scm'}{'interp2'} = "guile";
$data{'scm'}{'iflags2'} = "-l $data{'scm'}{'src'} -c '(primes 3 $max)'";
$data{'cl'}{'name'} = "Common Lisp";
$data{'cl'}{'src'} = "primes.lisp";
#$data{'cl'}{'compiler'} = 1;
#$data{'cl'}{'compiler0'} = "clisp";
#$data{'cl'}{'compiler0'} = "gcl";
#$data{'cl'}{'cflagspre0'} = "rm -f primes_clisp.lib primes_clisp.fas && ";
#$data{'cl'}{'cflagspre0'} = "rm -f primes2.o && ";
#$data{'cl'}{'cflags0'} = "-c";
#$data{'cl'}{'cflags0'} = "-compile";
$data{'cl'}{'interp'} = 1;#2
#$data{'cl'}{'interp0'} = "clisp";
#$data{'cl'}{'interp0'} = "gcl";
#$data{'cl'}{'iflags0'} = "-q -i primes2.fas -x '(primes $max)'";
#$data{'cl'}{'iflags0'} = "-load primes2.o -eval '(progn (primes $max) (bye))'";
$data{'cl'}{'interp0'} = "sbcl";
#$data{'cl'}{'interp0'} = "lisp";
$data{'cl'}{'iflags0'} = "--noinform --load primes.lisp --eval '(progn (primes $max) (quit))'";
#$data{'cl'}{'iflags0'} = "-quiet -load primes2.cl -eval '(progn (primes $max) (quit))'";
#"--noinform --load primes_clisp.cl --eval '(progn (primes $max) (quit))'";
$data{'cl'}{'filter0'} = "sed -e '/[;N]/g'";
#$data{'cl'}{'filter0'} = "sed -e '/[A-Z]/g'";
$data{'pro'}{'name'} = "Prolog";
$data{'pro'}{'src'} = "primes.prolog.pl";
$data{'pro'}{'interp'} = 2;
$data{'pro'}{'interp0'} = "pl";
$data{'pro'}{'iflagspre0'} = "echo '[primes_prolog]. primes($max).' | ";
$data{'pro'}{'iflags0'} = "-q";
$data{'pro'}{'filter0'} = "sed -e '/?/g'";
$data{'pro'}{'interp1'} = "gprolog";
$data{'pro'}{'iflags1'} = "--init-goal '[primes_prolog]' --entry-goal 'primes($max)' --query-goal 'halt(0)'";
$data{'pro'}{'iflagspre1'} = "export GLOBALSZ=40000; ";
$data{'pro'}{'filter1'} = "sed -e '/[?A-Za-z]/g'";
$data{'pl'}{'name'} = "PERL";
$data{'pl'}{'prog'} = "primes.perl.pl";
$data{'pl'}{'interp0'} = "perl";
$data{'5c'}{'name'} = "Nickle";
$data{'5c'}{'prog'} = "primes.5c";
$data{'5c'}{'interp0'} = "nickle";
$data{'5c'}{'warn'} = "Execution is approximately 20-30 times slower than perl.";
$data{'5c'}{'reprompt'} = 1;
$data{'st'}{'name'} = "Smalltalk";
$data{'st'}{'prog'} = "primes.st";
$data{'st'}{'interp0'} = "gst";
$data{'st'}{'iflags0'} = "-g $data{'st'}{'prog'} -a $max";
$data{'lua'}{'name'} = "Lua";
$data{'lua'}{'src'} = "primes.5.lua";
2011-03-08 07:01:27 +00:00
#$data{'lua'}{'versionedsrc'} = 1;
# No one has version 4 anymore (right?)
#$data{'lua'}{'versionfinder'} = "lua -v 2>&1 | awk '{print \$2}' | sed -e 's/[^54]//g'";
2011-03-08 07:01:27 +00:00
$data{'lua'}{'interp0'} = "lua";
$data{'lua'}{'iflagspre4'} = "echo $max | ";
$data{'pike'}{'name'} = "Pike";
$data{'pike'}{'prog'} = "primes.pike";
$data{'pike'}{'interp0'} = "pike";
$data{'m3'}{'name'} = "Modula-3";
$data{'m3'}{'compiler0'} = "m3build";
$data{'m3'}{'prog'} = "`ls */primesm3`";
$data{'tcl'}{'name'} = "TCL";
$data{'tcl'}{'src'} = "primes.tcl";
$data{'tcl'}{'interp'} = 2;
$data{'tcl'}{'interp0'} = "tclsh";
$data{'tcl'}{'iflags0'} = "$data{'tcl'}{'src'} $max";
$data{'tcl'}{'interp1'} = "tclsh8.3";
$data{'tcl'}{'iflags1'} = "$data{'tcl'}{'src'} $max";
$data{'tcl'}{'warn'} = "Execution is slower than average, but nothing to worry about";
$data{'sh'}{'name'} = "Shell";
$data{'sh'}{'prog'} = "primes.sh";
$data{'sh'}{'reprompt'} = 1;
$data{'sh'}{'interp0'} = "sh";
$data{'sh'}{'warn'} = "Execution is painfully slow.\n\t\t Do not try with numbers greater than a few thousand.";
$data{'hs'}{'name'} = "Haskell";
$data{'hs'}{'src'} = "primes.hs";
$data{'hs'}{'prog'} = "primeshs";
$data{'hs'}{'compiler'} = 2;
$data{'hs'}{'compiler0'} = "ghc";
$data{'hs'}{'cflags0'} = "-O -o $data{'hs'}{'prog'}";
$data{'hs'}{'filter0'} = "sed -e 's/\.\]/\ /g'";
$data{'hs'}{'cflagspre0'} = "rm -f Main.hi primes.o && ";
$data{'hs'}{'warn'} = "Compiler is slow";
$data{'hs'}{'compiler1'} = "interpB";
# Uncomment for Hugs, appears to be crazy slow or broken?
#$data{'hs'}{'interpB'} = "hugs";
#$data{'hs'}{'preB'} = "echo \'primes 3 $max 2 4\' | ";
#$data{'hs'}{'iflagsB'} = $data{'hs'}{'src'};
#$data{'hs'}{'filterB'} = "sed -e 's/\.\]/\ /g' | sed -e 's/Main>/\ /g' | sed -e '/[a-zA-Z\/]/g' | sed -e '/ /g' ";
#$data{'hs'}{'warnB'} = "Haskell compiler (ghc) not found.\nFalling back to Haskell interpreter (hugs).\nThis method is very slow!";
$data{'py'}{'name'} = "Python";
$data{'py'}{'prog'} = "primes.py";
$data{'py'}{'interp0'} = "python";
$data{'php'}{'name'} = "PHP";
$data{'php'}{'prog'} = "primes.php";
$data{'php'}{'interp0'} = "php";
$data{'fe'}{'name'} = "Ferite";
$data{'fe'}{'prog'} = "primes.fe";
$data{'fe'}{'interp0'} = "ferite";
$data{'fe'}{'pre0'} = "echo $max | ";
$data{'rb1.8'}{'name'} = "Ruby 1.8";
$data{'rb1.8'}{'prog'} = "primes.rb";
$data{'rb1.8'}{'interp0'} = "ruby1.8";
$data{'rb1.9'}{'name'} = "Ruby 1.9.1";
$data{'rb1.9'}{'prog'} = "primes.rb";
$data{'rb1.9'}{'interp0'} = "ruby1.9.1";
$data{'java'}{'name'} = "Java";
$data{'java'}{'src'} = "primes.java";
$data{'java'}{'compiler0'} = "javac";
$data{'java'}{'interp0'} = "java";
$data{'java'}{'prog'} = "primes";
$data{'java'}{'osfilter'} = "FreeBSD";
$data{'java'}{'osreprompt'} = "OpenBSD";
$data{'java'}{'oswarn'} = "OpenBSD";
$data{'java'}{'oswarnmsg'} = "This language has been flagged as unstable on this operating system";
2013-02-23 17:36:15 +00:00
$data{'scala'}{'name'} = "Scala";
$data{'scala'}{'src'} = "primes.scala";
$data{'scala'}{'compiler0'} = "scalac";
$data{'scala'}{'interp0'} = "scala";
$data{'scala'}{'prog'} = "Primes";
2011-03-08 07:01:27 +00:00
$data{'cs'}{'name'} = "C# (Mono)";
$data{'cs'}{'src'} = "primes.cs";
$data{'cs'}{'compiler0'} = "mcs";
$data{'cs'}{'prog'} = "primescs.exe";
$data{'cs'}{'cflags0'} = "-o $data{'cs'}{'prog'}";
$data{'cs'}{'interp'} = 2;
$data{'cs'}{'interp0'} = "mono";
$data{'cs'}{'interp1'} = "mint";
$data{'vb'}{'name'} = "Visual Basic .Net (Mono)";
$data{'vb'}{'src'} = "primes.vb";
$data{'vb'}{'compiler0'} = "mbas";
$data{'vb'}{'prog'} = "primesvb.exe";
$data{'vb'}{'cflags0'} = "-o $data{'vb'}{'prog'}";
$data{'vb'}{'interp'} = 2;
$data{'vb'}{'interp0'} = "mono";
$data{'vb'}{'interp1'} = "mint";
$data{'vb'}{'osfilter'} = "FreeBSD";
sub checkValid
{
print "Checking outputed results for validity...\n";
local(@res) = `wc primes.*.txt`;
local($i);
for($i=0; $i < $#res; $i++)
{
$arr[$i][0] = `echo \"$res[$i]\" | awk '{print \$2}'`;
chomp($arr[$i][0]);
chomp($arr[$i][0]);
$arr[$i][1] = `echo \"$res[$i]\" | awk '{print \$4}'`;
chomp($arr[$i][1]);
chomp($arr[$i][1]);
}
# scan all others for differencees, for each match add 1 to [i][2]
$pt = 0;
for($i=0; $i<=$#arr; $i++)
{
$arr[$i][2] = 0;
for($p=0; $p <= $#arr; $p++)
{
if($p==$i) { next; }
if($arr[$i][0] == $arr[$p][0]) { $arr[$i][2]++; }
}
if($arr[$i][2] > $pt) {$pt = $arr[$i][2];}
}
print "Checked ". ($#arr+1)." ouput files of $execd executed languages for validity:\n";
if($pt != $#arr )
{
print "Differences detected in ".(($#arr+1)-($pt+1)) ." output files:\n";
for($i=0; $i<= $#arr; $i++)
{
if($arr[$i][2] < $pt || $pt == 0) {
print "\t". $arr[$i][1]."\n";
}
}
} else {
print "All output appears to be valid!\n";
}
print "View benchmark results in 'results.txt'\n";
}
sub parseTimes
{
if($debug) {
print "\n$cmd\n";
}
for($i=0; $i< $itr; $i++)
{
if($rcmd ne "") { `$rcmd`; }
my $tstr = `$cmd`;
print ".";
($tm[$i][0], $tm[$i][1], $tm[$i][2]) = $tstr =~
/[^\d]*(\d*\.\d*)[^\d]*(\d*\.\d*)[^\d]*(\d*\.\d*).*/;
}
my $tr = $tu = $ts =0.0;
for($i=0; $i< $itr; $i++)
{
$tr += $tm[$i][0];
$tu += $tm[$i][1];
$ts += $tm[$i][2];
}
$tr /= $itr;
$tu /= $itr;
$ts /= $itr;
$tr = substr($tr, 0,4);
$tu = substr($tu, 0,4);
$ts = substr($ts, 0,4);
#print results "$tr real\t$tu user\t$ts sys\n";
if(length($tr) == 1) { $tr .= "."; }
if(length($tr) == 2) { $tr .= "0"; }
if(length($tr) == 3) { $tr .= "0"; }
print results "$tr seconds\n";
}
sub getByLocate
{
local($where) = `locate $_[0] | grep bin | grep -v cgi | grep -v port | grep -v src`;
($where) = $where =~ /(.*\/$_[0])\n.*$/;
#print "WHERE: '$where'\n";
if($where eq "") { return ""; } else { return $where; }
}
sub getInterp
{
local($where) = `/usr/bin/whereis $_[0] | grep -v port`;
if(! ($where =~ "\:")) {
if($where eq "") { return getByLocate($_[0]); }
else { return "/usr/bin/env $_[0]";
}
} else
{
local($t1, $t2) = split(":", $where);
chomp($t2);
if($t2 ne "") {
return "/usr/bin/env $_[0]";
} else {
return getByLocate($_[0]);
}
}
}
# HEADER
open(results, ">".$RESULTS) || die("Cannot open $RESULTS\n");
print results "Prime number benchmarks\n";
$mach = `uname -a`;
print results "Benchmark machine: " . $mach."\n";
# TESTS
$yesall = 0;
$item = 0;
$execd = 0;
$compiler="";
foreach $l (@langs)
{
$item++;
$interpB = 0;
$compiler = "";
$version = "";
if($data{$l}{'osreprompt'} && $os =~ $data{$l}{'osreprompt'}) {
$data{$l}{'reprompt'} = 1;
}
if($data{$l}{'osreprompt'} && $os =~ $data{$l}{'oswarn'}) {
$data{$l}{'warn'} = $data{$l}{'oswarnmsg'};
}
if($yesall == 0 || $data{$l}{'reprompt'}){
print "($item/$llen) Run ".$data{$l}{"name"}." test\n";
if($data{$l}{'warn'} && !$data{$l}{"reprompt"}) { print "WARNING: $data{$l}{'warn'}\n";}
if($data{$l}{'reprompt'}) {
print "RE-PROMPT: WARNING: ";
if($data{$l}{"warn"}) {
print $data{$l}{'warn'};
} else {
print "Execution is excessively slow.";
}
print "\n";
}
print "(Y)es yes(A)ll (Q)uit [N]o : ";
$query = <stdin>;
$query = substr($query,0,1);
}
if($query eq "a" || $query eq "A")
{
$yesall = 1;
}
if(($yesall == 1 && !$data{$l}{'reprompt'}) || $query eq "y" || $query eq "Y" )
{
if($yesall == 1) {
if($query eq "n" || $query eq "N") { $query = "y";}
}
if($query eq "Y") {$query eq "y"; }
if($yesall == 1 && $query eq "y" && !$data{$l}{'reprompt'}) {
print "($item/$llen) ";
}
print "Testing ". $data{$l}{"name"}.":\n";
if($data{$l}{'warn'} && $yesall && $query eq "y") { print "WARNING: $data{$l}{'warn'}\n";}
if($query eq "A" || $query eq "a") {$query = "y";}
print results "($item/$llen) ". $data{$l}{"name"}." results:\n";
if( $data{$l}{'osfilter'} and $os =~ $data{$l}{'osfilter'})
{
print "ERROR: This language is flagged as incompatible with this operating system\n\n";
print results "ERROR: This language is flagged as incompatible with this operating system\n\n";
next;
}
$cmd="";
if( $data{$l}{"compiler0"})
{
print "Compiling";
print results "Compile";
if($l ne "java" && $l ne "m3") {$rcmd = "rm -f $data{$l}{'prog'}";}
else { $rcmd = "";}
$cmd .= "sh ";
if(!$debug) { $cmd .= "2>&1 "; }
$cmd .= "-c \"" .$TIME . " sh -c \\\"";
$cp = 0;
if(! $data{$l}{'compiler'})
{
$data{$l}{'compiler'} = 1;
}
for(; $cp < $data{$l}{'compiler'}; $cp++)
{
if($data{$l}{"compiler$cp"} eq "interpB")
{
$cp = $data{$l}{'compiler'};
$interpB = 1;
last;
}
$comp = getInterp($data{$l}{"compiler$cp"});
last if($comp ne "");
}
if($cp == $data{$l}{'compiler'}) {
$clist = "";
for($p=0;$p<$data{$l}{'compiler'};$p++)
{
last if($data{$l}{"compiler$p"} eq "interpB");
$clist .= "\t\t\t($p) ". $data{$l}{"compiler$p"}."\n";
}
print ":\tERROR - Unable to find one of the following compiler(s):\n$clist\n";
print results ":\tERROR - Unable to find one of the following compiler(s):\n$clist\n";
if(! $interpB) { next; }
}
if(!$interpB) {
$compiler = $data{$l}{"compiler$cp"};
print " [$compiler] ";
print results " [$compiler]:\t";
if(length($compiler) < 5) {print results "\t";}
if($data{$l}{"cflagspre$cp"}) { $cmd .= $data{$l}{"cflagspre$cp"};}
$cmd .= "$comp ";
2013-01-31 05:11:32 +00:00
# So gcc stoped compiling if teh linking was done before the soruce file was specified
# go figure
$gcc_code = 0;
if ($l =~ /^o?b?j?ca?[23]?$/) {
2013-01-31 05:11:32 +00:00
$gcc_code = 1;
}
if( $gcc_code) {
$cmd .= " ".$data{$l}{"src"}." ";
}
2011-03-08 07:01:27 +00:00
if( $data{$l}{"cflags$cp"} )
{
$cmd .= $data{$l}{"cflags$cp"};
}
2013-01-31 05:11:32 +00:00
if ( ! $gcc_code) {
$cmd .= " ".$data{$l}{"src"}." ";
}
2011-03-08 07:01:27 +00:00
$cmd .= "\\\"\"";
#printf "CMD: '$cmd'\n";
parseTimes();
$rcmd = "";
print "\n";
}
}
if($interpB && $data{$l}{'warnB'})
{
print "WARNING: ".$data{$l}{'warnB'}."\n";
}
print "Executing";
print results "Execute";
$filter = "";
$interpreter = "";
$cmd = "sh ";
if(!$debug) { $cmd .= "2>&1 "; }
$cmd .= "-c \"". $TIME . " sh -c \\\"";
if( $data{$l}{"interp0"} or $interpB)
{
$ip=0;
if(! $data{$l}{'interp'}) {
$data{$l}{'interp'} = 1;
}
if($interpB) {
$interp = getInterp($data{$l}{'interpB'});
if($interp eq "") {
$ip = $data{$l}{'interp'};
} else {
$ip = "B";
}
}
else {
for(; $ip < $data{$l}{'interp'}; $ip++)
{
$interp = getInterp($data{$l}{"interp$ip"});
last if($interp ne "");
}
}
if($ip == $data{$l}{'interp'})
{
$ilist = "";
if($interpB) {
$ilist = "\t".$data{$l}{'interpB'}."\n";
} else
{
for($p=0;$p<$data{$l}{'interp'};$p++)
{
$ilist .= "\t\t\t($p) " .$data{$l}{"interp$p"}."\n";
}
}
print ":\tERROR - Unable to find one of the following interpreter(s):\n$ilist\n";
print results ":\tERROR - Unable to find one of the following interpreter(s):\n$ilist\n";
next;
}
$interpreter = $data{$l}{"interp$ip"};
print " [$interpreter]";
print results " [$interpreter]";
$filter = $data{$l}{"filter$ip"};
$cmd .= $data{$l}{"pre$ip"};
$cmd .= $data{$l}{"iflagspre$ip"};
$cmd .= "$interp ";
if(!$data{$l}{'noarg'})
{
if( $data{$l}{"iflags$ip"})
{
$cmd .= $data{$l}{"iflags$ip"}. " ";
} elsif( $data{$l}{"prog"} )
{
$cmd .= $data{$l}{"prog"}." $max ";
} else
{
if($data{$l}{"versionfinder"}) {
$version = `$data{$l}{"versionfinder"}`;
chomp($version);
$data{$l}{'src'} =~ s/#VERSION#/$version/;
}
if($version) {
if($data{$l}{"iflagspre$version"})
{
$cmd = $data{$l}{"iflagspre$version"} . $cmd;
}
}
$cmd .= $data{$l}{"src"}. " ";
$cmd .= "$max ";
}
}
} else
{
if($data{$l}{'pre'}) { $cmd .= $data{$l}{'pre'};}
$cmd .= "./" . $data{$l}{"prog"} . " $max";
$filter = $data{$l}{"filter$cp"};
}
if($filter) { $cmd .= " | $filter "; }
$cmd .= " > primes.$l.txt";
$cmd .= "\\\"\"";
print " ";
print results ":\t";
if(length($interpreter) < 5) { print results "\t";}
parseTimes();
print "\n";
print results "\n";
sleep 1;
$execd++;
}
elsif( $query eq "q" || $query eq "Q")
{
print "\n";
checkValid();
print "Quiting\n";
close(results);
exit;
}
print "\n";
}
checkValid();
close(results);