فهرست منبع

增加benchmark的工程测试

everywhere.z 7 ماه پیش
والد
کامیت
7c9bf1ebea
22فایلهای تغییر یافته به همراه584 افزوده شده و 1 حذف شده
  1. 24 0
      liteflow-benchmark/liteflow-benchmark-script-groovy/pom.xml
  2. 76 0
      liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/ScriptGroovyBenchmark.java
  3. 20 0
      liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/cmp/ACmp.java
  4. 20 0
      liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/cmp/BCmp.java
  5. 20 0
      liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/cmp/CCmp.java
  6. 13 0
      liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/cmp/TestDomain.java
  7. 3 0
      liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/resources/application.properties
  8. 55 0
      liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/resources/flow.xml
  9. 29 0
      liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/resources/script.groovy
  10. 24 0
      liteflow-benchmark/liteflow-benchmark-script-java/pom.xml
  11. 76 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/ScriptJavaBenchmark.java
  12. 20 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/ACmp.java
  13. 20 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/BCmp.java
  14. 20 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/CCmp.java
  15. 23 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/DCmp.java
  16. 28 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/Person.java
  17. 25 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/TestDomain.java
  18. 3 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/resources/application.properties
  19. 60 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/resources/flow.xml
  20. 20 0
      liteflow-benchmark/liteflow-benchmark-script-java/src/test/resources/javaScript.java
  21. 2 1
      liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/ScriptJavaxBenchmark.java
  22. 3 0
      liteflow-benchmark/pom.xml

+ 24 - 0
liteflow-benchmark/liteflow-benchmark-script-groovy/pom.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>liteflow-benchmark</artifactId>
+        <groupId>com.yomahub</groupId>
+        <version>${revision}</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>liteflow-benchmark-script-groovy</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.yomahub</groupId>
+            <artifactId>liteflow-script-groovy</artifactId>
+            <version>${revision}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

+ 76 - 0
liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/ScriptGroovyBenchmark.java

@@ -0,0 +1,76 @@
+package com.yomahub.liteflow.benchmark;
+
+import cn.hutool.core.io.resource.ResourceUtil;
+import cn.hutool.core.util.StrUtil;
+import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
+import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.FlowBus;
+import org.openjdk.jmh.annotations.*;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+import org.openjdk.jmh.runner.options.TimeValue;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.PropertySource;
+
+import java.util.concurrent.TimeUnit;
+
+@State(Scope.Benchmark)
+@EnableAutoConfiguration
+@PropertySource(value = "classpath:application.properties")
+@ComponentScan("com.yomahub.liteflow.benchmark.cmp")
+public class ScriptGroovyBenchmark {
+
+    private ConfigurableApplicationContext applicationContext;
+
+    private FlowExecutor flowExecutor;
+
+    @Setup
+    public void setup() {
+        applicationContext = SpringApplication.run(ScriptGroovyBenchmark.class);
+        flowExecutor = applicationContext.getBean(FlowExecutor.class);
+    }
+
+    @TearDown
+    public void tearDown() {
+        applicationContext.close();
+    }
+
+    //普通执行
+    @Benchmark
+    public  void test1(){
+        flowExecutor.execute2Resp("chain1");
+    }
+
+    //LF动态创建组件和规则,并执行
+    @Benchmark
+    public  void test2(){
+        String scriptContent = ResourceUtil.readUtf8Str("classpath:script.groovy");
+        LiteFlowNodeBuilder.createScriptNode().setId("ds").setScript(scriptContent).build();
+
+        if(!FlowBus.containChain("chain2")){
+            LiteFlowChainELBuilder.createChain().setChainId("chain2").setEL("THEN(ds)").build();
+        }
+        flowExecutor.execute2Resp("chain2");
+    }
+
+
+    public static void main(String[] args) throws RunnerException {
+        Options opt = new OptionsBuilder()
+                .include(ScriptGroovyBenchmark.class.getSimpleName())
+                .mode(Mode.Throughput)
+                .warmupIterations(1)//预热次数
+                .measurementIterations(3)//执行次数
+                .measurementTime(new TimeValue(10, TimeUnit.SECONDS))//每次执行多少时间
+                .threads(100)//多少个线程
+                .forks(1)//多少个进程
+                .timeUnit(TimeUnit.SECONDS)
+                .build();
+        new Runner(opt).run();
+    }
+}

+ 20 - 0
liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/cmp/ACmp.java

