view Looping.rb @ 7:69b8c75e9c24 default

Scalaのソースコードを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Fri, 18 Feb 2011 10:32:06 +0900
parents 861b93741d60
children 30da8c1da4d4
line wrap: on
line source

#!/usr/bin/env ruby
class Looping
 def initialize
    @n0 = 0
 end

 def calc(n)
    n1 = @n0 + (1 - 2*(n%2))
    @n0 = n
    return n1
 end
end

l = Looping.new
n = 1
t1 = Time.now
2147483647.times{ |c|
 n = l.calc(n)
}
t2 = Time.now
print "#{n}\nRuby\t#{t2 - t1}\n"