# HG changeset patch # User "uncorrelated zombie" # Date 1297900910 -32400 # Node ID d788c88f41bd72d3491be747967738163f4d7323 # Parent 57283e4fdd4b794ceb787ff69a19a9a731211dc5 Rubyのベンチマークを追加。ソースコードは2ch.netの>>178からコピー。 diff -r 57283e4fdd4b -r d788c88f41bd Looping.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Looping.rb Thu Feb 17 09:01:50 2011 +0900 @@ -0,0 +1,24 @@ +#!/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