@@ -0,0 +1,20 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.benchmark.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeComponent;
+
+@LiteflowComponent("a")
+public class ACmp extends NodeComponent {
+
+	@Override
+	public void process() {
+	}
+
+}

+ 20 - 0
liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/cmp/BCmp.java

@@ -0,0 +1,20 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.benchmark.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeComponent;
+
+@LiteflowComponent("b")
+public class BCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+	}
+
+}

+ 20 - 0
liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/cmp/CCmp.java

@@ -0,0 +1,20 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.benchmark.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeComponent;
+
+@LiteflowComponent("c")
+public class CCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+	}
+
+}

+ 13 - 0
liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/java/com/yomahub/liteflow/benchmark/cmp/TestDomain.java

@@ -0,0 +1,13 @@
+package com.yomahub.liteflow.benchmark.cmp;
+
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class TestDomain {
+
+    public String sayHello(String name){
+        return "hello," + name;
+    }
+
+}

+ 3 - 0
liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/resources/application.properties

@@ -0,0 +1,3 @@
+liteflow.rule-source=flow.xml
+liteflow.print-execution-log=false
+liteflow.script-setting.javax-is-cache=false

+ 55 - 0
liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/resources/flow.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE flow PUBLIC  "liteflow" "liteflow.dtd">
+<flow>
+    <nodes>
+        <node id="s1" name="普通脚本1" type="script" language="groovy">
+            <![CDATA[
+            import cn.hutool.core.collection.ListUtil
+            import cn.hutool.core.date.DateUtil
+
+            import java.util.function.Consumer
+            import java.util.function.Function
+            import java.util.stream.Collectors
+
+            def date = DateUtil.parse("2022-10-17 13:31:43")
+            defaultContext.setData("demoDate", date)
+
+            List<String> list = ListUtil.toList("a", "b", "c")
+
+            List<String> resultList = list.stream().map(s -> "hello," + s).collect(Collectors.toList())
+
+            defaultContext.setData("resultList", resultList)
+
+            class Student {
+                int studentID
+                String studentName
+            }
+
+            Student student = new Student()
+            student.studentID = 100301
+            student.studentName = "张三"
+                    defaultContext.setData("student", student)
+
+            def a = 3
+            def b = 2
+            defaultContext.setData("s1", a * b)
+            ]]>
+        </node>
+
+        <node id="s2" name="循环脚本1" type="for_script" language="groovy">
+            <![CDATA[
+            return 2
+            ]]>
+        </node>
+
+        <node id="s3" name="选择脚本" type="switch_script" language="groovy">
+            <![CDATA[
+            return "b"
+            ]]>
+        </node>
+    </nodes>
+
+    <chain name="chain1">
+        THEN(FOR(s2).DO(THEN(a, b, c, s1)), SWITCH(s3).TO(a,b));
+    </chain>
+</flow>

+ 29 - 0
liteflow-benchmark/liteflow-benchmark-script-groovy/src/test/resources/script.groovy

@@ -0,0 +1,29 @@
+import cn.hutool.core.collection.ListUtil
+import cn.hutool.core.date.DateUtil
+
+import java.util.function.Consumer
+import java.util.function.Function
+import java.util.stream.Collectors
+
+def date = DateUtil.parse("2022-10-17 13:31:43")
+defaultContext.setData("demoDate", date)
+
+List<String> list = ListUtil.toList("a", "b", "c")
+
+List<String> resultList = list.stream().map(s -> "hello," + s).collect(Collectors.toList())
+
+defaultContext.setData("resultList", resultList)
+
+class Student {
+    int studentID
+    String studentName
+}
+
+Student student = new Student()
+student.studentID = 100301
+student.studentName = "张三"
+defaultContext.setData("student", student)
+
+def a = 3
+def b = 2
+defaultContext.setData("s1", a * b)

+ 24 - 0
liteflow-benchmark/liteflow-benchmark-script-java/pom.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>liteflow-benchmark</artifactId>
+        <groupId>com.yomahub</groupId>
+        <version>${revision}</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>liteflow-benchmark-script-java</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.yomahub</groupId>
+            <artifactId>liteflow-script-java</artifactId>
+            <version>${revision}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

+ 76 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/ScriptJavaBenchmark.java

