updated python to python 3; added clang c compiler; added Dart; added run params to results.txt
This commit is contained in:
parent
83a6f8573f
commit
0dc98c99c8
2
Makefile
2
Makefile
|
@ -3,4 +3,4 @@ default:
|
||||||
./autoTest.pl
|
./autoTest.pl
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.txt primesc primescpp primesaltc primes.class primespas primes*.exe primes.o primesobjc primes.ali primesada primesfor primese primes.h primes1.c primes1.o primes.id primes.make primescbl link.res ppas.sh primes.beam primesocaml primesasm primes.cmi primes.cmx luac.out primeshs primes_clisp.fas primes.lib Main.hi primes_clisp.lib primes_clisp.o primes.hi primescsieve gst.im primesalt2c primesalt3c primesgo primesrs
|
rm -f *.txt primesgcc primesclang primescpp primesaltc primes.class primespas primes*.exe primes.o primesobjc primes.ali primesada primesfor primese primes.h primes1.c primes1.o primes.id primes.make primescbl link.res ppas.sh primes.beam primesocaml primesasm primes.cmi primes.cmx luac.out primeshs primes_clisp.fas primes.lib Main.hi primes_clisp.lib primes_clisp.o primes.hi primescsieve gst.im primesalt2c primesalt3c primesgo primesrs
|
||||||
|
|
39
autoTest.pl
39
autoTest.pl
|
@ -12,10 +12,10 @@ $os = `uname`;
|
||||||
|
|
||||||
$debug=0;
|
$debug=0;
|
||||||
|
|
||||||
@langs = ("c",
|
@langs = ("cgcc", "cclang",
|
||||||
# Uncomment for alternat C algorithms
|
# Uncomment for alternat C algorithms
|
||||||
# "c2", "ca", "ca2", "ca3",
|
# "c2", "ca", "ca2", "ca3",
|
||||||
"objc", "cpp", "asm", "for", "pas", "go", "rs", "ada", "hs", "e", "cbl", "oml", "java", "scala", "cs", "vb", "erl", "awk", "pl", "php", "py", "tcl", "rb", "cl", "scm", "st", "sml", "4th", "pro", "m3", "pike", "lua", "rexx", "r", "fe", "5c", "m4", "sh");
|
"objc", "cpp", "asm", "for", "pas", "go", "rs", "ada", "hs", "e", "cbl", "oml", "java", "scala", "cs", "vb", "erl", "awk", "pl", "php", "py", "tcl", "rb", "dart", "cl", "scm", "st", "sml", "4th", "pro", "m3", "pike", "lua", "rexx", "r", "fe", "5c", "m4", "sh");
|
||||||
|
|
||||||
$llen = $#langs+1;
|
$llen = $#langs+1;
|
||||||
|
|
||||||
|
@ -25,19 +25,25 @@ chomp($itr);
|
||||||
print "\n";
|
print "\n";
|
||||||
if($itr < 1) { $itr = 3; }
|
if($itr < 1) { $itr = 3; }
|
||||||
|
|
||||||
print "Maximun number to search to [100000]: ";
|
print "Maximun number to search to [1000000]: ";
|
||||||
$max = <stdin>;
|
$max = <stdin>;
|
||||||
chomp($max);
|
chomp($max);
|
||||||
print "\n";
|
print "\n";
|
||||||
if($max < 1) { $max = 100000; }
|
if($max < 1) { $max = 1000000; }
|
||||||
|
|
||||||
#sources
|
#sources
|
||||||
|
|
||||||
$data{'c'}{'name'} = "C";
|
$data{'cgcc'}{'name'} = "C (gcc)";
|
||||||
$data{'c'}{'src'}= "primes.c";
|
$data{'cgcc'}{'src'}= "primes.c";
|
||||||
$data{'c'}{'prog'} = "primesc";
|
$data{'cgcc'}{'prog'} = "primesgcc";
|
||||||
$data{'c'}{'compiler0'} = "gcc";
|
$data{'cgcc'}{'compiler0'} = "gcc";
|
||||||
$data{'c'}{'cflags0'} = "-lm -O3 -o " . $data{'c'}{'prog'};
|
$data{'cgcc'}{'cflags0'} = "-lm -O3 -o " . $data{'cgcc'}{'prog'};
|
||||||
|
|
||||||
|
$data{'cclang'}{'name'} = "C (clang)";
|
||||||
|
$data{'cclang'}{'src'}= "primes.c";
|
||||||
|
$data{'cclang'}{'prog'} = "primesclang";
|
||||||
|
$data{'cclang'}{'compiler0'} = "clang";
|
||||||
|
$data{'cclang'}{'cflags0'} = "-lm -O3 -o " . $data{'cclang'}{'prog'};
|
||||||
|
|
||||||
$data{'c2'}{'name'} = "C Sieve";
|
$data{'c2'}{'name'} = "C Sieve";
|
||||||
$data{'c2'}{'src'}= "primes.sieve.c";
|
$data{'c2'}{'src'}= "primes.sieve.c";
|
||||||
|
@ -230,6 +236,10 @@ $data{'pl'}{'name'} = "PERL";
|
||||||
$data{'pl'}{'prog'} = "primes.perl.pl";
|
$data{'pl'}{'prog'} = "primes.perl.pl";
|
||||||
$data{'pl'}{'interp0'} = "perl";
|
$data{'pl'}{'interp0'} = "perl";
|
||||||
|
|
||||||
|
$data{'dart'}{'name'} = "Dart";
|
||||||
|
$data{'dart'}{'prog'} = "primes.dart";
|
||||||
|
$data{'dart'}{'interp0'} = "dart";
|
||||||
|
|
||||||
$data{'5c'}{'name'} = "Nickle";
|
$data{'5c'}{'name'} = "Nickle";
|
||||||
$data{'5c'}{'prog'} = "primes.5c";
|
$data{'5c'}{'prog'} = "primes.5c";
|
||||||
$data{'5c'}{'interp0'} = "nickle";
|
$data{'5c'}{'interp0'} = "nickle";
|
||||||
|
@ -291,7 +301,7 @@ $data{'hs'}{'compiler1'} = "interpB";
|
||||||
|
|
||||||
$data{'py'}{'name'} = "Python";
|
$data{'py'}{'name'} = "Python";
|
||||||
$data{'py'}{'prog'} = "primes.py";
|
$data{'py'}{'prog'} = "primes.py";
|
||||||
$data{'py'}{'interp0'} = "python";
|
$data{'py'}{'interp0'} = "python3";
|
||||||
|
|
||||||
$data{'php'}{'name'} = "PHP";
|
$data{'php'}{'name'} = "PHP";
|
||||||
$data{'php'}{'prog'} = "primes.php";
|
$data{'php'}{'prog'} = "primes.php";
|
||||||
|
@ -459,7 +469,10 @@ open(results, ">".$RESULTS) || die("Cannot open $RESULTS\n");
|
||||||
print results "Prime number benchmarks\n";
|
print results "Prime number benchmarks\n";
|
||||||
|
|
||||||
$mach = `uname -a`;
|
$mach = `uname -a`;
|
||||||
print results "Benchmark machine: " . $mach."\n";
|
print results "Benchmark machine: " . $mach;
|
||||||
|
|
||||||
|
print results "Iterations: " . $itr . "\n";
|
||||||
|
print results "Max number searched to: " . $max . "\n\n";
|
||||||
|
|
||||||
# TESTS
|
# TESTS
|
||||||
|
|
||||||
|
@ -574,10 +587,10 @@ foreach $l (@langs)
|
||||||
if(length($compiler) < 5) {print results "\t";}
|
if(length($compiler) < 5) {print results "\t";}
|
||||||
if($data{$l}{"cflagspre$cp"}) { $cmd .= $data{$l}{"cflagspre$cp"};}
|
if($data{$l}{"cflagspre$cp"}) { $cmd .= $data{$l}{"cflagspre$cp"};}
|
||||||
$cmd .= "$comp ";
|
$cmd .= "$comp ";
|
||||||
# So gcc stoped compiling if teh linking was done before the soruce file was specified
|
# So gcc stoped compiling if thh linking was done before the soruce file was specified
|
||||||
# go figure
|
# go figure
|
||||||
$gcc_code = 0;
|
$gcc_code = 0;
|
||||||
if ($l =~ /^o?b?j?ca?[23]?$/) {
|
if ($l =~ /^o?b?j?ca?[23]?(gcc)?$/) {
|
||||||
$gcc_code = 1;
|
$gcc_code = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
void main(List<String> args) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
print("USAGE: dart primes.dart <MAX>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var max = int.parse(args[0]);
|
||||||
|
|
||||||
|
for (var i = 3; i <= max; i += 2) {
|
||||||
|
var cap = sqrt(i);
|
||||||
|
var isPrime = true;
|
||||||
|
for (var j = 3; j <= cap; j += 2) {
|
||||||
|
if (i % j == 0) {
|
||||||
|
isPrime = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isPrime) {
|
||||||
|
print(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
# Python version of a Prime Number Finder
|
# Python version of a Prime Number Finder
|
||||||
# haplo@mindstab.net
|
# haplo@mindstab.net
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ import math
|
||||||
|
|
||||||
try: max = int(sys.argv[1]);
|
try: max = int(sys.argv[1]);
|
||||||
except:
|
except:
|
||||||
print "primes.py <MAX NUM>"
|
print("primes.py <MAX NUM>")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if max < 1:
|
if max < 1:
|
||||||
print "Invalide MAX NUM"
|
print("Invalide MAX NUM")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
for cnt in range(3, max, 2) :
|
for cnt in range(3, max, 2) :
|
||||||
|
@ -23,5 +23,5 @@ for cnt in range(3, max, 2) :
|
||||||
break
|
break
|
||||||
|
|
||||||
if isPrime != 0 :
|
if isPrime != 0 :
|
||||||
print cnt
|
print(cnt)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue