summaryrefslogtreecommitdiff
path: root/trunk/benchmark/other-lang
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/benchmark/other-lang')
-rw-r--r--trunk/benchmark/other-lang/ack.pl11
-rw-r--r--trunk/benchmark/other-lang/ack.py16
-rw-r--r--trunk/benchmark/other-lang/ack.rb12
-rw-r--r--trunk/benchmark/other-lang/ack.scm7
-rw-r--r--trunk/benchmark/other-lang/eval.rb66
-rw-r--r--trunk/benchmark/other-lang/fact.pl13
-rw-r--r--trunk/benchmark/other-lang/fact.py18
-rw-r--r--trunk/benchmark/other-lang/fact.rb13
-rw-r--r--trunk/benchmark/other-lang/fact.scm8
-rw-r--r--trunk/benchmark/other-lang/fib.pl11
-rw-r--r--trunk/benchmark/other-lang/fib.py7
-rw-r--r--trunk/benchmark/other-lang/fib.rb9
-rw-r--r--trunk/benchmark/other-lang/fib.scm7
-rw-r--r--trunk/benchmark/other-lang/loop.pl3
-rw-r--r--trunk/benchmark/other-lang/loop.py2
-rw-r--r--trunk/benchmark/other-lang/loop.rb4
-rw-r--r--trunk/benchmark/other-lang/loop.scm1
-rw-r--r--trunk/benchmark/other-lang/loop2.rb1
-rw-r--r--trunk/benchmark/other-lang/tak.pl11
-rw-r--r--trunk/benchmark/other-lang/tak.py8
-rw-r--r--trunk/benchmark/other-lang/tak.rb13
-rw-r--r--trunk/benchmark/other-lang/tak.scm10
22 files changed, 251 insertions, 0 deletions
diff --git a/trunk/benchmark/other-lang/ack.pl b/trunk/benchmark/other-lang/ack.pl
new file mode 100644
index 0000000000..201e22ddfa
--- /dev/null
+++ b/trunk/benchmark/other-lang/ack.pl
@@ -0,0 +1,11 @@
+use integer;
+
+sub Ack {
+ return $_[0] ? ($_[1] ? Ack($_[0]-1, Ack($_[0], $_[1]-1))
+ : Ack($_[0]-1, 1))
+ : $_[1]+1;
+}
+
+my $NUM = 9;
+$NUM = 1 if ($NUM < 1);
+my $ack = Ack(3, $NUM);
diff --git a/trunk/benchmark/other-lang/ack.py b/trunk/benchmark/other-lang/ack.py
new file mode 100644
index 0000000000..9968e7cfcf
--- /dev/null
+++ b/trunk/benchmark/other-lang/ack.py
@@ -0,0 +1,16 @@
+import sys
+sys.setrecursionlimit(5000000)
+
+def Ack(M, N):
+ if (not M):
+ return( N + 1 )
+ if (not N):
+ return( Ack(M-1, 1) )
+ return( Ack(M-1, Ack(M, N-1)) )
+
+def main():
+ NUM = 9
+ sys.setrecursionlimit(10000)
+ Ack(3, NUM)
+
+main()
diff --git a/trunk/benchmark/other-lang/ack.rb b/trunk/benchmark/other-lang/ack.rb
new file mode 100644
index 0000000000..7451bed6c4
--- /dev/null
+++ b/trunk/benchmark/other-lang/ack.rb
@@ -0,0 +1,12 @@
+def ack(m, n)
+ if m == 0 then
+ n + 1
+ elsif n == 0 then
+ ack(m - 1, 1)
+ else
+ ack(m - 1, ack(m, n - 1))
+ end
+end
+
+NUM = 9
+ack(3, NUM)
diff --git a/trunk/benchmark/other-lang/ack.scm b/trunk/benchmark/other-lang/ack.scm
new file mode 100644
index 0000000000..a80b73ba55
--- /dev/null
+++ b/trunk/benchmark/other-lang/ack.scm
@@ -0,0 +1,7 @@
+(define (ack m n)
+ (cond ((zero? m) (+ n 1))
+ ((zero? n) (ack (- m 1) 1))
+ (else (ack (- m 1) (ack m (- n 1))))))
+
+(ack 3 9)
+
diff --git a/trunk/benchmark/other-lang/eval.rb b/trunk/benchmark/other-lang/eval.rb
new file mode 100644
index 0000000000..3875927389
--- /dev/null
+++ b/trunk/benchmark/other-lang/eval.rb
@@ -0,0 +1,66 @@
+
+Bench = %w(
+ loop
+ ack
+ fib
+ tak
+ fact
+)
+
+Lang = <<EOP.map{|l| l.strip}
+ ruby-cyg
+ ../../../test6/miniruby
+ perl
+ python
+ gosh
+EOP
+
+Bench.replace ['loop2']
+Lang.replace ['ruby-cyg']
+
+Ext = %w(
+ .rb
+ .rb
+ .pl
+ .py
+ .scm
+)
+
+p Bench
+p Lang
+
+require 'benchmark'
+
+def bench cmd
+ m = Benchmark.measure{
+ #p cmd
+ system(cmd)
+ }
+ [m.utime, m.real]
+end
+
+Result = []
+Bench.each{|b|
+ r = []
+ Lang.each_with_index{|l, idx|
+ cmd = "#{l} #{b}#{Ext[idx]}"
+ r << bench(cmd)
+ }
+ Result << r
+}
+
+require 'pp'
+# utime
+puts Lang.join("\t")
+Bench.each_with_index{|b, bi|
+ print b, "\t"
+ puts Result[bi].map{|e| e[0]}.join("\t")
+}
+
+# rtime
+puts Lang.join("\t")
+Bench.each_with_index{|b, bi|
+ print b, "\t"
+ puts Result[bi].map{|e| e[1]}.join("\t")
+}
+
diff --git a/trunk/benchmark/other-lang/fact.pl b/trunk/benchmark/other-lang/fact.pl
new file mode 100644
index 0000000000..a9b0b69cdf
--- /dev/null
+++ b/trunk/benchmark/other-lang/fact.pl
@@ -0,0 +1,13 @@
+sub fact{
+ my $n = @_[0];
+ if($n < 2){
+ return 1;
+ }
+ else{
+ return $n * fact($n-1);
+ }
+}
+
+for($i=0; $i<10000; $i++){
+ &fact(100);
+}
diff --git a/trunk/benchmark/other-lang/fact.py b/trunk/benchmark/other-lang/fact.py
new file mode 100644
index 0000000000..01593965d9
--- /dev/null
+++ b/trunk/benchmark/other-lang/fact.py
@@ -0,0 +1,18 @@
+#import sys
+#sys.setrecursionlimit(1000)
+
+def factL(n):
+ r = 1
+ for x in range(2, n):
+ r *= x
+ return r
+
+def factR(n):
+ if n < 2:
+ return 1
+ else:
+ return n * factR(n-1)
+
+for i in range(10000):
+ factR(100)
+
diff --git a/trunk/benchmark/other-lang/fact.rb b/trunk/benchmark/other-lang/fact.rb
new file mode 100644
index 0000000000..7e97b22b39
--- /dev/null
+++ b/trunk/benchmark/other-lang/fact.rb
@@ -0,0 +1,13 @@
+def fact(n)
+ if n < 2
+ 1
+ else
+ n * fact(n-1)
+ end
+end
+
+i=0
+while i<10000
+ i+=1
+ fact(100)
+end
diff --git a/trunk/benchmark/other-lang/fact.scm b/trunk/benchmark/other-lang/fact.scm
new file mode 100644
index 0000000000..c98a7fedd3
--- /dev/null
+++ b/trunk/benchmark/other-lang/fact.scm
@@ -0,0 +1,8 @@
+(define (fact n)
+ (if (< n 2)
+ 1
+ (* n (fact (- n 1)))))
+
+(dotimes (i 10000)
+ (fact 100))
+
diff --git a/trunk/benchmark/other-lang/fib.pl b/trunk/benchmark/other-lang/fib.pl
new file mode 100644
index 0000000000..a46f666d1e
--- /dev/null
+++ b/trunk/benchmark/other-lang/fib.pl
@@ -0,0 +1,11 @@
+sub fib{
+ my $n = $_[0];
+ if($n < 3){
+ return 1;
+ }
+ else{
+ return fib($n-1) + fib($n-2);
+ }
+};
+
+&fib(34);
diff --git a/trunk/benchmark/other-lang/fib.py b/trunk/benchmark/other-lang/fib.py
new file mode 100644
index 0000000000..45f2bceb8d
--- /dev/null
+++ b/trunk/benchmark/other-lang/fib.py
@@ -0,0 +1,7 @@
+def fib(n):
+ if n < 3:
+ return 1
+ else:
+ return fib(n-1) + fib(n-2)
+
+fib(34)
diff --git a/trunk/benchmark/other-lang/fib.rb b/trunk/benchmark/other-lang/fib.rb
new file mode 100644
index 0000000000..ec587eabe0
--- /dev/null
+++ b/trunk/benchmark/other-lang/fib.rb
@@ -0,0 +1,9 @@
+def fib n
+ if n < 3
+ 1
+ else
+ fib(n-1) + fib(n-2)
+ end
+end
+
+fib(34)
diff --git a/trunk/benchmark/other-lang/fib.scm b/trunk/benchmark/other-lang/fib.scm
new file mode 100644
index 0000000000..2fc4e225bd
--- /dev/null
+++ b/trunk/benchmark/other-lang/fib.scm
@@ -0,0 +1,7 @@
+(define (fib n)
+ (if (< n 3)
+ 1
+ (+ (fib (- n 1)) (fib (- n 2)))))
+
+(fib 34)
+
diff --git a/trunk/benchmark/other-lang/loop.pl b/trunk/benchmark/other-lang/loop.pl
new file mode 100644
index 0000000000..2777490aaa
--- /dev/null
+++ b/trunk/benchmark/other-lang/loop.pl
@@ -0,0 +1,3 @@
+for($i=0; $i<30000000; $i++){
+}
+
diff --git a/trunk/benchmark/other-lang/loop.py b/trunk/benchmark/other-lang/loop.py
new file mode 100644
index 0000000000..003749bf3a
--- /dev/null
+++ b/trunk/benchmark/other-lang/loop.py
@@ -0,0 +1,2 @@
+for i in xrange(30000000):
+ pass
diff --git a/trunk/benchmark/other-lang/loop.rb b/trunk/benchmark/other-lang/loop.rb
new file mode 100644
index 0000000000..d43cef61f3
--- /dev/null
+++ b/trunk/benchmark/other-lang/loop.rb
@@ -0,0 +1,4 @@
+i=0
+while i<30000000
+ i+=1
+end
diff --git a/trunk/benchmark/other-lang/loop.scm b/trunk/benchmark/other-lang/loop.scm
new file mode 100644
index 0000000000..3364f7e679
--- /dev/null
+++ b/trunk/benchmark/other-lang/loop.scm
@@ -0,0 +1 @@
+(dotimes (x 30000000))
diff --git a/trunk/benchmark/other-lang/loop2.rb b/trunk/benchmark/other-lang/loop2.rb
new file mode 100644
index 0000000000..df8fffc1ff
--- /dev/null
+++ b/trunk/benchmark/other-lang/loop2.rb
@@ -0,0 +1 @@
+30000000.times{}
diff --git a/trunk/benchmark/other-lang/tak.pl b/trunk/benchmark/other-lang/tak.pl
new file mode 100644
index 0000000000..7e748a67c6
--- /dev/null
+++ b/trunk/benchmark/other-lang/tak.pl
@@ -0,0 +1,11 @@
+sub tak {
+ local($x, $y, $z) = @_;
+ if (!($y < $x)) {
+ return $z;
+ } else {
+ return &tak(&tak($x - 1, $y, $z),
+ &tak($y - 1, $z, $x),
+ &tak($z - 1, $x, $y));
+ }
+}
+&tak(18, 9, 0);
diff --git a/trunk/benchmark/other-lang/tak.py b/trunk/benchmark/other-lang/tak.py
new file mode 100644
index 0000000000..04f3f6829c
--- /dev/null
+++ b/trunk/benchmark/other-lang/tak.py
@@ -0,0 +1,8 @@
+def tak(x, y, z):
+ if not(y<x):
+ return z
+ else:
+ return tak(tak(x-1, y, z),
+ tak(y-1, z, x),
+ tak(z-1, x, y))
+tak(18, 9, 0)
diff --git a/trunk/benchmark/other-lang/tak.rb b/trunk/benchmark/other-lang/tak.rb
new file mode 100644
index 0000000000..efe5380f4e
--- /dev/null
+++ b/trunk/benchmark/other-lang/tak.rb
@@ -0,0 +1,13 @@
+
+def tak x, y, z
+ unless y < x
+ z
+ else
+ tak( tak(x-1, y, z),
+ tak(y-1, z, x),
+ tak(z-1, x, y))
+ end
+end
+
+tak(18, 9, 0)
+
diff --git a/trunk/benchmark/other-lang/tak.scm b/trunk/benchmark/other-lang/tak.scm
new file mode 100644
index 0000000000..52a7629ee5
--- /dev/null
+++ b/trunk/benchmark/other-lang/tak.scm
@@ -0,0 +1,10 @@
+(define (tak x y z)
+ (if (not (< y x))
+ z
+ (tak (tak (- x 1) y z)
+ (tak (- y 1) z x)
+ (tak (- z 1) x y))))
+
+(tak 18 9 0)
+
+