@@ -0,0 +1,76 @@
+package com.yomahub.liteflow.benchmark;
+
+import cn.hutool.core.io.resource.ResourceUtil;
+import cn.hutool.core.util.StrUtil;
+import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
+import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.FlowBus;
+import org.openjdk.jmh.annotations.*;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+import org.openjdk.jmh.runner.options.TimeValue;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.PropertySource;
+
+import java.util.concurrent.TimeUnit;
+
+@State(Scope.Benchmark)
+@EnableAutoConfiguration
+@PropertySource(value = "classpath:application.properties")
+@ComponentScan("com.yomahub.liteflow.benchmark.cmp")
+public class ScriptJavaBenchmark {
+
+    private ConfigurableApplicationContext applicationContext;
+
+    private FlowExecutor flowExecutor;
+
+    @Setup
+    public void setup() {
+        applicationContext = SpringApplication.run(ScriptJavaBenchmark.class);
+        flowExecutor = applicationContext.getBean(FlowExecutor.class);
+    }
+
+    @TearDown
+    public void tearDown() {
+        applicationContext.close();
+    }
+
+    //普通执行
+    @Benchmark
+    public  void test1(){
+        flowExecutor.execute2Resp("chain1");
+    }
+
+    //LF动态创建组件和规则,并执行
+    @Benchmark
+    public  void test2(){
+        String scriptContent = ResourceUtil.readUtf8Str("classpath:javaScript.java");
+        LiteFlowNodeBuilder.createScriptNode().setId("ds").setScript(scriptContent).build();
+
+        if(!FlowBus.containChain("chain2")){
+            LiteFlowChainELBuilder.createChain().setChainId("chain2").setEL("THEN(ds)").build();
+        }
+        flowExecutor.execute2Resp("chain2");
+    }
+
+
+    public static void main(String[] args) throws RunnerException {
+        Options opt = new OptionsBuilder()
+                .include(ScriptJavaBenchmark.class.getSimpleName())
+                .mode(Mode.Throughput)
+                .warmupIterations(1)//预热次数
+                .measurementIterations(3)//执行次数
+                .measurementTime(new TimeValue(10, TimeUnit.SECONDS))//每次执行多少时间
+                .threads(300)//多少个线程
+                .forks(1)//多少个进程
+                .timeUnit(TimeUnit.SECONDS)
+                .build();
+        new Runner(opt).run();
+    }
+}

+ 20 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/ACmp.java

@@ -0,0 +1,20 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.benchmark.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeComponent;
+
+@LiteflowComponent("a")
+public class ACmp extends NodeComponent {
+
+	@Override
+	public void process() {
+	}
+
+}

+ 20 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/BCmp.java

@@ -0,0 +1,20 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.benchmark.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeComponent;
+
+@LiteflowComponent("b")
+public class BCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+	}
+
+}

+ 20 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/CCmp.java

@@ -0,0 +1,20 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.benchmark.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeComponent;
+
+@LiteflowComponent("c")
+public class CCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+	}
+
+}

+ 23 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/DCmp.java

@@ -0,0 +1,23 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.benchmark.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+@LiteflowComponent("d")
+public class DCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		DefaultContext context = this.getFirstContextBean();
+		context.setData("count", 198);
+	}
+
+}

+ 28 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/Person.java

