Is faster handling hexadecimal values than handling chars?

Hi, could I know if it’s faster using hexadecimal values instead of
charsm in Ruby?
I mean:

a) char =~ /[\x61-\x7A]|[\x41-\x5A]/

b) char =~ /[A-Z]|[a-z]/

Both are the same, but maybe a) operation is faster than b) ?

Thanks a lot.

2008/4/15, Iñaki Baz C. [email protected]:

Hi, could I know if it’s faster using hexadecimal values instead of
charsm in Ruby?
I mean:

a) char =~ /[\x61-\x7A]|[\x41-\x5A]/

b) char =~ /[A-Z]|[a-z]/

Both are the same, but maybe a) operation is faster than b) ?

Sorry, I’ve found Benchmark Class and have tried it:

Benchmark.realtime {‘f’ =~ /[\x61-\x7A]|[\x41-\x5A]/ }
=> 1.81198120117188e-05

Benchmark.realtime {‘f’ =~ /[A-Z]|[a-z]/ }
=> 1.81198120117188e-05

both give similar results.

Best regards.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs