Loading .github/workflows/ci_e2e.yml +1 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,6 @@ jobs: uses: actions/upload-artifact@v1 with: name: dslogs path: /var/lib/docker/volumes/docker-swarm_dolphinscheduler-logs/_data path: /var/lib/docker/volumes/dolphinscheduler-logs/_data .github/workflows/ci_ut.yml +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ jobs: -Dsonar.core.codeCoveragePlugin=jacoco -Dsonar.projectKey=apache-dolphinscheduler -Dsonar.login=e4058004bc6be89decf558ac819aa1ecbee57682 -Dsonar.exclusions=dolphinscheduler-ui/src/**/i18n/locale/*.js -Dsonar.exclusions=dolphinscheduler-ui/src/**/i18n/locale/*.js,dolphinscheduler-microbench/src/**/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} Loading dolphinscheduler-microbench/pom.xml 0 → 100644 +101 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ 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 ~ ~ 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. --> <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>dolphinscheduler</artifactId> <groupId>org.apache.dolphinscheduler</groupId> <version>1.2.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>dolphinscheduler-microbench</artifactId> <packaging>jar</packaging> <name>${project.artifactId}</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <jmh.version>1.21</jmh.version> <javac.target>1.8</javac.target> <uberjar.name>benchmarks</uberjar.name> </properties> <dependencies> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-core</artifactId> <version>${jmh.version}</version> </dependency> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-generator-annprocess</artifactId> <version>${jmh.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven-compiler-plugin.version}</version> <configuration> <compilerVersion>${javac.target}</compilerVersion> <source>${javac.target}</source> <target>${javac.target}</target> <useIncrementalCompilation>false</useIncrementalCompilation> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>${maven-assembly-plugin.version}</version> <configuration> <archive> <manifest> <mainClass>org.openjdk.jmh.Main</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build> </project> No newline at end of file dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java 0 → 100644 +123 −0 Original line number Diff line number Diff line /* * 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 * * 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.apache.dolphinscheduler.microbench.base; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.ChainedOptionsBuilder; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; /** * BaseBenchMark * If you need to test jmh, please extend him first */ @Warmup(iterations = AbstractBaseBenchmark.DEFAULT_WARMUP_ITERATIONS) @Measurement(iterations = AbstractBaseBenchmark.DEFAULT_MEASURE_ITERATIONS) @State(Scope.Thread) @Fork(AbstractBaseBenchmark.DEFAULT_FORKS) public abstract class AbstractBaseBenchmark { static final int DEFAULT_WARMUP_ITERATIONS = 10; static final int DEFAULT_MEASURE_ITERATIONS = 10; static final int DEFAULT_FORKS = 2; private static Logger logger = LoggerFactory.getLogger(AbstractBaseBenchmark.class); private ChainedOptionsBuilder newOptionsBuilder() { String className = getClass().getSimpleName(); ChainedOptionsBuilder optBuilder = new OptionsBuilder() // set benchmark ClassName .include(className); if (getMeasureIterations() > 0) { optBuilder.warmupIterations(getMeasureIterations()); } if (getMeasureIterations() > 0) { optBuilder.measurementIterations(getMeasureIterations()); } if (getForks() > 0) { optBuilder.forks(getForks()); } String output = getReportDir(); if (output != null) { boolean writeFileStatus; String filePath = getReportDir() + className + ".json"; File file = new File(filePath); if (file.exists()) { writeFileStatus = file.delete(); } else { writeFileStatus = file.getParentFile().mkdirs(); try { writeFileStatus = file.createNewFile(); } catch (IOException e) { logger.warn("jmh test create file error" + e); } } if (writeFileStatus) { optBuilder.resultFormat(ResultFormatType.JSON) .result(filePath); } } return optBuilder; } @Test public void run() throws Exception { new Runner(newOptionsBuilder().build()).run(); } private int getWarmupIterations() { String value = System.getProperty("warmupIterations"); return null != value ? Integer.parseInt(value) : -1; } private int getMeasureIterations() { String value = System.getProperty("measureIterations"); return null != value ? Integer.parseInt(value) : -1; } private static String getReportDir() { return System.getProperty("perfReportDir"); } private static int getForks() { String value = System.getProperty("forkCount"); return null != value ? Integer.parseInt(value) : -1; } } dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/EnumBenchMark.java 0 → 100644 +112 −0 Original line number Diff line number Diff line /* * 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 * * 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.apache.dolphinscheduler.microbench.common; import org.apache.dolphinscheduler.microbench.base.AbstractBaseBenchmark; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; /** *Enum values JMH test */ @Warmup(iterations = 2, time = 1) @Measurement(iterations = 4, time = 1) @State(Scope.Benchmark) public class EnumBenchMark extends AbstractBaseBenchmark { @Benchmark public boolean simpleTest(){ return Boolean.TRUE; } @Param({"101", "108", "103", "104", "105", "103"}) private int testNum; @Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void enumValuesTest() { TestTypeEnum.oldGetNameByType(testNum); } @Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void enumStaticMapTest() { TestTypeEnum.newGetNameByType(testNum); } public enum TestTypeEnum { TYPE_101(101, "TYPE101"), TYPE_102(102, "TYPE102"), TYPE_103(103, "TYPE103"), TYPE_104(104, "TYPE104"), TYPE_105(105, "TYPE105"), TYPE_106(106, "TYPE106"), TYPE_107(107, "TYPE107"), TYPE_108(108, "TYPE108"); private int code; private String name; public int getCode() { return code; } public String getName() { return name; } TestTypeEnum(int code, String name) { this.code = code; this.name = name; } private static final Map<Integer, TestTypeEnum> TEST_TYPE_MAP = new HashMap<>(); static { for (TestTypeEnum testTypeEnum : TestTypeEnum.values()) { TEST_TYPE_MAP.put(testTypeEnum.code,testTypeEnum); } } public static void newGetNameByType(int code) { if (TEST_TYPE_MAP.containsKey(code)) { TEST_TYPE_MAP.get(code); return; } throw new IllegalArgumentException("invalid code : " + code); } public static void oldGetNameByType(int code) { for (TestTypeEnum testTypeEnum : TestTypeEnum.values()) { if (testTypeEnum.getCode() == code) { return; } } throw new IllegalArgumentException("invalid code : " + code); } } } Loading
.github/workflows/ci_e2e.yml +1 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,6 @@ jobs: uses: actions/upload-artifact@v1 with: name: dslogs path: /var/lib/docker/volumes/docker-swarm_dolphinscheduler-logs/_data path: /var/lib/docker/volumes/dolphinscheduler-logs/_data
.github/workflows/ci_ut.yml +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ jobs: -Dsonar.core.codeCoveragePlugin=jacoco -Dsonar.projectKey=apache-dolphinscheduler -Dsonar.login=e4058004bc6be89decf558ac819aa1ecbee57682 -Dsonar.exclusions=dolphinscheduler-ui/src/**/i18n/locale/*.js -Dsonar.exclusions=dolphinscheduler-ui/src/**/i18n/locale/*.js,dolphinscheduler-microbench/src/**/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} Loading
dolphinscheduler-microbench/pom.xml 0 → 100644 +101 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!-- ~ 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 ~ ~ 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. --> <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>dolphinscheduler</artifactId> <groupId>org.apache.dolphinscheduler</groupId> <version>1.2.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>dolphinscheduler-microbench</artifactId> <packaging>jar</packaging> <name>${project.artifactId}</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <jmh.version>1.21</jmh.version> <javac.target>1.8</javac.target> <uberjar.name>benchmarks</uberjar.name> </properties> <dependencies> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-core</artifactId> <version>${jmh.version}</version> </dependency> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-generator-annprocess</artifactId> <version>${jmh.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven-compiler-plugin.version}</version> <configuration> <compilerVersion>${javac.target}</compilerVersion> <source>${javac.target}</source> <target>${javac.target}</target> <useIncrementalCompilation>false</useIncrementalCompilation> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>${maven-assembly-plugin.version}</version> <configuration> <archive> <manifest> <mainClass>org.openjdk.jmh.Main</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build> </project> No newline at end of file
dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java 0 → 100644 +123 −0 Original line number Diff line number Diff line /* * 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 * * 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.apache.dolphinscheduler.microbench.base; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.ChainedOptionsBuilder; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; /** * BaseBenchMark * If you need to test jmh, please extend him first */ @Warmup(iterations = AbstractBaseBenchmark.DEFAULT_WARMUP_ITERATIONS) @Measurement(iterations = AbstractBaseBenchmark.DEFAULT_MEASURE_ITERATIONS) @State(Scope.Thread) @Fork(AbstractBaseBenchmark.DEFAULT_FORKS) public abstract class AbstractBaseBenchmark { static final int DEFAULT_WARMUP_ITERATIONS = 10; static final int DEFAULT_MEASURE_ITERATIONS = 10; static final int DEFAULT_FORKS = 2; private static Logger logger = LoggerFactory.getLogger(AbstractBaseBenchmark.class); private ChainedOptionsBuilder newOptionsBuilder() { String className = getClass().getSimpleName(); ChainedOptionsBuilder optBuilder = new OptionsBuilder() // set benchmark ClassName .include(className); if (getMeasureIterations() > 0) { optBuilder.warmupIterations(getMeasureIterations()); } if (getMeasureIterations() > 0) { optBuilder.measurementIterations(getMeasureIterations()); } if (getForks() > 0) { optBuilder.forks(getForks()); } String output = getReportDir(); if (output != null) { boolean writeFileStatus; String filePath = getReportDir() + className + ".json"; File file = new File(filePath); if (file.exists()) { writeFileStatus = file.delete(); } else { writeFileStatus = file.getParentFile().mkdirs(); try { writeFileStatus = file.createNewFile(); } catch (IOException e) { logger.warn("jmh test create file error" + e); } } if (writeFileStatus) { optBuilder.resultFormat(ResultFormatType.JSON) .result(filePath); } } return optBuilder; } @Test public void run() throws Exception { new Runner(newOptionsBuilder().build()).run(); } private int getWarmupIterations() { String value = System.getProperty("warmupIterations"); return null != value ? Integer.parseInt(value) : -1; } private int getMeasureIterations() { String value = System.getProperty("measureIterations"); return null != value ? Integer.parseInt(value) : -1; } private static String getReportDir() { return System.getProperty("perfReportDir"); } private static int getForks() { String value = System.getProperty("forkCount"); return null != value ? Integer.parseInt(value) : -1; } }
dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/EnumBenchMark.java 0 → 100644 +112 −0 Original line number Diff line number Diff line /* * 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 * * 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.apache.dolphinscheduler.microbench.common; import org.apache.dolphinscheduler.microbench.base.AbstractBaseBenchmark; import org.openjdk.jmh.annotations.*; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; /** *Enum values JMH test */ @Warmup(iterations = 2, time = 1) @Measurement(iterations = 4, time = 1) @State(Scope.Benchmark) public class EnumBenchMark extends AbstractBaseBenchmark { @Benchmark public boolean simpleTest(){ return Boolean.TRUE; } @Param({"101", "108", "103", "104", "105", "103"}) private int testNum; @Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void enumValuesTest() { TestTypeEnum.oldGetNameByType(testNum); } @Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) public void enumStaticMapTest() { TestTypeEnum.newGetNameByType(testNum); } public enum TestTypeEnum { TYPE_101(101, "TYPE101"), TYPE_102(102, "TYPE102"), TYPE_103(103, "TYPE103"), TYPE_104(104, "TYPE104"), TYPE_105(105, "TYPE105"), TYPE_106(106, "TYPE106"), TYPE_107(107, "TYPE107"), TYPE_108(108, "TYPE108"); private int code; private String name; public int getCode() { return code; } public String getName() { return name; } TestTypeEnum(int code, String name) { this.code = code; this.name = name; } private static final Map<Integer, TestTypeEnum> TEST_TYPE_MAP = new HashMap<>(); static { for (TestTypeEnum testTypeEnum : TestTypeEnum.values()) { TEST_TYPE_MAP.put(testTypeEnum.code,testTypeEnum); } } public static void newGetNameByType(int code) { if (TEST_TYPE_MAP.containsKey(code)) { TEST_TYPE_MAP.get(code); return; } throw new IllegalArgumentException("invalid code : " + code); } public static void oldGetNameByType(int code) { for (TestTypeEnum testTypeEnum : TestTypeEnum.values()) { if (testTypeEnum.getCode() == code) { return; } } throw new IllegalArgumentException("invalid code : " + code); } } }