JBehave
  1. JBehave
  2. JBEHAVE-617

Speed up RegexStoryParser by removing leading .*

    Details

    • Type: Improvement Improvement
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.4
    • Fix Version/s: 3.5.4, 3.6
    • Component/s: Core
    • Labels:
      None
    • Patch Submitted:
      Yes
    • Number of attachments :
      1

      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

        Mauro Talevi made changes -
        Field Original Value New Value
        Summary speed up RegexStoryParser by removing leading .* Speed up RegexStoryParser by removing leading .*
        Fix Version/s 3.6 [ 17721 ]
        Mauro Talevi made changes -
        Assignee Mauro Talevi [ maurotalevi ]
        Fix Version/s 3.5.4 [ 18081 ]
        Hide
        Mauro Talevi added a comment -

        Applied with thanks.

        Also created a examples/performance module where we can verify the performance related behaviour.

        Feel free to contribute any story of which you'd want to test performance issues.

        Show
        Mauro Talevi added a comment - Applied with thanks. Also created a examples/performance module where we can verify the performance related behaviour. Feel free to contribute any story of which you'd want to test performance issues.
        Mauro Talevi made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]

          People

          • Assignee:
            Mauro Talevi
            Reporter:
            Laura Dean
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: