view 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
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
	n1
	end
end

if __FILE__ == $0
	s = Looping.new
	c = 0
	n = 1
	t1 = Time.now
	while c<2147483647
		n = s.calc(n)
		c+=1
	end
	t2 = Time.now
	puts "#{n} Ruby\t#{t2-t1}"
end