-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Java] Improve expression creation performance #187
Conversation
Improved expression creation performance by about 50%.
Added test case for empty cucumber expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers, this looks good but it is liable to be cleaned up by someone who things this code is very ugly.
java/src/main/java/io/cucumber/cucumberexpressions/ExpressionFactory.java
Outdated
Show resolved
Hide resolved
java/src/main/java/io/cucumber/cucumberexpressions/ExpressionFactory.java
Show resolved
Hide resolved
java/src/main/java/io/cucumber/cucumberexpressions/ExpressionFactory.java
Outdated
Show resolved
Hide resolved
java/src/main/java/io/cucumber/cucumberexpressions/ExpressionFactory.java
Outdated
Show resolved
Hide resolved
Refactored code according to PR comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'll try and merge and release this soonish.
I made a benchmark with JMH which shows that the modified method is about 15% faster (see escapeRegex2 below) : Benchmark Mode Cnt Score Error Units CucumberExpressionBenchmark.escapeRegex0 thrpt 25 726563,091 Β± 15558,020 ops/s CucumberExpressionBenchmark.escapeRegex1 thrpt 25 782046,026 Β± 10993,804 ops/s CucumberExpressionBenchmark.escapeRegex2 thrpt 25 833512,235 Β± 25088,968 ops/s The `CucumberExpression` class looks extensively tested, thus I didn't added more test cases. Note: for completeness, I tested another variant (escapeRegex1) which replaces the `ESCAPE_PATTERN.matcher(text).replaceAll(String)` with multiple `String.replace(String,String)` : the performance is not that good (only 8% faster than the original method) and code readability/maintenance is bad. But it was interesting to have the numbers to compare...
In order to keep the implementations consistent I think it would be a good idea to port this to the other implementations too. |
I added |
Well done. I've ran my suite of ~1000 scenarios in dry-run mode and instead of 37s I've got 13s with the latest release. Almost 300% performance boost. |
@jkronegg now available in Cucumber 7.10. Much appreciated! |
π€ What's changed?
Refactored ExpressionFactory to improve expression creation performance by about 50%.
β‘οΈ What's your motivation?
Fixes #185
π·οΈ What kind of change is this?
β»οΈ Anything particular you want feedback on?
The PR has been asked by mpkorstanje
π Checklist: