[Boulder Ruby Group] Anyone else see this?
ara.t.howard
ara.t.howard at gmail.com
Sat Jun 30 02:42:12 EDT 2007
On Jun 29, 2007, at 11:54 PM, Tony Arcieri wrote:
> http://m.onkey.org/2007/6/30/let-s-start-with-wtf
>
> Just did my own little test...
>
> ~$ irb -rbenchmark -rubygems -ractive_support
> >> class Fixnum; def timestwo; self * 2; end; end
> => nil
> >> puts Benchmark.measure { (1..10000000).map { |n| n.timestwo } }
> 13.570000 0.100000 13.670000 ( 13.795564)
> => nil
> >> puts Benchmark.measure { (1..10000000).map(&:timestwo) }
> 48.370000 0.080000 48.450000 ( 48.517666)
> => nil
>
> Yikes
>
> --
> Tony Arcieri
> ClickCaster, Inc.
> tony at clickcaster.com
> _______________________________________________
> Bdrg-members mailing list
> Bdrg-members at rubyforge.org
> http://rubyforge.org/mailman/listinfo/bdrg-members
less capable.
cfp:~ > cat a.rb
require 'benchmark'
class Symbol
def to_proc
lambda{|obj| obj.send self}
end
end
n = 10000
s = Struct.new :id
messages = []
n.times { messages << s.new(:id => rand(n)) }
Benchmark.bm do |x|
# Integer
x.report { n.times { messages.map{|m| m.id} } }
x.report { n.times { messages.map(&:id) } }
end
cfp:~ > ruby a.rb
user system total real
31.160000 1.200000 32.360000 ( 33.135435)
40.640000 1.380000 42.020000 ( 43.270193)
-a
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/bdrg-members/attachments/20070630/fdbc9c9f/attachment.html
More information about the Bdrg-members
mailing list