Skip to content

Commit

Permalink
[incubator-kie-issues#781] Fix as per PR suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
BAMOE CI committed Dec 20, 2023
1 parent 050759f commit 4ebc585
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getObjectArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELAddExecutorBenchmark {
private AddExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"String String", "Duration Duration", "OffsetDateTime Duration", "int int"})
private String argsType;
Expand All @@ -49,11 +48,11 @@ public class FEELAddExecutorBenchmark {
public void setup() {
executor = AddExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getMap(argsType);
values = getObjectArray(argsType);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELAndExecutorBenchmark {
private AndExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"true true", "true false", "false true", "false false"})
private String args;
Expand All @@ -49,11 +48,11 @@ public class FEELAndExecutorBenchmark {
public void setup() {
executor = AndExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getBooleanMap(args);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getObjectArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELDivExecutorBenchmark {
private DivExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"Duration int", "Duration Duration", "ChronoPeriod int", "ChronoPeriod ChronoPeriod"})
private String args;
Expand All @@ -49,11 +48,11 @@ public class FEELDivExecutorBenchmark {
public void setup() {
executor = DivExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getMap(args);
values = getObjectArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELEqExecutorBenchmark {
private EqExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"Duration int", "Duration Duration", "ChronoPeriod int", "ChronoPeriod ChronoPeriod"})
private String args;
Expand All @@ -49,11 +48,11 @@ public class FEELEqExecutorBenchmark {
public void setup() {
executor = EqExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getBooleanMap(args);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELGtExecutorBenchmark {
private GtExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"String String", "Duration Duration", "int int", "ChronoPeriod ChronoPeriod"})
private String args;
Expand All @@ -49,11 +48,11 @@ public class FEELGtExecutorBenchmark {
public void setup() {
executor = GtExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getBooleanMap(args);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELGteExecutorBenchmark {
private GteExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"String String", "Duration Duration", "int int", "ChronoPeriod ChronoPeriod"})
private String args;
Expand All @@ -49,11 +48,11 @@ public class FEELGteExecutorBenchmark {
public void setup() {
executor = GteExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getBooleanMap(args);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,25 @@
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.ChronoPeriod;
import java.time.temporal.ChronoUnit;
import java.util.Map;

public class FEELInfixExecutorBenchmarkUtils {


private FEELInfixExecutorBenchmarkUtils() {
}

static Map<String, Object> getMap(String types) {
static Object[] getObjectArray(String types) {
String[] parsedTypes = types.split(" ");
String leftType = parsedTypes[0];
String rightType = parsedTypes[1];
return Map.of("a", getObject(leftType, 1), "b", getObject(rightType, 2));
return new Object[]{getObject(leftType, 1), getObject(rightType, 2)};
}

static Map<String, Object> getBooleanMap(String args) {
static Object[] getBooleanArray(String args) {
String[] parsedArgs = args.split(" ");
String leftArg = parsedArgs[0];
String rightArg = parsedArgs[1];
return Map.of("a", Boolean.valueOf(leftArg), "b", Boolean.valueOf(rightArg));
return new Object[]{Boolean.valueOf(leftArg), Boolean.valueOf(rightArg)};
}

private static Object getObject(String type, int value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELLtExecutorBenchmark {
private LtExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"String String", "Duration Duration", "int int", "ChronoPeriod ChronoPeriod"})
private String args;
Expand All @@ -49,11 +48,11 @@ public class FEELLtExecutorBenchmark {
public void setup() {
executor = LtExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getBooleanMap(args);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELLteExecutorBenchmark {
private LteExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"String String", "Duration Duration", "int int", "ChronoPeriod ChronoPeriod"})
private String args;
Expand All @@ -49,11 +48,11 @@ public class FEELLteExecutorBenchmark {
public void setup() {
executor = LteExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getBooleanMap(args);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getObjectArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELMultExecutorBenchmark {
private MultExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"Duration int", "Duration Duration", "ChronoPeriod int", "ChronoPeriod ChronoPeriod"})
private String args;
Expand All @@ -49,11 +48,11 @@ public class FEELMultExecutorBenchmark {
public void setup() {
executor = MultExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getMap(args);
values = getObjectArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanMap;
import static org.drools.benchmarks.dmn.feel.infixexecutors.FEELInfixExecutorBenchmarkUtils.getBooleanArray;

@Warmup(iterations = 10)
@Measurement(iterations = 50)
Expand All @@ -39,7 +38,7 @@ public class FEELNeExecutorBenchmark {
private NeExecutor executor;
private EvaluationContext ctx;

private Map<String, Object> map;
private Object[] values;

@Param({"Duration int", "Duration Duration", "ChronoPeriod int", "ChronoPeriod ChronoPeriod"})
private String args;
Expand All @@ -49,11 +48,11 @@ public class FEELNeExecutorBenchmark {
public void setup() {
executor = NeExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
map = getBooleanMap(args);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(map.get("a"), map.get("b"), ctx);
return executor.evaluate(values[0], values[1], ctx);
}
}
Loading

0 comments on commit 4ebc585

Please sign in to comment.