@@ -0,0 +1,28 @@
+package com.yomahub.liteflow.benchmark.cmp;
+
+public class Person {
+    private String name;
+
+    private Integer salary;
+
+    public Person(String name, Integer salary) {
+        this.name = name;
+        this.salary = salary;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getSalary() {
+        return salary;
+    }
+
+    public void setSalary(Integer salary) {
+        this.salary = salary;
+    }
+}

+ 25 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/java/com/yomahub/liteflow/benchmark/cmp/TestDomain.java

@@ -0,0 +1,25 @@
+package com.yomahub.liteflow.benchmark.cmp;
+
+import cn.hutool.core.collection.ListUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public class TestDomain {
+
+    public String sayHello(String name){
+        return "hello," + name;
+    }
+
+    public static void main(String[] args) {
+        List<Person> personList = ListUtil.toList(
+                new Person("jack", 15000),
+                new Person("tom", 13500),
+                new Person("peter", 18600)
+                );
+
+        int totalSalary = personList.stream().mapToInt(Person::getSalary).sum();
+        System.out.println(totalSalary);
+    }
+}

+ 3 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/resources/application.properties

@@ -0,0 +1,3 @@
+liteflow.rule-source=flow.xml
+liteflow.print-execution-log=false
+liteflow.script-setting.javax-is-cache=false

+ 60 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/resources/flow.xml

@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE flow PUBLIC  "liteflow" "liteflow.dtd">
+<flow>
+    <nodes>
+        <node id="s1" name="普通脚本1" type="script" language="java">
+            <![CDATA[
+            import com.yomahub.liteflow.benchmark.cmp.TestDomain;
+            import com.yomahub.liteflow.slot.DefaultContext;
+            import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
+            import com.yomahub.liteflow.script.body.JaninoCommonScriptBody;
+            import com.yomahub.liteflow.script.ScriptExecuteWrap;
+
+            public class Demo implements JaninoCommonScriptBody {
+                public Void body(ScriptExecuteWrap wrap) {
+                    int v1 = 2;
+                    int v2 = 3;
+                    DefaultContext ctx = (DefaultContext) wrap.getCmp().getFirstContextBean();
+                    ctx.setData("s1", v1 * v2);
+
+                    TestDomain domain = (TestDomain) ContextAwareHolder.loadContextAware().getBean(TestDomain.class);
+                    String str = domain.sayHello("jack");
+                    ctx.setData("hi", str);
+
+                    return null;
+                }
+            }
+            ]]>
+        </node>
+
+        <node id="s2" name="循环脚本1" type="for_script" language="java">
+            <![CDATA[
+            import com.yomahub.liteflow.script.body.JaninoForScriptBody;
+            import com.yomahub.liteflow.script.ScriptExecuteWrap;
+
+            public class Demo implements JaninoForScriptBody{
+                public Integer body(ScriptExecuteWrap wrap){
+                    return 2;
+                }
+            }
+            ]]>
+        </node>
+
+        <node id="s3" name="选择脚本" type="switch_script" language="java">
+            <![CDATA[
+            import com.yomahub.liteflow.script.ScriptExecuteWrap;
+            import com.yomahub.liteflow.script.body.JaninoSwitchScriptBody;
+
+            public class Demo implements JaninoSwitchScriptBody {
+                public String body(ScriptExecuteWrap wrap) {
+                    return "b";
+                }
+            }
+            ]]>
+        </node>
+    </nodes>
+
+    <chain name="chain1">
+        THEN(FOR(s2).DO(THEN(a, b, c, s1)), SWITCH(s3).TO(a,b));
+    </chain>
+</flow>

+ 20 - 0
liteflow-benchmark/liteflow-benchmark-script-java/src/test/resources/javaScript.java

@@ -0,0 +1,20 @@
+import com.yomahub.liteflow.benchmark.cmp.TestDomain;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
+import com.yomahub.liteflow.script.body.JaninoCommonScriptBody;
+import com.yomahub.liteflow.script.ScriptExecuteWrap;
+
+public class Demo implements JaninoCommonScriptBody {
+    public Void body(ScriptExecuteWrap wrap) {
+        int v1 = 2;
+        int v2 = 3;
+        DefaultContext ctx = (DefaultContext) wrap.getCmp().getFirstContextBean();
+        ctx.setData("s1", v1 * v2);
+
+        TestDomain domain = (TestDomain) ContextAwareHolder.loadContextAware().getBean(TestDomain.class);
+        String str = domain.sayHello("jack");
+        ctx.setData("hi", str);
+
+        return null;
+    }
+}

+ 2 - 1
liteflow-benchmark/liteflow-benchmark-script-javax/src/test/java/com/yomahub/liteflow/benchmark/ScriptJavaxBenchmark.java

@@ -1,6 +1,7 @@
 package com.yomahub.liteflow.benchmark;
 
 import cn.hutool.core.io.resource.ResourceUtil;
+import cn.hutool.core.util.StrUtil;
 import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
 import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
 import com.yomahub.liteflow.core.FlowExecutor;
@@ -68,7 +69,7 @@ public class ScriptJavaxBenchmark {
                 .warmupIterations(1)//预热次数
                 .measurementIterations(3)//执行次数
                 .measurementTime(new TimeValue(10, TimeUnit.SECONDS))//每次执行多少时间
-                .threads(300)//多少个线程
+                .threads(100)//多少个线程
                 .forks(1)//多少个进程
                 .timeUnit(TimeUnit.SECONDS)
                 .build();

+ 3 - 0
liteflow-benchmark/pom.xml

@@ -44,6 +44,9 @@
 
     <modules>
         <module>liteflow-benchmark-script-javax</module>
+        <module>liteflow-benchmark-script-java</module>
+        <module>liteflow-benchmark-script-groovy</module>
+        <module>liteflow-benchmark-script-kotlin</module>
     </modules>
 
     <build>