From: Bob Hutchison Date: 2006-05-23T05:36:28+09:00 Subject: Re: Zed and Luis drop the bomb on Ruby's poor performance On May 22, 2006, at 3:49 PM, Sam Roberts wrote: > I even tried using symbols instead of strings, I expected from lisp > experience that symbol comparisons would be really fast, but they > are only slightly faster (for strings of the size I'm working with > anyway). ** Don't forget that string comparison is pretty quick if the strings differ in the first character. If you try comparing to the same string and make the string a lot longer (say 2000 characters) you'll get a situation where symbol comparisons are about three times faster than string comparisons. You also need a better noop. If you call a method in there that does nothing then I'm getting: user system total real noop 0.490000 0.000000 0.490000 ( 0.664154) do nothing method 1.650000 0.030000 1.680000 ( 2.501031) String#== 3.030000 0.040000 3.070000 ( 4.191784) String#eql? 2.930000 0.030000 2.960000 ( 4.237489) String#equal? 1.300000 0.010000 1.310000 ( 1.858182) Symbol#== 1.310000 0.020000 1.330000 ( 1.979673) Symbol#eql? 1.300000 0.010000 1.310000 ( 2.036749) Symbol#equal? 1.310000 0.010000 1.320000 ( 1.727041) (this is on OS X... ignore the real time since it is pretty much random on OS X) Have you tried profiling your code? ---- Bob Hutchison -- blogs at Recursive Design Inc. -- Raconteur -- xampl for Ruby --