This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-performance-tests.git
commit 3c9bb66a2b9f242b9561f291e17d27efcc460ec8 Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Mon Aug 26 11:14:27 2024 +0200 Improve granularity for the Simple operator tests --- .../apache/camel/itest/jmh/SimpleOperatorTest.java | 43 +++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleOperatorTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleOperatorTest.java index e7444ae..9d232be 100644 --- a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleOperatorTest.java +++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleOperatorTest.java @@ -57,8 +57,8 @@ public class SimpleOperatorTest { // Set the following options as needed .mode(Mode.All) .timeUnit(TimeUnit.MICROSECONDS) - .warmupTime(TimeValue.seconds(1)) - .warmupIterations(2) + .warmupTime(TimeValue.seconds(3)) + .warmupIterations(5) .measurementTime(TimeValue.seconds(10)) .measurementIterations(2) .threads(2) @@ -77,9 +77,9 @@ public class SimpleOperatorTest { @State(Scope.Thread) public static class BenchmarkState { CamelContext camel; - String expression = "${header.gold} == 123"; - String expression2 = "${header.gold} > 123"; - String expression3 = "${header.gold} < 123"; + final String expressionEquals = "${header.gold} == 123"; + final String expressionGreaterThan = "${header.gold} > 123"; + final String expressionSmallerThan = "${header.gold} < 123"; Exchange exchange; Language simple; @@ -101,7 +101,7 @@ public class SimpleOperatorTest { @TearDown(Level.Trial) public void close() { try { - LOG.info("" + camel.getTypeConverterRegistry().getStatistics()); + LOG.info("{}", camel.getTypeConverterRegistry().getStatistics()); camel.stop(); } catch (Exception e) { // ignore @@ -112,22 +112,23 @@ public class SimpleOperatorTest { @Benchmark @Measurement(batchSize = 1000) - public void simplePredicate(BenchmarkState state, Blackhole bh) { - boolean out = state.simple.createPredicate(state.expression).matches(state.exchange); - if (!out) { - throw new IllegalArgumentException("Evaluation failed"); - } + public void simplePredicateEquals(BenchmarkState state, Blackhole bh) { + boolean out = state.simple.createPredicate(state.expressionEquals).matches(state.exchange); + bh.consume(out); + } + + @Benchmark + @Measurement(batchSize = 1000) + public void simplePredicateGreaterThan(BenchmarkState state, Blackhole bh) { + boolean out = state.simple.createPredicate(state.expressionGreaterThan).matches(state.exchange); + bh.consume(out); + } + + @Benchmark + @Measurement(batchSize = 1000) + public void simplePredicateSmallerThan(BenchmarkState state, Blackhole bh) { + boolean out = state.simple.createPredicate(state.expressionSmallerThan).matches(state.exchange); bh.consume(out); - boolean out2 = state.simple.createPredicate(state.expression2).matches(state.exchange); - if (out2) { - throw new IllegalArgumentException("Evaluation failed"); - } - bh.consume(out2); - boolean out3 = state.simple.createPredicate(state.expression3).matches(state.exchange); - if (out3) { - throw new IllegalArgumentException("Evaluation failed"); - } - bh.consume(out3); } }
