tags:

views:

132

answers:

3

Anyone has experience measuring glibc regexp functions? Are there any generic tests I need to run to make such a measurements (in addition to testing the exact patterns I intend to search)?

Thanks.

+1  A: 

Regular expression performance depends much on which regular expression you're using and which data you're applying it to. There's little point in just benchmarking a bunch of regular expressions. You have to compare actual code using a regex and your actual plain C alternative on your actual data.

As a rule of thumb, I'd say that if you already have properly functioning procedural code to do the text matching you need, just leave that in place. If you don't have that code yet, I recommend to start with regexes as you'll save yourself much development time (assuming you're familiar with regexes). You can probably write procedural code that is faster than the equivalent regex, but the difference isn't going to be dramatic. The effort of writing and maintaining the procedural code will be significantly higher than using a regex.

Jan Goyvaerts
A: 

take a look http://www.boost.org/doc/libs/1_41_0/libs/regex/doc/gcc-performance.html

guner
Cool! Thanks. I though people never even look at such old questions.
Jack
+1  A: 

Are you using hand-written char-by-char comparison, standard string matching functions, or smart text-matching algorithms?

In the former case especially, switching to regexp may even be faster, depending on the kind of regexp and the library you use (there isn't only glibc, there's plenty of libraries around: PCRE, the ones listed here and much more).

Blaisorblade