diff --git a/commons-vfs2/pom.xml b/commons-vfs2/pom.xml index 3750a95fef..891d8c35a0 100644 --- a/commons-vfs2/pom.xml +++ b/commons-vfs2/pom.xml @@ -140,6 +140,12 @@ httpcore-nio test + + + org.openjdk.jmh + jmh-core + test + @@ -352,6 +358,66 @@ + + + benchmark + + + true + org.apache + + + + + org.openjdk.jmh + jmh-generator-annprocess + test + + + + + + + + maven-compiler-plugin + ${commons.compiler.version} + + + **/* + + + + + + org.codehaus.mojo + exec-maven-plugin + + + benchmark + test + + exec + + + test + java + + -classpath + + org.openjdk.jmh.Main + -rf + json + -rff + target/jmh-result.json + ${benchmark} + + + + + + + + diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/UriParserBenchmark.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/UriParserBenchmark.java new file mode 100644 index 0000000000..bb17e0057d --- /dev/null +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/UriParserBenchmark.java @@ -0,0 +1,35 @@ +/* + * 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.commons.vfs2.provider; + +import org.apache.commons.vfs2.FileSystemException; +import org.openjdk.jmh.annotations.*; + +@BenchmarkMode(Mode.Throughput) +@Warmup(iterations = 2) +@Measurement(iterations = 5) +public class UriParserBenchmark { + + private static final String PATH_TO_NORMALIZE = "file:///this/../is/a%2flong%2Fpath/./for testing/normlisePath%2fmethod.txt"; + + @Benchmark + public void normalisePath() throws FileSystemException { + StringBuilder path = new StringBuilder(PATH_TO_NORMALIZE); + UriParser.fixSeparators(path); + UriParser.normalisePath(path); + } +} diff --git a/pom.xml b/pom.xml index 59ad6961f1..5398547525 100644 --- a/pom.xml +++ b/pom.xml @@ -586,6 +586,19 @@ jsr311-api 1.1.1 + + + org.openjdk.jmh + jmh-core + 1.37 + test + + + org.openjdk.jmh + jmh-generator-annprocess + 1.37 + test +