From: Nathan Ahmed Date: 2012-08-17T19:24:25+09:00 Subject: Re: case vs if-else --e89a8ff1c4ea5bb32604c77390a3 Content-Type: text/plain; charset=ISO-8859-1 So then what is the point of ruby if it's just for human-readability? Isn't it all about functionality? What good are interpreted languages? Not saying they aren't, yet still. On Fri, Aug 17, 2012 at 12:03 AM, Regis d'Aubarede wrote: > Hello, > > test done with : > > a="x" > if a=="b" then 2 > elsif a=="c" then 1 > elsif a=="c" then 1 > .... 50 elsif > > a="x" > case a > when "g" then 1 > when "i" then 1 > when "j" then 1 > when "k" then 1 > when "l" then 1 > when "b" then 1 > .... 50 when > > 10 microsecondes with if, > 231 nanosecondes with case > > I use benchi, (from ruiby, see attachment), for this kind of test. > If you need performences, try mirah with a jvm ... > > Attachments: > http://www.ruby-forum.com/attachment/7683/benchi.png > > > -- > Posted via http://www.ruby-forum.com/. > > --e89a8ff1c4ea5bb32604c77390a3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable So then what is the point of ruby if it's just for human-readability? I= sn't it all about functionality? What good are interpreted languages? N= ot saying they aren't, yet still.

On = Fri, Aug 17, 2012 at 12:03 AM, Regis d'Aubarede <<= a href=3D"mailto:lists@ruby-forum.com" target=3D"_blank">lists@ruby-forum.c= om> wrote:
Hello,

test done with :

a=3D"x"
if a=3D=3D"b" then 2
elsif a=3D=3D"c" then 1
elsif a=3D=3D"c" then 1
.... 50 elsif

a=3D"x"
case a
=A0when "g" then 1
=A0when "i" then 1
=A0when =A0"j" then 1
=A0when "k" then 1
=A0when "l" then 1
=A0when "b" then 1
.... 50 when

10 microsecondes with if,
231 nanosecondes with case

I use benchi, (from ruiby, see attachment), for this kind of test.
If you need performences, try mirah with a jvm ...

Attachments:
http://www.ruby-forum.com/attachment/7683/benchi.png

--e89a8ff1c4ea5bb32604c77390a3--