Speed up RegexStoryParser by removing leading .*

Description

We noticed our jbehave tests taking a long time. Mostly our fault, but also a surprising amount of time spent in Matcher.find() from RegexStoryParser, said the profiler. Who knew? Turns out, that happens when you call find() on long lines and your regex starts with .* , as this guy explains:
http://www.fasterj.com/articles/regex2.shtml

So we removed it, and our tests ran a little faster. (We removed it only from the expressions used with find(); we didn't touch the ones using matches().)

And your tests run a lot faster!

Unfortunately, I don't know how to prevent regression here. I don't see performance tests, and the behavior didn't change. (You can note how long things take on the continuous integration server, though.) And it's pretty easy to imagine someone coming through and making the regular expressions all look the same. Still, there you have it.

Activity

Show:
Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created October 18, 2011 at 8:09 PM
Updated May 22, 2015 at 8:20 AM
Resolved November 27, 2011 at 12:49 PM