comparison Looping.rb @ 4:d788c88f41bd >>178

Rubyのベンチマークを追加。ソースコードは2ch.netの>>178からコピー。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Thu, 17 Feb 2011 09:01:50 +0900
parents
children 30da8c1da4d4
comparison
equal deleted inserted replaced
3:57283e4fdd4b 4:d788c88f41bd
1 #!/usr/bin/env ruby
2 class Looping
3 def initialize()
4 @n0 = 0
5 end
6 def calc(n)
7 n1 = @n0 + (1 - 2*(n%2))
8 @n0 = n
9 n1
10 end
11 end
12
13 if __FILE__ == $0
14 s = Looping.new
15 c = 0
16 n = 1
17 t1 = Time.now
18 while c<2147483647
19 n = s.calc(n)
20 c+=1
21 end
22 t2 = Time.now
23 puts "#{n} Ruby\t#{t2-t1}"
24 end