From: Rick DeNatale Date: 2006-10-27T22:40:22+09:00 Subject: Re: String#== vs. Symbol#== speed (was Re: Symbol < String in Ruby > 1.8) On 10/27/06, Yukihiro Matsumoto wrote: > Try the following program to see the > comparison performance difference between Strings and Symbols. > > require 'benchmark' > require 'pp' > > str0 = "a" * 2000 > str1 = str0.dup > str1[-1] = "b" sym0 = str0.to_sym sym1 = str1.to_sym > > $N = 1000000 ... And for the kids who didn't try this at home: rick@frodo:/public/rubyscripts$ ruby matzsymbolbm.rb user system total real noop 0.770000 0.000000 0.770000 ( 0.834606) String#== 24.860000 0.560000 25.420000 ( 33.240050) Symbol#== 2.660000 0.380000 3.040000 ( 3.363099) So under these, more realistic, conditions, Symbol comparison is nearly a 10x improvement. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/