String#include? vs. String#match

Interesting phenomenon; for finding whenever some string occurs inside other string, String#match is 5 (!) times faster than String#include? for long strings (50k), and 2 times slower for short strings (tens of bytes).
The slowness can be explained by the time it takes to compile the regexp.
But how can it be so slow for long strings? Going to ask this in ruby.core.

Leave a Reply

Pages

Adsense