summaryrefslogtreecommitdiff
path: root/benchmark/other-lang
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-12 23:01:19 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-12 23:01:19 +0000
commitfd81221a8e2c3a8c77599602fe38cd563d86191d (patch)
tree47faf15269b927feb9e4b13fe2d09a51dae4ddfd /benchmark/other-lang
parent1a4b93cf920d0850061ce4b53351b4cdc7d464c7 (diff)
set svn:eol-style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark/other-lang')
-rw-r--r--benchmark/other-lang/ack.pl22
-rw-r--r--benchmark/other-lang/ack.py32
-rw-r--r--benchmark/other-lang/ack.rb24
-rw-r--r--benchmark/other-lang/ack.scm14
-rw-r--r--benchmark/other-lang/eval.rb132
-rw-r--r--benchmark/other-lang/fact.pl26
-rw-r--r--benchmark/other-lang/fact.py36
-rw-r--r--benchmark/other-lang/fact.rb26
-rw-r--r--benchmark/other-lang/fact.scm16
-rw-r--r--benchmark/other-lang/fib.pl22
-rw-r--r--benchmark/other-lang/fib.py14
-rw-r--r--benchmark/other-lang/fib.rb18
-rw-r--r--benchmark/other-lang/fib.scm14
-rw-r--r--benchmark/other-lang/loop.pl6
-rw-r--r--benchmark/other-lang/loop.py4
-rw-r--r--benchmark/other-lang/loop.rb8
-rw-r--r--benchmark/other-lang/loop.scm2
-rw-r--r--benchmark/other-lang/loop2.rb2
-rw-r--r--benchmark/other-lang/tak.pl22
-rw-r--r--benchmark/other-lang/tak.py16
-rw-r--r--benchmark/other-lang/tak.rb26
-rw-r--r--benchmark/other-lang/tak.scm20
22 files changed, 251 insertions, 251 deletions
diff --git a/benchmark/other-lang/ack.pl b/benchmark/other-lang/ack.pl
index 8933c33ae5..201e22ddfa 100644
--- a/benchmark/other-lang/ack.pl
+++ b/benchmark/other-lang/ack.pl
@@ -1,11 +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);
+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/benchmark/other-lang/ack.py b/benchmark/other-lang/ack.py
index 971796f689..9968e7cfcf 100644
--- a/benchmark/other-lang/ack.py
+++ b/benchmark/other-lang/ack.py
@@ -1,16 +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()
+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/benchmark/other-lang/ack.rb b/benchmark/other-lang/ack.rb
index 7886183ff0..7451bed6c4 100644
--- a/benchmark/other-lang/ack.rb
+++ b/benchmark/other-lang/ack.rb
@@ -1,12 +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)
+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/benchmark/other-lang/ack.scm b/benchmark/other-lang/ack.scm
index e9e1886933..a80b73ba55 100644
--- a/benchmark/other-lang/ack.scm
+++ b/benchmark/other-lang/ack.scm
@@ -1,7 +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)
-
+(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/benchmark/other-lang/eval.rb b/benchmark/other-lang/eval.rb
index e6ff94d294..3875927389 100644
--- a/benchmark/other-lang/eval.rb
+++ b/benchmark/other-lang/eval.rb
@@ -1,66 +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")
-}
-
+
+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/benchmark/other-lang/fact.pl b/benchmark/other-lang/fact.pl
index 2cef18534c..a9b0b69cdf 100644
--- a/benchmark/other-lang/fact.pl
+++ b/benchmark/other-lang/fact.pl
@@ -1,13 +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);
-}
+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/benchmark/other-lang/fact.py b/benchmark/other-lang/fact.py
index 460e4057f4..01593965d9 100644
--- a/benchmark/other-lang/fact.py
+++ b/benchmark/other-lang/fact.py
@@ -1,18 +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)
-
+#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/benchmark/other-lang/fact.rb b/benchmark/other-lang/fact.rb
index c75320824c..7e97b22b39 100644
--- a/benchmark/other-lang/fact.rb
+++ b/benchmark/other-lang/fact.rb
@@ -1,13 +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
+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/benchmark/other-lang/fact.scm b/benchmark/other-lang/fact.scm
index 511990f797..c98a7fedd3 100644
--- a/benchmark/other-lang/fact.scm
+++ b/benchmark/other-lang/fact.scm
@@ -1,8 +1,8 @@
-(define (fact n)
- (if (< n 2)
- 1
- (* n (fact (- n 1)))))
-
-(dotimes (i 10000)
- (fact 100))
-
+(define (fact n)
+ (if (< n 2)
+ 1
+ (* n (fact (- n 1)))))
+
+(dotimes (i 10000)
+ (fact 100))
+
diff --git a/benchmark/other-lang/fib.pl b/benchmark/other-lang/fib.pl
index d660a2337b..a46f666d1e 100644
--- a/benchmark/other-lang/fib.pl
+++ b/benchmark/other-lang/fib.pl
@@ -1,11 +1,11 @@
-sub fib{
- my $n = $_[0];
- if($n < 3){
- return 1;
- }
- else{
- return fib($n-1) + fib($n-2);
- }
-};
-
-&fib(34);
+sub fib{
+ my $n = $_[0];
+ if($n < 3){
+ return 1;
+ }
+ else{
+ return fib($n-1) + fib($n-2);
+ }
+};
+
+&fib(34);
diff --git a/benchmark/other-lang/fib.py b/benchmark/other-lang/fib.py
index 40f87f3e9c..45f2bceb8d 100644
--- a/benchmark/other-lang/fib.py
+++ b/benchmark/other-lang/fib.py
@@ -1,7 +1,7 @@
-def fib(n):
- if n < 3:
- return 1
- else:
- return fib(n-1) + fib(n-2)
-
-fib(34)
+def fib(n):
+ if n < 3:
+ return 1
+ else:
+ return fib(n-1) + fib(n-2)
+
+fib(34)
diff --git a/benchmark/other-lang/fib.rb b/benchmark/other-lang/fib.rb
index 7e0e8daa7e..ec587eabe0 100644
--- a/benchmark/other-lang/fib.rb
+++ b/benchmark/other-lang/fib.rb
@@ -1,9 +1,9 @@
-def fib n
- if n < 3
- 1
- else
- fib(n-1) + fib(n-2)
- end
-end
-
-fib(34)
+def fib n
+ if n < 3
+ 1
+ else
+ fib(n-1) + fib(n-2)
+ end
+end
+
+fib(34)
diff --git a/benchmark/other-lang/fib.scm b/benchmark/other-lang/fib.scm
index ea63503b11..2fc4e225bd 100644
--- a/benchmark/other-lang/fib.scm
+++ b/benchmark/other-lang/fib.scm
@@ -1,7 +1,7 @@
-(define (fib n)
- (if (< n 3)
- 1
- (+ (fib (- n 1)) (fib (- n 2)))))
-
-(fib 34)
-
+(define (fib n)
+ (if (< n 3)
+ 1
+ (+ (fib (- n 1)) (fib (- n 2)))))
+
+(fib 34)
+
diff --git a/benchmark/other-lang/loop.pl b/benchmark/other-lang/loop.pl
index ecacef4477..2777490aaa 100644
--- a/benchmark/other-lang/loop.pl
+++ b/benchmark/other-lang/loop.pl
@@ -1,3 +1,3 @@
-for($i=0; $i<30000000; $i++){
-}
-
+for($i=0; $i<30000000; $i++){
+}
+
diff --git a/benchmark/other-lang/loop.py b/benchmark/other-lang/loop.py
index b47089fd39..003749bf3a 100644
--- a/benchmark/other-lang/loop.py
+++ b/benchmark/other-lang/loop.py
@@ -1,2 +1,2 @@
-for i in xrange(30000000):
- pass
+for i in xrange(30000000):
+ pass
diff --git a/benchmark/other-lang/loop.rb b/benchmark/other-lang/loop.rb
index 35cd67a7a3..d43cef61f3 100644
--- a/benchmark/other-lang/loop.rb
+++ b/benchmark/other-lang/loop.rb
@@ -1,4 +1,4 @@
-i=0
-while i<30000000
- i+=1
-end
+i=0
+while i<30000000
+ i+=1
+end
diff --git a/benchmark/other-lang/loop.scm b/benchmark/other-lang/loop.scm
index 1646ac3c1d..3364f7e679 100644
--- a/benchmark/other-lang/loop.scm
+++ b/benchmark/other-lang/loop.scm
@@ -1 +1 @@
-(dotimes (x 30000000))
+(dotimes (x 30000000))
diff --git a/benchmark/other-lang/loop2.rb b/benchmark/other-lang/loop2.rb
index f3085926a3..df8fffc1ff 100644
--- a/benchmark/other-lang/loop2.rb
+++ b/benchmark/other-lang/loop2.rb
@@ -1 +1 @@
-30000000.times{}
+30000000.times{}
diff --git a/benchmark/other-lang/tak.pl b/benchmark/other-lang/tak.pl
index c7bb626e61..7e748a67c6 100644
--- a/benchmark/other-lang/tak.pl
+++ b/benchmark/other-lang/tak.pl
@@ -1,11 +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);
+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/benchmark/other-lang/tak.py b/benchmark/other-lang/tak.py
index 9b7bd8f23c..04f3f6829c 100644
--- a/benchmark/other-lang/tak.py
+++ b/benchmark/other-lang/tak.py
@@ -1,8 +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)
+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/benchmark/other-lang/tak.rb b/benchmark/other-lang/tak.rb
index d70d5db8f8..efe5380f4e 100644
--- a/benchmark/other-lang/tak.rb
+++ b/benchmark/other-lang/tak.rb
@@ -1,13 +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)
-
+
+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/benchmark/other-lang/tak.scm b/benchmark/other-lang/tak.scm
index 45cc576767..52a7629ee5 100644
--- a/benchmark/other-lang/tak.scm
+++ b/benchmark/other-lang/tak.scm
@@ -1,10 +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)
-
-
+(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)
+
+