Skip to content

Commit

Permalink
[incubator-kie-issues#780] DMN - Benchmarking InfixOpNode and InfixOp…
Browse files Browse the repository at this point in the history
…erators (#281)

* [dmn-infixopnode-benchmark] Benchmarking infixopnode

* [incubator-kie-issues#781] Benchmarking infixopnode

* [incubator-kie-issues#781] Benchmarking infixexecutors

* [incubator-kie-issues#781] Fix as per PR suggestion

* [incubator-kie-issues#780] Benchmarking infixopnode

* [incubator-kie-issues#780] Benchmarking infixexecutors

* [incubator-kie-issues#780] Fix as per PR suggestion

---------

Co-authored-by: BAMOE CI <[email protected]>
  • Loading branch information
gitgabrio and BAMOE CI authored Dec 20, 2023
1 parent 3aaba1c commit acaae15
Show file tree
Hide file tree
Showing 15 changed files with 854 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.drools.benchmarks.dmn.feel;

import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Warmup;

import java.util.concurrent.TimeUnit;

@Warmup(iterations = 30, time = 200, timeUnit = TimeUnit.MILLISECONDS)
public class FEELInfixOpBenchmark extends AbstractFEELBenchmark {

@Param({"30 >= 20 * 10", "16 / 5 * ( 7 )", "9 + 5 ** 3", "10 * 32", "34 < 10 and 43 = \"32\" or 23"})
private String expression;

@Override
public String getExpression() {
return expression;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.drools.benchmarks.dmn.feel.infixexecutors;

import org.kie.dmn.feel.lang.EvaluationContext;
import org.kie.dmn.feel.lang.ast.infixexecutors.AddExecutor;
import org.kie.dmn.feel.lang.impl.EvaluationContextImpl;
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

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

@Warmup(iterations = 10)
@Measurement(iterations = 50)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
@State(org.openjdk.jmh.annotations.Scope.Thread)
public class FEELAddExecutorBenchmark {

private AddExecutor executor;
private EvaluationContext ctx;

private Object[] values;

@Param({"String String", "Duration Duration", "OffsetDateTime Duration", "int int"})
private String argsType;


@Setup
public void setup() {
executor = AddExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
values = getObjectArray(argsType);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.drools.benchmarks.dmn.feel.infixexecutors;

import org.kie.dmn.feel.lang.EvaluationContext;
import org.kie.dmn.feel.lang.ast.infixexecutors.AndExecutor;
import org.kie.dmn.feel.lang.impl.EvaluationContextImpl;
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

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

@Warmup(iterations = 10)
@Measurement(iterations = 50)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class FEELAndExecutorBenchmark {

private AndExecutor executor;
private EvaluationContext ctx;

private Object[] values;

@Param({"true true", "true false", "false true", "false false"})
private String args;


@Setup
public void setup() {
executor = AndExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.drools.benchmarks.dmn.feel.infixexecutors;

import org.kie.dmn.feel.lang.EvaluationContext;
import org.kie.dmn.feel.lang.ast.infixexecutors.DivExecutor;
import org.kie.dmn.feel.lang.impl.EvaluationContextImpl;
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

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

@Warmup(iterations = 10)
@Measurement(iterations = 50)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class FEELDivExecutorBenchmark {

private DivExecutor executor;
private EvaluationContext ctx;

private Object[] values;

@Param({"Duration int", "Duration Duration", "ChronoPeriod int", "ChronoPeriod ChronoPeriod"})
private String args;


@Setup
public void setup() {
executor = DivExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
values = getObjectArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.drools.benchmarks.dmn.feel.infixexecutors;

import org.kie.dmn.feel.lang.EvaluationContext;
import org.kie.dmn.feel.lang.ast.infixexecutors.EqExecutor;
import org.kie.dmn.feel.lang.impl.EvaluationContextImpl;
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

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

@Warmup(iterations = 10)
@Measurement(iterations = 50)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class FEELEqExecutorBenchmark {

private EqExecutor executor;
private EvaluationContext ctx;

private Object[] values;

@Param({"Duration int", "Duration Duration", "ChronoPeriod int", "ChronoPeriod ChronoPeriod"})
private String args;


@Setup
public void setup() {
executor = EqExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.drools.benchmarks.dmn.feel.infixexecutors;

import org.kie.dmn.feel.lang.EvaluationContext;
import org.kie.dmn.feel.lang.ast.infixexecutors.GtExecutor;
import org.kie.dmn.feel.lang.impl.EvaluationContextImpl;
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

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

@Warmup(iterations = 10)
@Measurement(iterations = 50)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class FEELGtExecutorBenchmark {

private GtExecutor executor;
private EvaluationContext ctx;

private Object[] values;

@Param({"String String", "Duration Duration", "int int", "ChronoPeriod ChronoPeriod"})
private String args;


@Setup
public void setup() {
executor = GtExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
values = getBooleanArray(args);
}

@Benchmark
public Object evaluate() {
return executor.evaluate(values[0], values[1], ctx);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.drools.benchmarks.dmn.feel.infixexecutors;

import org.kie.dmn.feel.lang.EvaluationContext;
import org.kie.dmn.feel.lang.ast.infixexecutors.GteExecutor;
import org.kie.dmn.feel.lang.impl.EvaluationContextImpl;
import org.kie.dmn.feel.util.ClassLoaderUtil;
import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

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

@Warmup(iterations = 10)
@Measurement(iterations = 50)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class FEELGteExecutorBenchmark {

private GteExecutor executor;
private EvaluationContext ctx;

private Object[] values;

@Param({"String String", "Duration Duration", "int int", "ChronoPeriod ChronoPeriod"})
private String args;


@Setup
public void setup() {
executor = GteExecutor.instance();
ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
values = getBooleanArray(args);
}

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

0 comments on commit acaae15

Please sign in to comment.