You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Cucumber tests run in about 10.2 seconds on average : that's not so bad (we have plain Java, no Spring, no Mockito). But we wanted to have an even faster feedback loop for the developer.
Thus, we made some profiling and found that ExpressionFactory.createExpression(String) was eating a lot of CPU (this method is called more than 64'000 times for our project).
✅ What did you expect to see?
We improved the code with two different variants and made some benchmark using JMH microbenchmark framework :
creationExpression0 is the original method
creationExpression1 is a small update in which we replaced some regexp conditions by startsWith/endsWith conditions
creationExpression2 is a full rewrite with regexp conditions replaced by character testing conditions
👓 What did you see?
I have a project tested with Cucumber 7.9.0:
The Cucumber tests run in about 10.2 seconds on average : that's not so bad (we have plain Java, no Spring, no Mockito). But we wanted to have an even faster feedback loop for the developer.
Thus, we made some profiling and found that
ExpressionFactory.createExpression(String)
was eating a lot of CPU (this method is called more than 64'000 times for our project).✅ What did you expect to see?
We improved the code with two different variants and made some benchmark using JMH microbenchmark framework :
The benchmark results are the following :
Benchmark Mode Cnt Score Error Units
ExpressionFactoryBenchmark.createExpression0 thrpt 25 234230,747 ± 4693,108 ops/s
ExpressionFactoryBenchmark.createExpression1 thrpt 25 347290,522 ± 4297,255 ops/s
ExpressionFactoryBenchmark.createExpression2 thrpt 25 356142,244 ± 9833,928 ops/s
When using the createExpression2 variant on our project, the cucumber tests run in 9.0 seconds on average. That's a 1.2 second improvement (12%).
Thus, we suggest to replace current
ExpressionFactory.createExpression(String)
implementation by the one from our createExpression2.You can find in annex the three different variants, unit testing to ensure that all three variants behave the same and the JMH benchmark code.
cucumberexpressions.zip
📦 Which tool/library version are you using?
I'm using Cucumber 7.9.0 with the following Maven dependencies:
🔬 How could we reproduce it?
The JMH micro benchmark is provided in
ExpressionFactoryBenchmark
.Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: