Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/jmh/java/pl/allegro/tech/opel/OpelEngineBanchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package pl.allegro.tech.opel; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
|
||
public class OpelEngineBanchmark { | ||
|
||
private static final OpelEngine engine = OpelEngineBuilder.create().build(); | ||
private static final String SIMPLE_EXPRESSION = "2 + 2 * 2"; | ||
private static final String COMPLEX_EXPRESSION = "val x = 'some string'; val y = x.length() / 10; if (x > 4) x.toLowerCase else 'lorem ipsum'"; | ||
private static final OpelParsingResult PARSED_SIMPLE_EXPRESSION = engine.parse(SIMPLE_EXPRESSION); | ||
private static final OpelParsingResult PARSED_COMPLEX_EXPRESSION = engine.parse(COMPLEX_EXPRESSION); | ||
|
||
@Benchmark | ||
public void validateSimpleExpression() { | ||
engine.eval(SIMPLE_EXPRESSION); | ||
} | ||
|
||
@Benchmark | ||
public void validateComplexExpression() { | ||
engine.eval(COMPLEX_EXPRESSION); | ||
} | ||
|
||
@Benchmark | ||
public void validateSimpleParsedExpression() { | ||
PARSED_SIMPLE_EXPRESSION.eval(); | ||
} | ||
|
||
@Benchmark | ||
public void validateComplexParsedExpression() { | ||
PARSED_COMPLEX_EXPRESSION.eval(); | ||
} | ||
|
||
} |