From: Srinivas JONNALAGADDA Date: 2006-09-15T22:32:22+09:00 Subject: Re: Benchmark for Ruby On Fri, 2006-09-15 at 21:43 +0900, Francis Cianfrocca wrote: > Some of the surprises: Symbol#=== is really slow. Replace case statements > against Symbols with if/then constructions. I have a lot of requirement of the kind shown below, where ':asdf' would be passed in as a parameter. I have written trivial versions of both 'case' and 'if/elsif/else'. The difference is very little, even over 10 million comparisons. But, in fact, 'case' seems to be faster. js@srinivasj:~> cat tmp/test/1.rb def timer b = Time.now yield e = Time.now puts "Time taken is #{e - b} seconds." end timer do 10_000_000.times do | __ | x = case :asdf when :a 'a' when :b 'b' when :c 'c' when :d 'd' when :e 'e' else 'asdf' end end end timer do 10_000_000.times do | __ | x = if :asdf == :a 'a' elsif :asdf == :b 'b' elsif :asdf == :c 'c' elsif :asdf == :d 'd' elsif :asdf == :e 'e' else 'asdf' end end end Were you referring to some other kind of 'if/then'? I am very interested in this, since, as I mentioned above, I need this construct several times. Greetings, JS