Regexps Profiling

I

Igor Maximchuk

Hello,

I was recently using module 'profile' to profile code, that used Regexps. It
was discovered, that Regexp or String class methods usage (Regexp#match,
String:#=~) is being profiled only when there exists explicit call like
r.match(s)
or s =~ r, while s =~ /foo/ is not considered as a method call.
And some testing shows, that s =~ /foo/ is a little faster than r.match(s)

Questions:
Are Regexp#match, String#scan, etc actually wrappings for something
"internal" (=~)?
How is this related to object-oriented regular expressions paradigm?

example code:

require 'profile'

s = "abc"
r = /(.)/
s =~ /(.)/
#r.match(s) #uncomment to see the difference
#s =~ r #uncomment to see the difference
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,088
Members
48,773
Latest member
Kaybee

Latest Threads

Top