From c32f443e7bb1de49418e8351510c7fb0262a85af Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 1 Apr 2016 10:01:16 +0300 Subject: [PATCH 001/342] Added tag 1.12 for changeset eb41bdab96cf --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 200cd1427..09182b2a3 100644 --- a/.hgtags +++ b/.hgtags @@ -74,3 +74,4 @@ c5a34103cbb32c8aee3d6b3a151f15819a4ea664 1.11 48dbd05547e85e52017d1cbefe895ad744dbdefc 1.11.1 4778686520db8eae8a26f78f4df48fcf2710515b 1.11.2 534d83d9137f2231b889188f6bff02e541d1e7bd 1.11.3 +eb41bdab96cf7579db48fc39a9fa423b54bf4786 1.12 From 5131eac92ecef7975e3c2f61c978147d41534205 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 1 Apr 2016 10:01:30 +0300 Subject: [PATCH 002/342] Continue in 1.13-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 27326329d..390aa7cd1 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.12 + 1.13-SNAPSHOT org.openjdk.jmh diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index ff118abeb..d291a5acc 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.12 + 1.13-SNAPSHOT org.openjdk.jmh diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index a22846004..01014942f 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.12 + 1.13-SNAPSHOT org.openjdk.jmh diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 031d60031..ea49d3158 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.12 + 1.13-SNAPSHOT org.openjdk.jmh diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 24c77c0bf..e3fdd7ec6 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 4b058d67a..e96e9d083 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index d3dabe090..119e422de 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index e55d9fcaf..db56852e0 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 033368450..ede197b46 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 846d76578..db06f162c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index a3660e24d..9e7aee1c2 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 960519f18..270d9b0fd 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 9a95edc1a..021cc9726 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 008d53932..335c3b6fc 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.12 + 1.13-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 0f50948f7..1eb5ed95e 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.12 + 1.13-SNAPSHOT Java Microbenchmark Harness Parent From 26f266d40061edf6d4423be9bc50b26866433a7a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 3 May 2016 19:19:20 +0300 Subject: [PATCH 003/342] 7901666: Reader/Writer leak in BenchmarkGenerator --- .../generators/core/BenchmarkGenerator.java | 140 ++++++++++-------- .../java/org/openjdk/jmh/util/FileUtils.java | 35 +---- 2 files changed, 84 insertions(+), 91 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 77e2fe1d8..d9b9ab60f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -128,82 +128,96 @@ public void complete(GeneratorSource source, GeneratorDestination destination) { compilerControl.finish(source, destination); // Processing completed, final round. + // Collect all benchmark entries here + Set entries = new HashSet(); + + // Try to read the benchmark entries from the previous generator sessions. + // Incremental compilation may add or remove @Benchmark entries. New entries + // are discovered and added from the current compilation session. It is harder + // to detect removed @Benchmark entries. To do so, we are overwriting all benchmark + // records that belong to a current compilation unit. + Multimap entriesByQName = new HashMultimap(); try { - // Collect all benchmark entries here - Set entries = new HashSet(); - - // Try to read the benchmark entries from the previous generator sessions. - // Incremental compilation may add or remove @Benchmark entries. New entries - // are discovered and added from the current compilation session. It is harder - // to detect removed @Benchmark entries. To do so, we are overwriting all benchmark - // records that belong to a current compilation unit. - Multimap entriesByQName = new HashMultimap(); - try { - Reader reader = destination.getResource(BenchmarkList.BENCHMARK_LIST.substring(1)); - Collection existingLines = FileUtils.readAllLines(reader); - for (String line : existingLines) { - BenchmarkListEntry br = new BenchmarkListEntry(line); - entries.add(br); - entriesByQName.put(br.getUserClassQName(), br); - } - } catch (IOException e) { - // Expected in most cases, move on. - } catch (UnsupportedOperationException e) { - destination.printWarning("Unable to read the existing benchmark list, because of UnsupportedOperationException. Run on JDK 7 or higher."); + for (String line : readBenchmarkList(destination)) { + BenchmarkListEntry br = new BenchmarkListEntry(line); + entries.add(br); + entriesByQName.put(br.getUserClassQName(), br); } + } catch (UnsupportedOperationException e) { + destination.printWarning("Unable to read the existing benchmark list, because of UnsupportedOperationException. Run on JDK 7 or higher."); + } - // Generate new benchmark entries - for (BenchmarkInfo info : benchmarkInfos) { - try { - MethodGroup group = info.methodGroup; - for (Mode m : group.getModes()) { - BenchmarkListEntry br = new BenchmarkListEntry( - info.userClassQName, - info.generatedClassQName, - group.getName(), - m, - group.getThreads(), - group.getTotalThreadCount(), - group.getWarmupIterations(), - group.getWarmupTime(), - group.getWarmupBatchSize(), - group.getMeasurementIterations(), - group.getMeasurementTime(), - group.getMeasurementBatchSize(), - group.getForks(), - group.getWarmupForks(), - group.getJvm(), - group.getJvmArgs(), - group.getJvmArgsPrepend(), - group.getJvmArgsAppend(), - group.getParams(), - group.getOutputTimeUnit(), - group.getOperationsPerInvocation(), - group.getTimeout() - ); - - if (entriesByQName.keys().contains(info.userClassQName)) { - destination.printNote("Benchmark entries for " + info.userClassQName + " already exist, overwriting"); - entries.removeAll(entriesByQName.get(info.userClassQName)); - entriesByQName.remove(info.userClassQName); - } - - entries.add(br); + // Generate new benchmark entries + for (BenchmarkInfo info : benchmarkInfos) { + try { + MethodGroup group = info.methodGroup; + for (Mode m : group.getModes()) { + BenchmarkListEntry br = new BenchmarkListEntry( + info.userClassQName, + info.generatedClassQName, + group.getName(), + m, + group.getThreads(), + group.getTotalThreadCount(), + group.getWarmupIterations(), + group.getWarmupTime(), + group.getWarmupBatchSize(), + group.getMeasurementIterations(), + group.getMeasurementTime(), + group.getMeasurementBatchSize(), + group.getForks(), + group.getWarmupForks(), + group.getJvm(), + group.getJvmArgs(), + group.getJvmArgsPrepend(), + group.getJvmArgsAppend(), + group.getParams(), + group.getOutputTimeUnit(), + group.getOperationsPerInvocation(), + group.getTimeout() + ); + + if (entriesByQName.keys().contains(info.userClassQName)) { + destination.printNote("Benchmark entries for " + info.userClassQName + " already exist, overwriting"); + entries.removeAll(entriesByQName.get(info.userClassQName)); + entriesByQName.remove(info.userClassQName); } - } catch (GenerationException ge) { - destination.printError(ge.getMessage(), ge.getElement()); + + entries.add(br); } + } catch (GenerationException ge) { + destination.printError(ge.getMessage(), ge.getElement()); } + } + + writeBenchmarkList(destination, entries); + } + private Collection readBenchmarkList(GeneratorDestination destination) { + Reader reader = null; + try { + reader = destination.getResource(BenchmarkList.BENCHMARK_LIST.substring(1)); + return FileUtils.readAllLines(reader); + } catch (IOException e) { + // okay, move on + } finally { + FileUtils.safelyClose(reader); + } + return Collections.emptyList(); + } + + private void writeBenchmarkList(GeneratorDestination destination, Collection entries) { + PrintWriter writer = null; + try { // Write out the complete benchmark list - PrintWriter writer = new PrintWriter(destination.newResource(BenchmarkList.BENCHMARK_LIST.substring(1))); + writer = new PrintWriter(destination.newResource(BenchmarkList.BENCHMARK_LIST.substring(1))); for (BenchmarkListEntry entry : entries) { writer.println(entry.toLine()); } - writer.close(); - } catch (IOException ex) { destination.printError("Error writing benchmark list", ex); + } finally { + FileUtils.safelyClose(writer); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java index a421fe5c7..80fd8d341 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java @@ -25,7 +25,6 @@ package org.openjdk.jmh.util; import java.io.*; -import java.nio.channels.Channel; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; @@ -183,45 +182,25 @@ public static void copy(String src, String dst) throws IOException { } } - public static void safelyClose(OutputStream out) { - if (out != null) { + public static void safelyClose(T obj) { + if (obj != null) { try { - out.flush(); + obj.flush(); } catch (IOException e) { // ignore } try { - out.close(); + obj.close(); } catch (IOException e) { // ignore } } } - public static void safelyClose(InputStream in) { - if (in != null) { + public static void safelyClose(T obj) { + if (obj != null) { try { - in.close(); - } catch (IOException e) { - // ignore - } - } - } - - public static void safelyClose(Channel channel) { - if (channel != null) { - try { - channel.close(); - } catch (IOException e) { - // do nothing - } - } - } - - public static void safelyClose(Reader reader) { - if (reader != null) { - try { - reader.close(); + obj.close(); } catch (IOException e) { // do nothing } From 38279ac1704f606e32bd11edc4e2c8fdc0c3719b Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 30 May 2016 20:13:31 +0300 Subject: [PATCH 004/342] Update LICENSE with new FSF address --- LICENSE | 6 +++--- jmh-ant-sample/LICENSE | 6 +++--- jmh-archetypes/LICENSE | 6 +++--- jmh-archetypes/jmh-groovy-benchmark-archetype/LICENSE | 6 +++--- .../src/main/resources/LICENSE | 6 +++--- jmh-archetypes/jmh-java-benchmark-archetype/LICENSE | 6 +++--- .../jmh-java-benchmark-archetype/src/main/resources/LICENSE | 6 +++--- jmh-archetypes/jmh-kotlin-benchmark-archetype/LICENSE | 6 +++--- .../src/main/resources/LICENSE | 6 +++--- jmh-archetypes/jmh-scala-benchmark-archetype/LICENSE | 6 +++--- .../src/main/resources/LICENSE | 6 +++--- jmh-core-benchmarks/LICENSE | 6 +++--- jmh-core-benchmarks/src/main/LICENSE | 6 +++--- jmh-core-it/LICENSE | 6 +++--- jmh-core-it/src/test/resources/LICENSE | 6 +++--- jmh-core/LICENSE | 6 +++--- jmh-core/src/main/resources/LICENSE | 6 +++--- jmh-generator-annprocess/LICENSE | 6 +++--- jmh-generator-annprocess/src/main/resources/LICENSE | 6 +++--- jmh-generator-asm/LICENSE | 6 +++--- jmh-generator-asm/src/main/resources/LICENSE | 6 +++--- jmh-generator-bytecode/LICENSE | 6 +++--- jmh-generator-bytecode/src/main/resources/LICENSE | 6 +++--- jmh-generator-reflection/LICENSE | 6 +++--- jmh-generator-reflection/src/main/resources/LICENSE | 6 +++--- 25 files changed, 75 insertions(+), 75 deletions(-) diff --git a/LICENSE b/LICENSE index b40a0f457..8b400c7ab 100644 --- a/LICENSE +++ b/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-ant-sample/LICENSE b/jmh-ant-sample/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-ant-sample/LICENSE +++ b/jmh-ant-sample/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-archetypes/LICENSE b/jmh-archetypes/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-archetypes/LICENSE +++ b/jmh-archetypes/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/LICENSE b/jmh-archetypes/jmh-groovy-benchmark-archetype/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/LICENSE +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/LICENSE b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/LICENSE +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/LICENSE b/jmh-archetypes/jmh-java-benchmark-archetype/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/LICENSE +++ b/jmh-archetypes/jmh-java-benchmark-archetype/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/LICENSE b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/LICENSE +++ b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/LICENSE b/jmh-archetypes/jmh-kotlin-benchmark-archetype/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/LICENSE +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/LICENSE b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/LICENSE +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/LICENSE b/jmh-archetypes/jmh-scala-benchmark-archetype/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/LICENSE +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/LICENSE b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/LICENSE +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-core-benchmarks/LICENSE b/jmh-core-benchmarks/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-core-benchmarks/LICENSE +++ b/jmh-core-benchmarks/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-core-benchmarks/src/main/LICENSE b/jmh-core-benchmarks/src/main/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-core-benchmarks/src/main/LICENSE +++ b/jmh-core-benchmarks/src/main/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-core-it/LICENSE b/jmh-core-it/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-core-it/LICENSE +++ b/jmh-core-it/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-core-it/src/test/resources/LICENSE b/jmh-core-it/src/test/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-core-it/src/test/resources/LICENSE +++ b/jmh-core-it/src/test/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-core/LICENSE b/jmh-core/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-core/LICENSE +++ b/jmh-core/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-core/src/main/resources/LICENSE b/jmh-core/src/main/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-core/src/main/resources/LICENSE +++ b/jmh-core/src/main/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-generator-annprocess/LICENSE b/jmh-generator-annprocess/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-generator-annprocess/LICENSE +++ b/jmh-generator-annprocess/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-generator-annprocess/src/main/resources/LICENSE b/jmh-generator-annprocess/src/main/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-generator-annprocess/src/main/resources/LICENSE +++ b/jmh-generator-annprocess/src/main/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-generator-asm/LICENSE b/jmh-generator-asm/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-generator-asm/LICENSE +++ b/jmh-generator-asm/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-generator-asm/src/main/resources/LICENSE b/jmh-generator-asm/src/main/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-generator-asm/src/main/resources/LICENSE +++ b/jmh-generator-asm/src/main/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-generator-bytecode/LICENSE b/jmh-generator-bytecode/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-generator-bytecode/LICENSE +++ b/jmh-generator-bytecode/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-generator-bytecode/src/main/resources/LICENSE b/jmh-generator-bytecode/src/main/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-generator-bytecode/src/main/resources/LICENSE +++ b/jmh-generator-bytecode/src/main/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-generator-reflection/LICENSE b/jmh-generator-reflection/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-generator-reflection/LICENSE +++ b/jmh-generator-reflection/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. diff --git a/jmh-generator-reflection/src/main/resources/LICENSE b/jmh-generator-reflection/src/main/resources/LICENSE index b40a0f457..8b400c7ab 100644 --- a/jmh-generator-reflection/src/main/resources/LICENSE +++ b/jmh-generator-reflection/src/main/resources/LICENSE @@ -3,7 +3,7 @@ The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -287,8 +287,8 @@ pointer to where the full notice is found. more details. You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place, Suite 330, Boston, MA 02111-1307 USA + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. From 81d5702033aaa17b8c1b186d5cce633b2d489cde Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 23 Jun 2016 20:18:50 +0300 Subject: [PATCH 005/342] 7901706: @State classes are not validated when accessed as dependency --- .../ct/states/dag/AbstractDependencyTest.java | 65 +++++++++++++ .../generators/core/BenchmarkGenerator.java | 83 ++--------------- .../generators/core/StateObjectHandler.java | 93 +++++++++++++++++++ .../generators/annotations/APClassInfo.java | 2 +- 4 files changed, 165 insertions(+), 78 deletions(-) create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/AbstractDependencyTest.java diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/AbstractDependencyTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/AbstractDependencyTest.java new file mode 100644 index 000000000..9da12bce5 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/AbstractDependencyTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.ct.CompileTest; + +public class AbstractDependencyTest { + + @State(Scope.Benchmark) + public abstract static class A { + @Setup(Level.Trial) + public void setup() {} + + protected abstract void helper(); + } + + public static class CA extends A { + @Override + protected void helper() { + // do nothing + } + } + + @State(Scope.Thread) + public static class B { + @Setup(Level.Trial) + public void setup(A b2) {} + + } + + @Benchmark + public void test(CA ca, B b) { + + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "abstract"); + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index d9b9ab60f..350338b1f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -42,7 +42,6 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.Reader; -import java.lang.annotation.IncompleteAnnotationException; import java.lang.reflect.Field; import java.util.*; import java.util.concurrent.TimeUnit; @@ -262,77 +261,20 @@ private void validateBenchmark(ClassInfo clazz, Collection methods) throw new GenerationException("Benchmark classes should not be final.", clazz); } - Collection states = new ArrayList(); - // validate all arguments are @State-s for (MethodInfo e : methods) { - for (ParameterInfo var : e.getParameters()) { - if (BenchmarkGeneratorUtils.getAnnSuper(var.getType(), State.class) == null) { - throw new GenerationException( - "Method parameters should be @" + State.class.getSimpleName() + " classes.", - e); - } - states.add(var.getType()); - } - } - - // validate if enclosing class is implicit @State - if (BenchmarkGeneratorUtils.getAnnSuper(clazz, State.class) != null) { - states.add(clazz); + StateObjectHandler.validateStateArgs(e); } - // validate @State classes - for (ClassInfo state : states) { - // Because of https://bugs.openjdk.java.net/browse/JDK-8031122, - // we need to preemptively check the annotation value, and - // the API can only allow that by catching the exception, argh. - try { - BenchmarkGeneratorUtils.getAnnSuper(state, State.class).value(); - } catch (IncompleteAnnotationException iae) { - throw new GenerationException("The " + State.class.getSimpleName() + - " annotation should have the explicit " + Scope.class.getSimpleName() + " argument", - state); - } - - if (!state.isPublic()) { - throw new GenerationException("The " + State.class.getSimpleName() + - " annotation only supports public classes.", state); - } + boolean explicitState = BenchmarkGeneratorUtils.getAnnSuper(clazz, State.class) != null; - if (state.isFinal()) { - throw new GenerationException("The " + State.class.getSimpleName() + - " annotation does not support final classes.", state); - } - - if (state.isInner()) { - throw new GenerationException("The " + State.class.getSimpleName() + - " annotation does not support inner classes, make sure your class is static.", state); - } - - if (state.isAbstract()) { - throw new GenerationException("The " + State.class.getSimpleName() + - " annotation does not support abstract classes.", state); - } - - boolean hasDefaultConstructor = false; - for (MethodInfo constructor : state.getConstructors()) { - hasDefaultConstructor |= (constructor.getParameters().isEmpty() && constructor.isPublic()); - } - - // These classes use the special init sequence: - hasDefaultConstructor |= state.getQualifiedName().equals(BenchmarkParams.class.getCanonicalName()); - hasDefaultConstructor |= state.getQualifiedName().equals(IterationParams.class.getCanonicalName()); - hasDefaultConstructor |= state.getQualifiedName().equals(ThreadParams.class.getCanonicalName()); - - if (!hasDefaultConstructor) { - throw new GenerationException("The " + State.class.getSimpleName() + - " annotation can only be applied to the classes having the default public constructor.", - state); - } + // validate if enclosing class is implicit @State + if (explicitState) { + StateObjectHandler.validateState(clazz); } // validate against rogue fields - if (BenchmarkGeneratorUtils.getAnnSuper(clazz, State.class) == null || clazz.isAbstract()) { + if (!explicitState || clazz.isAbstract()) { for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(clazz)) { // allow static fields if (fi.isStatic()) continue; @@ -345,29 +287,16 @@ private void validateBenchmark(ClassInfo clazz, Collection methods) // validate rogue annotations on classes BenchmarkGeneratorUtils.checkAnnotations(clazz); - for (ClassInfo state : states) { - BenchmarkGeneratorUtils.checkAnnotations(state); - } // validate rogue annotations on fields for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(clazz)) { BenchmarkGeneratorUtils.checkAnnotations(fi); } - for (ClassInfo state : states) { - for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(state)) { - BenchmarkGeneratorUtils.checkAnnotations(fi); - } - } // validate rogue annotations on methods for (MethodInfo mi : methods) { BenchmarkGeneratorUtils.checkAnnotations(mi); } - for (ClassInfo state : states) { - for (MethodInfo mi : BenchmarkGeneratorUtils.getMethods(state)) { - BenchmarkGeneratorUtils.checkAnnotations(mi); - } - } // check modifiers for (MethodInfo m : methods) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 397294a7a..9b7647975 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.lang.annotation.Annotation; +import java.lang.annotation.IncompleteAnnotationException; import java.util.*; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; @@ -63,6 +64,92 @@ public StateObjectHandler(CompilerControlPlugin compileControl) { this.identifiers = new Identifiers(); } + public static void validateState(ClassInfo state) { + // Because of https://bugs.openjdk.java.net/browse/JDK-8031122, + // we need to preemptively check the annotation value, and + // the API can only allow that by catching the exception, argh. + try { + State ann = BenchmarkGeneratorUtils.getAnnSuper(state, State.class); + if (ann != null) { + ann.value(); + } + } catch (IncompleteAnnotationException iae) { + throw new GenerationException("The @" + State.class.getSimpleName() + + " annotation should have the explicit " + Scope.class.getSimpleName() + " argument", + state); + } + + if (!state.isPublic()) { + throw new GenerationException("The instantiated @" + State.class.getSimpleName() + + " annotation only supports public classes.", state); + } + + if (state.isFinal()) { + throw new GenerationException("The instantiated @" + State.class.getSimpleName() + + " annotation does not support final classes. This class is not " , state); + } + + if (state.isInner()) { + throw new GenerationException("The instantiated @" + State.class.getSimpleName() + + " annotation does not support inner classes, make sure your class is static.", state); + } + + if (state.isAbstract()) { + throw new GenerationException("The instantiated @" + State.class.getSimpleName() + + " class cannot be abstract.", state); + } + + boolean hasDefaultConstructor = false; + for (MethodInfo constructor : state.getConstructors()) { + hasDefaultConstructor |= (constructor.getParameters().isEmpty() && constructor.isPublic()); + } + + // These classes use the special init sequence: + hasDefaultConstructor |= state.getQualifiedName().equals(BenchmarkParams.class.getCanonicalName()); + hasDefaultConstructor |= state.getQualifiedName().equals(IterationParams.class.getCanonicalName()); + hasDefaultConstructor |= state.getQualifiedName().equals(ThreadParams.class.getCanonicalName()); + + if (!hasDefaultConstructor) { + throw new GenerationException("The @" + State.class.getSimpleName() + + " annotation can only be applied to the classes having the default public constructor.", + state); + } + + // validate rogue annotations on classes + BenchmarkGeneratorUtils.checkAnnotations(state); + for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(state)) { + BenchmarkGeneratorUtils.checkAnnotations(fi); + } + + // validate rogue annotations on methods + for (MethodInfo mi : BenchmarkGeneratorUtils.getMethods(state)) { + BenchmarkGeneratorUtils.checkAnnotations(mi); + } + + // check @Setup/@TearDown have only @State arguments + for (MethodInfo mi : BenchmarkGeneratorUtils.getAllMethods(state)) { + if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) { + for (ParameterInfo var : mi.getParameters()) { + if (BenchmarkGeneratorUtils.getAnnSuper(var.getType(), State.class) == null) { + throw new GenerationException( + "Method parameters should be @" + State.class.getSimpleName() + " classes.", + mi); + } + } + } + } + } + + public static void validateStateArgs(MethodInfo e) { + for (ParameterInfo var : e.getParameters()) { + if (BenchmarkGeneratorUtils.getAnnSuper(var.getType(), State.class) == null) { + throw new GenerationException( + "Method parameters should be @" + State.class.getSimpleName() + " classes.", + e); + } + } + } + public State getState(ClassInfo ci, ParameterInfo pi) { State ann = BenchmarkGeneratorUtils.getAnnSuper(ci, State.class); if (ann == null) { @@ -75,6 +162,9 @@ public void bindMethodGroup(MethodGroup mg) { for (MethodInfo method : mg.methods()) { Set seen = new HashSet(); + // Check that all arguments are states. + validateStateArgs(method); + for (ParameterInfo ppi : method.getParameters()) { ClassInfo pci = ppi.getType(); @@ -130,6 +220,9 @@ public void bindImplicit(ClassInfo ci, String label, Scope scope) { } private void bindState(MethodInfo execMethod, StateObject so, ClassInfo ci) { + // Check it is a valid state + validateState(ci); + // auxiliary result, produce the accessors if (ci.getAnnotation(AuxCounters.class) != null) { if (so.scope != Scope.Thread) { diff --git a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java index b538d4b4d..a69fb0c8a 100644 --- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java +++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java @@ -62,7 +62,7 @@ public APClassInfo(ProcessingEnvironment processEnv, TypeElement element) { } public APClassInfo(ProcessingEnvironment processEnv, TypeMirror mirror) { - super(processEnv, null); + super(processEnv, processEnv.getTypeUtils().asElement(mirror)); this.mirror = mirror; this.isSpecial = mirror.getKind().isPrimitive() || (mirror.getKind() == TypeKind.ARRAY); if (isSpecial) { From ccbf5554d9de3c3e23c706adddfc368dcd4b9c72 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 12 Jul 2016 22:06:25 +0300 Subject: [PATCH 006/342] 7901729: Usability: Print thread distribution for asymmetric benchmarks --- .../it/threads/GroupThreadGroupOrderTest.java | 102 ++++++++++++++++++ .../generators/core/BenchmarkGenerator.java | 3 +- .../jmh/generators/core/MethodGroup.java | 14 ++- .../openjdk/jmh/infra/BenchmarkParams.java | 32 ++++-- .../jmh/runner/BenchmarkListEntry.java | 34 +++--- .../java/org/openjdk/jmh/runner/Runner.java | 3 +- .../jmh/runner/format/TextReportFormat.java | 35 +++++- .../jmh/results/TestAggregateResult.java | 4 +- .../jmh/results/format/ResultFormatTest.java | 1 + .../org/openjdk/jmh/runner/RunnerTest.java | 12 ++- .../org/openjdk/jmh/runner/MicroBenchmarks | 40 +++---- 11 files changed, 226 insertions(+), 54 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupThreadGroupOrderTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupThreadGroupOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupThreadGroupOrderTest.java new file mode 100644 index 000000000..9e96c2ede --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupThreadGroupOrderTest.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.threads; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * Tests if harness executes setup, run, and tearDown in the same workers. + */ +@BenchmarkMode(Mode.All) +@Warmup(iterations = 0) +@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +@State(Scope.Group) +public class GroupThreadGroupOrderTest { + + private Set abc = Collections.synchronizedSet(new HashSet()); + private Set def = Collections.synchronizedSet(new HashSet()); + private Set ghi = Collections.synchronizedSet(new HashSet()); + + @Setup(Level.Iteration) + public void prepare() { + abc.clear(); + def.clear(); + ghi.clear(); + } + + @TearDown(Level.Iteration) + public void verify() { + Assert.assertEquals("Test abc", 3, abc.size()); + Assert.assertEquals("Test def", 1, def.size()); + Assert.assertEquals("Test ghi", 2, ghi.size()); + } + + @Benchmark + @Group("T") + public void abc() { + abc.add(Thread.currentThread()); + Fixtures.work(); + } + + @Benchmark + @Group("T") + public void ghi() { + ghi.add(Thread.currentThread()); + Fixtures.work(); + } + + @Benchmark + @Group("T") + public void def() { + def.add(Thread.currentThread()); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .threadGroups(3, 1, 2) + .shouldFailOnError(true) + .build(); + new Runner(opt).run(); + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 350338b1f..6d87ef4c2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -156,8 +156,9 @@ public void complete(GeneratorSource source, GeneratorDestination destination) { info.generatedClassQName, group.getName(), m, - group.getThreads(), group.getTotalThreadCount(), + group.getGroupThreads(), + group.getGroupLabels(), group.getWarmupIterations(), group.getWarmupTime(), group.getWarmupBatchSize(), diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java index e10244674..7d3ca3c09 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java @@ -128,7 +128,7 @@ public Set getModes() { return modes; } - public int[] getThreads() { + public int[] getGroupThreads() { int[] threads = new int[methods.size()]; int c = 0; for (MethodInvocation mi : methods.keySet()) { @@ -137,6 +137,18 @@ public int[] getThreads() { return threads; } + public Optional> getGroupLabels() { + if (methods.size() > 1) { + Collection labels = new ArrayList(); + for (MethodInvocation mi : methods.keySet()) { + labels.add(mi.method.getName()); + } + return Optional.eitherOf(labels); + } else { + return Optional.none(); + } + } + public Optional getOperationsPerInvocation() { for (OperationsPerInvocation ann : getAll(OperationsPerInvocation.class)) { return Optional.of(ann.value()); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java index eb9444745..85e958764 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java @@ -71,14 +71,16 @@ public BenchmarkParams(BenchmarkParams other) { } public BenchmarkParams(String benchmark, String generatedTarget, boolean synchIterations, - int threads, int[] threadGroups, int forks, int warmupForks, + int threads, int[] threadGroups, Collection threadGroupLabels, + int forks, int warmupForks, IterationParams warmup, IterationParams measurement, Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, - threads, threadGroups, forks, warmupForks, + threads, threadGroups, threadGroupLabels, + forks, warmupForks, warmup, measurement, mode, params, timeUnit, opsPerInvocation, @@ -91,14 +93,16 @@ abstract class BenchmarkParamsL4 extends BenchmarkParamsL3 { private int markerEnd; public BenchmarkParamsL4(String benchmark, String generatedTarget, boolean synchIterations, - int threads, int[] threadGroups, int forks, int warmupForks, + int threads, int[] threadGroups, Collection threadGroupLabels, + int forks, int warmupForks, IterationParams warmup, IterationParams measurement, Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, - threads, threadGroups, forks, warmupForks, + threads, threadGroups, threadGroupLabels, + forks, warmupForks, warmup, measurement, mode, params, timeUnit, opsPerInvocation, @@ -132,14 +136,16 @@ abstract class BenchmarkParamsL3 extends BenchmarkParamsL2 { private boolean q171, q172, q173, q174, q175, q176, q177, q178; public BenchmarkParamsL3(String benchmark, String generatedTarget, boolean synchIterations, - int threads, int[] threadGroups, int forks, int warmupForks, + int threads, int[] threadGroups, Collection threadGroupLabels, + int forks, int warmupForks, IterationParams warmup, IterationParams measurement, Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, - threads, threadGroups, forks, warmupForks, + threads, threadGroups, threadGroupLabels, + forks, warmupForks, warmup, measurement, mode, params, timeUnit, opsPerInvocation, @@ -183,6 +189,7 @@ abstract class BenchmarkParamsL2 extends BenchmarkParamsL1 implements Serializab protected final boolean synchIterations; protected final int threads; protected final int[] threadGroups; + protected final Collection threadGroupLabels; protected final int forks; protected final int warmupForks; protected final IterationParams warmup; @@ -196,7 +203,8 @@ abstract class BenchmarkParamsL2 extends BenchmarkParamsL1 implements Serializab protected final TimeValue timeout; public BenchmarkParamsL2(String benchmark, String generatedTarget, boolean synchIterations, - int threads, int[] threadGroups, int forks, int warmupForks, + int threads, int[] threadGroups, Collection threadGroupLabels, + int forks, int warmupForks, IterationParams warmup, IterationParams measurement, Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, @@ -207,6 +215,7 @@ public BenchmarkParamsL2(String benchmark, String generatedTarget, boolean synch this.synchIterations = synchIterations; this.threads = threads; this.threadGroups = threadGroups; + this.threadGroupLabels = threadGroupLabels; this.forks = forks; this.warmupForks = warmupForks; this.warmup = warmup; @@ -226,6 +235,7 @@ public BenchmarkParamsL2(BenchmarkParams other) { this.synchIterations = other.synchIterations; this.threads = other.threads; this.threadGroups = other.threadGroups; + this.threadGroupLabels = other.threadGroupLabels; this.forks = other.forks; this.warmupForks = other.warmupForks; this.warmup = other.warmup; @@ -282,6 +292,14 @@ public int[] getThreadGroups() { return Arrays.copyOf(threadGroups, threadGroups.length); } + /** + * @return subgroup thread labels + * @see #getThreadGroups() + */ + public Collection getThreadGroupLabels() { + return Collections.unmodifiableCollection(threadGroupLabels); + } + /** * @return number of forked VM runs, which we measure */ diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java index 058bb41e2..cfe86dc9c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java @@ -44,6 +44,7 @@ public class BenchmarkListEntry implements Comparable { private final String method; private final Mode mode; private final int[] threadGroups; + private final Optional> threadGroupLabels; private final Optional threads; private final Optional warmupIterations; private final Optional warmupTime; @@ -64,7 +65,8 @@ public class BenchmarkListEntry implements Comparable { private WorkloadParams workloadParams; - public BenchmarkListEntry(String userClassQName, String generatedClassQName, String method, Mode mode, int[] threadGroups, Optional threads, + public BenchmarkListEntry(String userClassQName, String generatedClassQName, String method, Mode mode, + Optional threads, int[] threadGroups, Optional> threadGroupLabels, Optional warmupIterations, Optional warmupTime, Optional warmupBatchSize, Optional measurementIterations, Optional measurementTime, Optional measurementBatchSize, Optional forks, Optional warmupForks, @@ -77,6 +79,7 @@ public BenchmarkListEntry(String userClassQName, String generatedClassQName, Str this.mode = mode; this.threadGroups = threadGroups; this.threads = threads; + this.threadGroupLabels = threadGroupLabels; this.warmupIterations = warmupIterations; this.warmupTime = warmupTime; this.warmupBatchSize = warmupBatchSize; @@ -99,7 +102,7 @@ public BenchmarkListEntry(String userClassQName, String generatedClassQName, Str public BenchmarkListEntry(String line) { String[] args = line.split(BR_SEPARATOR); - if (args.length != 22) { + if (args.length != 23) { throw new IllegalStateException("Mismatched format for the line: " + line); } @@ -110,8 +113,9 @@ public BenchmarkListEntry(String line) { this.generatedClassQName = args[idx++].trim(); this.method = args[idx++].trim(); this.mode = Mode.deepValueOf(args[idx++].trim()); - this.threadGroups = Utils.unmarshalIntArray(args[idx++]); this.threads = Optional.of(args[idx++], INTEGER_UNMARSHALLER); + this.threadGroups = Utils.unmarshalIntArray(args[idx++]); + this.threadGroupLabels = Optional.of(args[idx++], STRING_COLLECTION_UNMARSHALLER); this.warmupIterations = Optional.of(args[idx++], INTEGER_UNMARSHALLER); this.warmupTime = Optional.of(args[idx++], TIME_VALUE_UNMARSHALLER); this.warmupBatchSize = Optional.of(args[idx++], INTEGER_UNMARSHALLER); @@ -130,18 +134,10 @@ public BenchmarkListEntry(String line) { this.timeout = Optional.of(args[idx++], TIME_VALUE_UNMARSHALLER); } - public BenchmarkListEntry(String userClassQName, String generatedName, String method, Mode mode) { - this(userClassQName, generatedName, method, mode, new int[]{}, Optional.none(), - Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), Optional.none(), - Optional.none(), Optional.none(), - Optional.none(), Optional.>none(), Optional.>none(), Optional.>none(), - Optional.>none(), Optional.none(), Optional.none(), - Optional.none()); - } - public String toLine() { - return userClassQName + BR_SEPARATOR + generatedClassQName + BR_SEPARATOR + method + BR_SEPARATOR + mode + BR_SEPARATOR + Utils.marshalIntArray(threadGroups) + BR_SEPARATOR + - threads + BR_SEPARATOR + warmupIterations + BR_SEPARATOR + warmupTime + BR_SEPARATOR + warmupBatchSize + BR_SEPARATOR + + return userClassQName + BR_SEPARATOR + generatedClassQName + BR_SEPARATOR + method + BR_SEPARATOR + mode + BR_SEPARATOR + + threads + BR_SEPARATOR + Utils.marshalIntArray(threadGroups) + BR_SEPARATOR + threadGroupLabels.toString(STRING_COLLECTION_MARSHALLER) + BR_SEPARATOR + + warmupIterations + BR_SEPARATOR + warmupTime + BR_SEPARATOR + warmupBatchSize + BR_SEPARATOR + measurementIterations + BR_SEPARATOR + measurementTime + BR_SEPARATOR + measurementBatchSize + BR_SEPARATOR + forks + BR_SEPARATOR + warmupForks + BR_SEPARATOR + jvm.toString(STRING_MARSHALLER) + BR_SEPARATOR + @@ -154,7 +150,8 @@ public String toLine() { } public BenchmarkListEntry cloneWith(Mode mode) { - return new BenchmarkListEntry(userClassQName, generatedClassQName, method, mode, threadGroups, threads, + return new BenchmarkListEntry(userClassQName, generatedClassQName, method, mode, + threads, threadGroups, threadGroupLabels, warmupIterations, warmupTime, warmupBatchSize, measurementIterations, measurementTime, measurementBatchSize, forks, warmupForks, @@ -164,7 +161,8 @@ public BenchmarkListEntry cloneWith(Mode mode) { } public BenchmarkListEntry cloneWith(WorkloadParams p) { - BenchmarkListEntry br = new BenchmarkListEntry(userClassQName, generatedClassQName, method, mode, threadGroups, threads, + BenchmarkListEntry br = new BenchmarkListEntry(userClassQName, generatedClassQName, method, mode, + threads, threadGroups, threadGroupLabels, warmupIterations, warmupTime, warmupBatchSize, measurementIterations, measurementTime, measurementBatchSize, forks, warmupForks, @@ -242,6 +240,10 @@ public int[] getThreadGroups() { return Arrays.copyOf(threadGroups, threadGroups.length); } + public Optional> getThreadGroupLabels() { + return threadGroupLabels; + } + @Override public String toString() { return "{\'" + userClassQName + "." + method + "\', " + mode + ", " + workloadParams + "}"; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 54299e2e3..14c1d9634 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -480,7 +480,8 @@ private BenchmarkParams newBenchmarkParams(BenchmarkListEntry benchmark, ActionM benchmark.getTimeout().orElse(Defaults.TIMEOUT)); return new BenchmarkParams(benchmark.getUsername(), benchmark.generatedTarget(), synchIterations, - threads, threadGroups, forks, warmupForks, + threads, threadGroups, benchmark.getThreadGroupLabels().orElse(Collections.emptyList()), + forks, warmupForks, warmup, measurement, benchmark.getMode(), benchmark.getWorkloadParams(), timeUnit, opsPerInvocation, jvm, jvmArgs, timeout); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index 8e84e1220..0a830473d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -36,9 +36,12 @@ import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; +import org.openjdk.jmh.util.Utils; import java.io.PrintStream; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -76,10 +79,26 @@ public void startBenchmark(BenchmarkParams params) { (timeout.convertTo(TimeUnit.NANOSECONDS) <= warmup.getTime().convertTo(TimeUnit.NANOSECONDS)); out.println("# Timeout: " + timeout + " per iteration" + (timeoutWarning ? ", ***WARNING: The timeout might be too low!***" : "")); - out.println("# Threads: " + params.getThreads() + " " + getThreadsString(params.getThreads()) + - (params.shouldSynchIterations() ? - ", will synchronize iterations" : - (params.getMode() == Mode.SingleShotTime) ? "" : ", ***WARNING: Synchronize iterations are disabled!***")); + out.print("# Threads: " + params.getThreads() + " " + getThreadsString(params.getThreads())); + + if (!params.getThreadGroupLabels().isEmpty()) { + int[] tg = params.getThreadGroups(); + + // TODO: Make params.getThreadGroupLabels return List + List labels = new ArrayList(params.getThreadGroupLabels()); + String[] ss = new String[tg.length]; + for (int cnt = 0; cnt < tg.length; cnt++) { + ss[cnt] = tg[cnt] + "x \"" + labels.get(cnt) + "\""; + } + + int groupCount = params.getThreads() / Utils.sum(tg); + out.print(" (" + groupCount + " " + getGroupsString(groupCount) + "; " + Utils.join(ss, ", ") + " in each group)"); + } + + out.println(params.shouldSynchIterations() ? + ", will synchronize iterations" : + (params.getMode() == Mode.SingleShotTime) ? "" : ", ***WARNING: Synchronize iterations are disabled!***"); + out.println("# Benchmark mode: " + params.getMode().longLabel()); out.println("# Benchmark: " + params.getBenchmark()); @@ -121,6 +140,14 @@ protected static String getThreadsString(int t) { } } + protected static String getGroupsString(int g) { + if (g > 1) { + return "groups"; + } else { + return "group"; + } + } + @Override public void iterationResult(BenchmarkParams benchmParams, IterationParams params, int iteration, IterationResult data) { StringBuilder sb = new StringBuilder(); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java index c4e83ae6e..7075f510a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java @@ -49,7 +49,9 @@ public class TestAggregateResult { @BeforeClass public static void setupClass() { result = new IterationResult( - new BenchmarkParams("blah", "blah", false, 1, new int[]{1}, 1, 1, + new BenchmarkParams("blah", "blah", false, + 1, new int[]{1}, Collections.emptyList(), + 1, 1, new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java index 143618e5d..c37091144 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java @@ -62,6 +62,7 @@ private Collection getStub() { false, r.nextInt(1000), new int[]{ r.nextInt(1000) }, + Collections.emptyList(), r.nextInt(1000), r.nextInt(1000), new IterationParams(IterationType.WARMUP, r.nextInt(1000), TimeValue.seconds(r.nextInt(1000)), 1), diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java index 9abc01cf7..1fac9ba17 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java @@ -57,7 +57,9 @@ public void testNullCheck() { @Test public void testEmptyOptsHaveCompileCommandFile() { Runner blade = new Runner(new OptionsBuilder()); - BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, 1, new int[]{1}, 1, 1, + BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, + 1, new int[]{1}, Collections.emptyList(), + 1, 1, new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, @@ -86,7 +88,9 @@ public void testOptsWithCompileCommandFileResultInMergedCompileCommandFile() thr Arrays.asList("inline,we/like/to/move/it.*")); Set extraHints = CompilerHints.fromFile(tempHints).get(); Runner blade = new Runner(new OptionsBuilder().build()); - BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, 1, new int[]{1}, 1, 1, + BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, + 1, new int[]{1}, Collections.emptyList(), + 1, 1, new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, @@ -119,7 +123,9 @@ public void testOptsWith2CompileCommandFilesResultInMergedCompileCommandFile() t Arrays.asList("inline,we/like/to/move/it.*")); Set extraHints2 = CompilerHints.fromFile(tempHints2).get(); Runner blade = new Runner(new OptionsBuilder().build()); - BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, 1, new int[]{1}, 1, 1, + BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, + 1, new int[]{1}, Collections.emptyList(), + 1, 1, new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks b/jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks index e977bc0b3..f4040293c 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks +++ b/jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks @@ -23,24 +23,24 @@ # -oracle.micro.benchmarks.api.java.util.concurrent.NormalMaps===,===oracle.micro.benchmarks.api.java.util.concurrent.generated.NormalMaps===,===testConcurrentHashMap===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005HashMapGetIntThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005HashMapGetIntGCThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005HashMapGetIntegerThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005ResizedHashMapGetIntThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005ResizedHashMapGetIntegerThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64===,===printBase64Binary_128bytesThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64===,===printBase64Binary_32bytesThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64===,===printBase64Binary_512bytesThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps===,===oracle.micro.benchmarks.api.java.util.concurrent.generated.GeneratedMaps===,===testConcurrentHashMap===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.api.java.util.concurrent.NormalMaps===,===oracle.micro.benchmarks.api.java.util.concurrent.generated.NormalMaps===,===testConcurrentHashMap===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005HashMapGetIntThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005HashMapGetIntGCThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005HashMapGetIntegerThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005ResizedHashMapGetIntThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005ResizedHashMapGetIntegerThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64===,===printBase64Binary_128bytesThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64===,===printBase64Binary_32bytesThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64===,===printBase64Binary_512bytesThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps===,===oracle.micro.benchmarks.api.java.util.concurrent.generated.GeneratedMaps===,===testConcurrentHashMap===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummy===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummyWarmThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummyWarmOnlyThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummySetupPayloadThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===boom_ExceptionThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===boom_ErrorThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===boom_ThrowableThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===blackholedThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestBrokenMicro===,===org.openjdk.jmh.runner.generated.TestBrokenMicro===,===dummyPayloadThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestExceptionThrowingMicro===,===org.openjdk.jmh.runner.generated.TestExceptionThrowingMicro===,===ouchThroughput===,===AverageTime===,===1====,===[4]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummy===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummyWarmThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummyWarmOnlyThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummySetupPayloadThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===boom_ExceptionThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===boom_ErrorThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===boom_ThrowableThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===blackholedThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestBrokenMicro===,===org.openjdk.jmh.runner.generated.TestBrokenMicro===,===dummyPayloadThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] +org.openjdk.jmh.runner.TestExceptionThrowingMicro===,===org.openjdk.jmh.runner.generated.TestExceptionThrowingMicro===,===ouchThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] From a68eed552a29b8c1d101b9249bf434ccf5e8b4f4 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 12 Jul 2016 23:46:52 +0300 Subject: [PATCH 007/342] 7901708: Inconsistency in labelling and usage for dynamically discovered profilers Print FQN for dynamically discovered profilers in profiler list. --- .../openjdk/jmh/profile/ProfilerFactory.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java index 28aff97e7..3b683c165 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java @@ -112,6 +112,15 @@ public static List getSupportedInternal(Collection s : ProfilerFactory.getDiscoveredProfilers()) { + maxLen = Math.max(maxLen, s.getCanonicalName().length()); + } + maxLen += 2; + StringBuilder supported = new StringBuilder(); StringBuilder unsupported = new StringBuilder(); @@ -121,13 +130,13 @@ public static void listProfilers(PrintStream out) { String descr = (prof != null) ? prof.getDescription() : "(unable to instantiate the profiler)"; if (prof != null) { - supported.append(String.format("%20s: %s %s\n", s, descr, "")); + supported.append(String.format("%" + maxLen + "s: %s %s\n", s, descr, "")); } else { - unsupported.append(String.format("%20s: %s %s\n", s, descr, "")); + unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s, descr, "")); unsupported.append("\n"); } } catch (ProfilerException e) { - unsupported.append(String.format("%20s: %s %s\n", s, "", "")); + unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s, "", "")); unsupported.append(e.getMessage()); unsupported.append("\n"); } @@ -139,13 +148,13 @@ public static void listProfilers(PrintStream out) { String descr = (prof != null) ? prof.getDescription() : "(unable to instantiate the profiler)"; if (prof != null) { - supported.append(String.format("%20s: %s %s\n", "", descr, "(discovered)")); + supported.append(String.format("%" + maxLen + "s: %s %s\n", s.getCanonicalName(), descr, "(discovered)")); } else { - unsupported.append(String.format("%20s: %s %s\n", "", descr, "(discovered)")); + unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s.getCanonicalName(), descr, "(discovered)")); unsupported.append("\n"); } } catch (ProfilerException e) { - unsupported.append(String.format("%20s: %s %s\n", s, "", "")); + unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s, s.getCanonicalName(), "")); unsupported.append(e.getMessage()); unsupported.append("\n"); } From fd248828e2526e9d7e2dc011eb106974430263f0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 13 Jul 2016 01:00:45 +0300 Subject: [PATCH 008/342] 7901707: Ability to use different JVM options for different forks --- .../ChangeJVMOptsExternalProfiler.java | 72 ++++++++++++ .../jmh/it/profilers/ChangeJVMOptsTest.java | 105 ++++++++++++++++++ .../services/org.openjdk.jmh.profile.Profiler | 1 + .../java/org/openjdk/jmh/runner/Runner.java | 23 ++-- .../java/org/openjdk/jmh/util/FileUtils.java | 24 ++++ .../org/openjdk/jmh/runner/RunnerTest.java | 7 +- 6 files changed, 221 insertions(+), 11 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsExternalProfiler.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsExternalProfiler.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsExternalProfiler.java new file mode 100644 index 000000000..1cc862518 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsExternalProfiler.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.openjdk.jmh.infra.BenchmarkParams; +import org.openjdk.jmh.profile.ExternalProfiler; +import org.openjdk.jmh.results.BenchmarkResult; +import org.openjdk.jmh.results.Result; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; + +public class ChangeJVMOptsExternalProfiler implements ExternalProfiler { + + @Override + public Collection addJVMInvokeOptions(BenchmarkParams params) { + return Collections.emptyList(); + } + + @Override + public Collection addJVMOptions(BenchmarkParams params) { + return Collections.singletonList("-Dkey=" + Math.random()); + } + + @Override + public void beforeTrial(BenchmarkParams benchmarkParams) { + // intentionally left blank + } + + @Override + public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { + return Collections.emptyList(); + } + + @Override + public boolean allowPrintOut() { + return true; + } + + @Override + public boolean allowPrintErr() { + return true; + } + + @Override + public String getDescription() { + return "Changing JVM Opts Integration Test External Profiler"; + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java new file mode 100644 index 000000000..aed134347 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.*; +import org.openjdk.jmh.util.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +@State(Scope.Benchmark) +public class ChangeJVMOptsTest { + + public static final File TMP_FILE = new File(System.getProperty("java.io.tmpdir") + File.separator + "ChangingJVMOpts-list"); + + @Setup(Level.Trial) + public void setup() { + try { + FileUtils.appendLines(TMP_FILE, + Collections.singleton(ManagementFactory.getRuntimeMXBean().getInputArguments().toString())); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + @Benchmark + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) + @Fork(value = 5, warmups = 5) + public void bench() { + // intentionally left blank + } + + @Test + public void testExternal_API() throws RunnerException, IOException { + prepare(); + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .warmupForks(5) + .forks(5) + .addProfiler(ChangeJVMOptsExternalProfiler.class) + .build(); + new Runner(opts).run(); + + check(); + } + + @Test + public void testExternal_CLI() throws RunnerException, CommandLineOptionException, IOException { + prepare(); + + Options opts = new CommandLineOptions("-prof", ChangeJVMOptsExternalProfiler.class.getCanonicalName(), Fixtures.getTestMask(this.getClass())); + new Runner(opts).run(); + + check(); + } + + private void prepare() { + TMP_FILE.delete(); + } + + private void check() throws IOException { + Set lines = new HashSet(); + for (String line : FileUtils.readAllLines(TMP_FILE)) { + if (!lines.add(line)) { + Assert.fail("Duplicate line: " + line); + } + } + } + +} diff --git a/jmh-core-it/src/test/resources/META-INF/services/org.openjdk.jmh.profile.Profiler b/jmh-core-it/src/test/resources/META-INF/services/org.openjdk.jmh.profile.Profiler index 8a80dbe39..78cee842e 100644 --- a/jmh-core-it/src/test/resources/META-INF/services/org.openjdk.jmh.profile.Profiler +++ b/jmh-core-it/src/test/resources/META-INF/services/org.openjdk.jmh.profile.Profiler @@ -1,5 +1,6 @@ org.openjdk.jmh.it.profilers.ItInternalProfiler org.openjdk.jmh.it.profilers.ItExternalProfiler +org.openjdk.jmh.it.profilers.ChangeJVMOptsExternalProfiler org.openjdk.jmh.it.profilers.order.InternalProfiler1 org.openjdk.jmh.it.profilers.order.InternalProfiler2 org.openjdk.jmh.it.profilers.order.InternalProfiler3 diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 14c1d9634..86efa6f09 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -587,11 +587,7 @@ private Multimap runSeparate(ActionPlan action boolean printOut = true; boolean printErr = true; - List javaInvokeOptions = new ArrayList(); - List javaOptions = new ArrayList(); for (ExternalProfiler prof : profilers) { - javaInvokeOptions.addAll(prof.addJVMInvokeOptions(params)); - javaOptions.addAll(prof.addJVMOptions(params)); printOut &= prof.allowPrintOut(); printErr &= prof.allowPrintErr(); } @@ -603,7 +599,6 @@ private Multimap runSeparate(ActionPlan action printOut = forcePrint || printOut; printErr = forcePrint || printErr; - List forkedString = getForkedMainCommand(params, javaInvokeOptions, javaOptions, server.getHost(), server.getPort()); List versionString = getVersionMainCommand(params); String opts = Utils.join(params.getJvmArgs(), " "); @@ -621,8 +616,10 @@ private Multimap runSeparate(ActionPlan action int forkCount = params.getForks(); int warmupForkCount = params.getWarmupForks(); if (warmupForkCount > 0) { - out.verbosePrintln("Warmup forking " + warmupForkCount + " times using command: " + forkedString); for (int i = 0; i < warmupForkCount; i++) { + List forkedString = getForkedMainCommand(params, profilers, server.getHost(), server.getPort()); + out.verbosePrintln("Warmup forking using command: " + forkedString); + etaBeforeBenchmark(); out.println("# Warmup Fork: " + (i + 1) + " of " + warmupForkCount); @@ -636,8 +633,10 @@ private Multimap runSeparate(ActionPlan action } } - out.verbosePrintln("Forking " + forkCount + " times using command: " + forkedString); for (int i = 0; i < forkCount; i++) { + List forkedString = getForkedMainCommand(params, profilers, server.getHost(), server.getPort()); + out.verbosePrintln("Forking using command: " + forkedString); + etaBeforeBenchmark(); out.println("# Fork: " + (i + 1) + " of " + forkCount); @@ -786,7 +785,15 @@ private List doFork(BinaryLinkServer reader, List comma * @param port host VM port * @return */ - List getForkedMainCommand(BenchmarkParams benchmark, List javaInvokeOptions, List javaOptions, String host, int port) { + List getForkedMainCommand(BenchmarkParams benchmark, List profilers, String host, int port) { + // Poll profilers for options + List javaInvokeOptions = new ArrayList(); + List javaOptions = new ArrayList(); + for (ExternalProfiler prof : profilers) { + javaInvokeOptions.addAll(prof.addJVMInvokeOptions(benchmark)); + javaOptions.addAll(prof.addJVMOptions(benchmark)); + } + List command = new ArrayList(); // prefix java invoke options, if any profiler wants it diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java index 80fd8d341..e27850bd2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java @@ -134,6 +134,30 @@ public static Collection readAllLines(File file) throws IOException { } } + public static void writeLines(File file, Collection lines) throws IOException { + PrintWriter pw = null; + try { + pw = new PrintWriter(file); + for (String line : lines) { + pw.println(line); + } + pw.close(); + } finally { + FileUtils.safelyClose(pw); + } + } + + public static void appendLines(File file, Collection lines) throws IOException { + Collection newLines = new ArrayList(); + try { + newLines.addAll(readAllLines(file)); + } catch (IOException e) { + // no file + } + newLines.addAll(lines); + writeLines(file, newLines); + } + public static Collection getClasses(File root) { Collection result = new ArrayList(); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java index 1fac9ba17..5cc143c2a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java @@ -28,6 +28,7 @@ import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; +import org.openjdk.jmh.profile.ExternalProfiler; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.FileUtils; @@ -65,7 +66,7 @@ public void testEmptyOptsHaveCompileCommandFile() { Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.emptyList(), TimeValue.days(1)); - List command = blade.getForkedMainCommand(bp, Collections.emptyList(), Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); + List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); // expecting 1 compile command file List files = CompilerHints.getCompileCommandFiles(command); @@ -96,7 +97,7 @@ public void testOptsWithCompileCommandFileResultInMergedCompileCommandFile() thr Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Arrays.asList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints), TimeValue.days(1)); - List command = blade.getForkedMainCommand(bp, Collections.emptyList(), Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); + List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); // expecting 1 compile command file List files = CompilerHints.getCompileCommandFiles(command); @@ -132,7 +133,7 @@ public void testOptsWith2CompileCommandFilesResultInMergedCompileCommandFile() t Utils.getCurrentJvm(), Arrays.asList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints1, CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints2), TimeValue.days(1)); - List command = blade.getForkedMainCommand(bp, Collections.emptyList(), Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); + List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); // expecting 1 compile command file List files = CompilerHints.getCompileCommandFiles(command); From 021c818b9febb78aa821d8d878e36f4df833b51b Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 13 Jul 2016 19:31:07 +0300 Subject: [PATCH 009/342] 7901730: jmh-core-ct should cleanup CLASS_OUTPUT before using a new compile session --- .../java/org/openjdk/jmh/ct/CompileTest.java | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java index 447213d0d..814368bdd 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java @@ -32,24 +32,13 @@ import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.Utils; -import javax.tools.Diagnostic; -import javax.tools.DiagnosticCollector; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileObject; -import javax.tools.SimpleJavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.StandardLocation; -import javax.tools.ToolProvider; +import javax.tools.*; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; public class CompileTest { @@ -134,12 +123,7 @@ public static boolean doTestOther(GeneratorSource source, InMemoryGeneratorDesti JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); - - try { - fm.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(new File(System.getProperty("java.io.tmpdir")))); - } catch (IOException e) { - Assert.fail(e.getMessage()); - } + setupClassOutput(fm); Collection sources = new ArrayList(); for (Map.Entry e : destination.getClasses().entrySet()) { @@ -166,12 +150,7 @@ private static boolean doTestAnnprocess(Class klass, InMemoryGeneratorDestina JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); - - try { - fm.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(new File(System.getProperty("java.io.tmpdir")))); - } catch (IOException e) { - Assert.fail(e.getMessage()); - } + setupClassOutput(fm); String name = "/" + klass.getCanonicalName().replaceAll("\\.", "/") + ".java"; String shortName = klass.getName(); @@ -202,6 +181,22 @@ private static boolean doTestAnnprocess(Class klass, InMemoryGeneratorDestina } } + private static void setupClassOutput(StandardJavaFileManager fm) { + try { + File tmp = File.createTempFile("jmh-core-ct", "temp"); + if (!tmp.delete()) { + throw new IOException("Cannot delete temp file: " + tmp); + } + if (!tmp.mkdirs()) { + throw new IOException("Cannot create temp dir: " + tmp); + } + tmp.deleteOnExit(); + fm.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(tmp)); + } catch (IOException e) { + Assert.fail(e.getMessage()); + } + } + public static class JavaSourceFromString extends SimpleJavaFileObject { final String code; From 44d309b1266932572e1e07bcbb7deb19807a5557 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 13 Jul 2016 19:35:00 +0300 Subject: [PATCH 010/342] 7901421: Reconsider the marshalling scheme for BenchmarkListEntry --- .../jmh/runner/AbstractResourceReader.java | 15 +- .../org/openjdk/jmh/runner/BenchmarkList.java | 21 +- .../jmh/runner/BenchmarkListEntry.java | 209 +++++------------- .../org/openjdk/jmh/runner/CompilerHints.java | 2 +- .../java/org/openjdk/jmh/util/Optional.java | 31 --- .../org/openjdk/jmh/util/lines/Constants.java | 39 ++++ .../jmh/util/lines/TestLineReader.java | 190 ++++++++++++++++ .../jmh/util/lines/TestLineWriter.java | 150 +++++++++++++ .../openjdk/jmh/runner/TestBenchmarkList.java | 164 +++++++++++++- .../org/openjdk/jmh/util/TestFileUtils.java | 2 +- .../org/openjdk/jmh/util/TestLineTest.java | 105 +++++++++ .../org/openjdk/jmh/runner/MicroBenchmarks | 46 ---- 12 files changed, 720 insertions(+), 254 deletions(-) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/util/lines/Constants.java create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineWriter.java create mode 100644 jmh-core/src/test/java/org/openjdk/jmh/util/TestLineTest.java delete mode 100644 jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java index fd6825cb7..76daaf2e3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java @@ -24,12 +24,7 @@ */ package org.openjdk.jmh.runner; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; +import java.io.*; import java.net.URL; import java.util.ArrayList; import java.util.Collections; @@ -40,10 +35,12 @@ class AbstractResourceReader { private final String file; private final String resource; + private final String strings; - protected AbstractResourceReader(String file, String resource) { + protected AbstractResourceReader(String file, String resource, String strings) { this.file = file; this.resource = resource; + this.strings = strings; } /** @@ -52,6 +49,10 @@ protected AbstractResourceReader(String file, String resource) { * @return a correct Reader instance */ protected List getReaders() { + if (strings != null) { + return Collections.singletonList(new StringReader(strings)); + } + if (file != null) { try { return Collections.singletonList(new FileReader(file)); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java index d14be7b15..e52490b29 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java @@ -29,12 +29,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.Reader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; +import java.util.*; import java.util.regex.Pattern; /** @@ -49,16 +44,20 @@ public static BenchmarkList defaultList() { return fromResource(BENCHMARK_LIST); } + public static BenchmarkList fromFile(String file) { + return new BenchmarkList(file, null, null); + } + public static BenchmarkList fromResource(String resource) { - return new BenchmarkList(null, resource); + return new BenchmarkList(null, resource, null); } - public static BenchmarkList fromFile(String file) { - return new BenchmarkList(file, null); + public static BenchmarkList fromString(String strings) { + return new BenchmarkList(null, null, strings); } - private BenchmarkList(String file, String resource) { - super(file, resource); + private BenchmarkList(String file, String resource, String strings) { + super(file, resource, strings); } /** diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java index cfe86dc9c..642d3210e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java @@ -27,18 +27,16 @@ import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Optional; -import org.openjdk.jmh.util.Utils; +import org.openjdk.jmh.util.lines.TestLineReader; +import org.openjdk.jmh.util.lines.TestLineWriter; import java.util.Arrays; import java.util.Collection; import java.util.Map; -import java.util.TreeMap; import java.util.concurrent.TimeUnit; public class BenchmarkListEntry implements Comparable { - private static final String BR_SEPARATOR = "===,==="; - private final String userClassQName; private final String generatedClassQName; private final String method; @@ -100,53 +98,67 @@ public BenchmarkListEntry(String userClassQName, String generatedClassQName, Str } public BenchmarkListEntry(String line) { - String[] args = line.split(BR_SEPARATOR); + this.workloadParams = new WorkloadParams(); - if (args.length != 23) { - throw new IllegalStateException("Mismatched format for the line: " + line); - } + TestLineReader reader = new TestLineReader(line); - this.workloadParams = new WorkloadParams(); + if (!reader.isCorrect()) { + throw new IllegalStateException("Unable to parse the line: " + line); + } - int idx = 0; - this.userClassQName = args[idx++].trim(); - this.generatedClassQName = args[idx++].trim(); - this.method = args[idx++].trim(); - this.mode = Mode.deepValueOf(args[idx++].trim()); - this.threads = Optional.of(args[idx++], INTEGER_UNMARSHALLER); - this.threadGroups = Utils.unmarshalIntArray(args[idx++]); - this.threadGroupLabels = Optional.of(args[idx++], STRING_COLLECTION_UNMARSHALLER); - this.warmupIterations = Optional.of(args[idx++], INTEGER_UNMARSHALLER); - this.warmupTime = Optional.of(args[idx++], TIME_VALUE_UNMARSHALLER); - this.warmupBatchSize = Optional.of(args[idx++], INTEGER_UNMARSHALLER); - this.measurementIterations = Optional.of(args[idx++], INTEGER_UNMARSHALLER); - this.measurementTime = Optional.of(args[idx++], TIME_VALUE_UNMARSHALLER); - this.measurementBatchSize = Optional.of(args[idx++], INTEGER_UNMARSHALLER); - this.forks = Optional.of(args[idx++], INTEGER_UNMARSHALLER); - this.warmupForks = Optional.of(args[idx++], INTEGER_UNMARSHALLER); - this.jvm = Optional.of(args[idx++], STRING_UNMARSHALLER); - this.jvmArgs = Optional.of(args[idx++], STRING_COLLECTION_UNMARSHALLER); - this.jvmArgsPrepend = Optional.of(args[idx++], STRING_COLLECTION_UNMARSHALLER); - this.jvmArgsAppend = Optional.of(args[idx++], STRING_COLLECTION_UNMARSHALLER); - this.params = Optional.of(args[idx++], PARAM_COLLECTION_UNMARSHALLER); - this.tu = Optional.of(args[idx++], TIMEUNIT_UNMARSHALLER); - this.opsPerInvocation = Optional.of(args[idx++], INTEGER_UNMARSHALLER); - this.timeout = Optional.of(args[idx++], TIME_VALUE_UNMARSHALLER); + this.userClassQName = reader.nextString(); + this.generatedClassQName = reader.nextString(); + this.method = reader.nextString(); + this.mode = Mode.deepValueOf(reader.nextString()); + this.threads = reader.nextOptionalInt(); + this.threadGroups = reader.nextIntArray(); + this.threadGroupLabels = reader.nextOptionalStringCollection(); + this.warmupIterations = reader.nextOptionalInt(); + this.warmupTime = reader.nextOptionalTimeValue(); + this.warmupBatchSize = reader.nextOptionalInt(); + this.measurementIterations = reader.nextOptionalInt(); + this.measurementTime = reader.nextOptionalTimeValue(); + this.measurementBatchSize = reader.nextOptionalInt(); + this.forks = reader.nextOptionalInt(); + this.warmupForks = reader.nextOptionalInt(); + this.jvm = reader.nextOptionalString(); + this.jvmArgs = reader.nextOptionalStringCollection(); + this.jvmArgsPrepend = reader.nextOptionalStringCollection(); + this.jvmArgsAppend = reader.nextOptionalStringCollection(); + this.params = reader.nextOptionalParamCollection(); + this.tu = reader.nextOptionalTimeUnit(); + this.opsPerInvocation = reader.nextOptionalInt(); + this.timeout = reader.nextOptionalTimeValue(); } public String toLine() { - return userClassQName + BR_SEPARATOR + generatedClassQName + BR_SEPARATOR + method + BR_SEPARATOR + mode + BR_SEPARATOR + - threads + BR_SEPARATOR + Utils.marshalIntArray(threadGroups) + BR_SEPARATOR + threadGroupLabels.toString(STRING_COLLECTION_MARSHALLER) + BR_SEPARATOR + - warmupIterations + BR_SEPARATOR + warmupTime + BR_SEPARATOR + warmupBatchSize + BR_SEPARATOR + - measurementIterations + BR_SEPARATOR + measurementTime + BR_SEPARATOR + measurementBatchSize + BR_SEPARATOR + - forks + BR_SEPARATOR + warmupForks + BR_SEPARATOR + - jvm.toString(STRING_MARSHALLER) + BR_SEPARATOR + - jvmArgs.toString(STRING_COLLECTION_MARSHALLER) + BR_SEPARATOR + - jvmArgsPrepend.toString(STRING_COLLECTION_MARSHALLER) + BR_SEPARATOR + - jvmArgsAppend.toString(STRING_COLLECTION_MARSHALLER) + BR_SEPARATOR + - params.toString(PARAM_COLLECTION_MARSHALLER) + BR_SEPARATOR + tu.toString(TIMEUNIT_MARSHALLER) + BR_SEPARATOR + - opsPerInvocation + BR_SEPARATOR + - timeout; + TestLineWriter writer = new TestLineWriter(); + + writer.putString(userClassQName); + writer.putString(generatedClassQName); + writer.putString(method); + writer.putString(mode.toString()); + writer.putOptionalInt(threads); + writer.putIntArray(threadGroups); + writer.putOptionalStringCollection(threadGroupLabels); + writer.putOptionalInt(warmupIterations); + writer.putOptionalTimeValue(warmupTime); + writer.putOptionalInt(warmupBatchSize); + writer.putOptionalInt(measurementIterations); + writer.putOptionalTimeValue(measurementTime); + writer.putOptionalInt(measurementBatchSize); + writer.putOptionalInt(forks); + writer.putOptionalInt(warmupForks); + writer.putOptionalString(jvm); + writer.putOptionalStringCollection(jvmArgs); + writer.putOptionalStringCollection(jvmArgsPrepend); + writer.putOptionalStringCollection(jvmArgsAppend); + writer.putOptionalParamCollection(params); + writer.putOptionalTimeUnit(tu); + writer.putOptionalInt(opsPerInvocation); + writer.putOptionalTimeValue(timeout); + + return writer.toString(); } public BenchmarkListEntry cloneWith(Mode mode) { @@ -317,111 +329,4 @@ public Optional getTimeout() { return timeout; } - static final Optional.Unmarshaller INTEGER_UNMARSHALLER = new Optional.Unmarshaller() { - @Override - public Integer valueOf(String s) { - return Integer.valueOf(s); - } - }; - - static final Optional.Unmarshaller TIME_VALUE_UNMARSHALLER = new Optional.Unmarshaller() { - @Override - public TimeValue valueOf(String s) { - return TimeValue.fromString(s); - } - }; - - static final Optional.Unmarshaller TIMEUNIT_UNMARSHALLER = new Optional.Unmarshaller() { - @Override - public TimeUnit valueOf(String s) { - return TimeUnit.valueOf(s); - } - }; - - static final Optional.Marshaller TIMEUNIT_MARSHALLER = new Optional.Marshaller() { - @Override - public String valueOf(TimeUnit val) { - return val.toString(); - } - }; - - static final Optional.Unmarshaller STRING_UNMARSHALLER = new Optional.Unmarshaller() { - @Override - public String valueOf(String s) { - return s; - } - }; - - static final Optional.Marshaller STRING_MARSHALLER = new Optional.Marshaller() { - @Override - public String valueOf(String s) { - return s; - } - }; - - static final Optional.Unmarshaller> STRING_COLLECTION_UNMARSHALLER = new Optional.Unmarshaller>() { - @Override - public Collection valueOf(String s) { - return Arrays.asList(s.split("===SEP===")); - } - }; - - static final Optional.Marshaller> STRING_COLLECTION_MARSHALLER = new Optional.Marshaller>() { - @Override - public String valueOf(Collection src) { - StringBuilder sb = new StringBuilder(); - for (String s : src) { - sb.append(s).append("===SEP==="); - } - return sb.toString(); - } - }; - - static final Optional.Unmarshaller> PARAM_COLLECTION_UNMARSHALLER = new Optional.Unmarshaller>() { - @Override - public Map valueOf(String s) { - Map map = new TreeMap(); - String[] pairs = s.split("===PAIR-SEP==="); - for (String pair : pairs) { - String[] kv = pair.split("===SEP-K==="); - if (kv[1].equalsIgnoreCase("===EMPTY===")) { - map.put(kv[0], new String[0]); - } else { - String[] vals = kv[1].split("===SEP-V==="); - for (int c = 0; c < vals.length; c++) { - if (vals[c].equals("===EMPTY-VAL===")) { - vals[c] = ""; - } - } - map.put(kv[0], vals); - } - } - return map; - } - }; - - static final Optional.Marshaller> PARAM_COLLECTION_MARSHALLER = new Optional.Marshaller>() { - @Override - public String valueOf(Map src) { - StringBuilder sb = new StringBuilder(); - for (Map.Entry e : src.entrySet()) { - sb.append(e.getKey()); - sb.append("===SEP-K==="); - if (e.getValue().length == 0) { - sb.append("===EMPTY==="); - } else { - for (String v : e.getValue()) { - if (v.isEmpty()) { - sb.append("===EMPTY-VAL==="); - } else { - sb.append(v); - } - sb.append("===SEP-V==="); - } - } - sb.append("===PAIR-SEP==="); - } - return sb.toString(); - } - }; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java index c279d6f47..242987a2c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java @@ -85,7 +85,7 @@ public static CompilerHints fromFile(String file) { } private CompilerHints(String file, String resource) { - super(file, resource); + super(file, resource, null); hints = Collections.unmodifiableSet(read()); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java index dd87b252e..9a14fbff2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java @@ -73,21 +73,6 @@ public static Optional of(T val) { return new Optional(val); } - /** - * Parse the existing string value into the Option - * @param source source string - * @param unmarshaller unmarshaller lambda parsing the (String -> T) - * @param type - * @return value wrapped in the Option - */ - public static Optional of(String source, Unmarshaller unmarshaller) { - if (source.equals("[]")) { - return Optional.none(); - } else { - return Optional.of(unmarshaller.valueOf(source.substring(1, source.length() - 1))); - } - } - public static Optional eitherOf(T val) { if (val == null) { return Optional.none(); @@ -108,14 +93,6 @@ public String toString() { } } - public String toString(Marshaller m) { - if (val == null) { - return "[]"; - } else { - return "[" + m.valueOf(val) + "]"; - } - } - public T get() { if (val == null) { throw new IllegalStateException("Optional is null"); @@ -140,12 +117,4 @@ public int hashCode() { return val != null ? val.hashCode() : 0; } - public interface Unmarshaller { - T valueOf(String s); - } - - public interface Marshaller { - String valueOf(T val); - } - } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/lines/Constants.java b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/Constants.java new file mode 100644 index 000000000..5f326b561 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/Constants.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.util.lines; + +public class Constants { + + public static final String MAGIC = "JMH "; + + public static final char TAG_EMPTY_OPTIONAL = 'E'; + public static final char TAG_STRING = 'S'; + public static final char TAG_INT = 'I'; + public static final char TAG_TIMEVALUE = 'T'; + public static final char TAG_STRING_COLLECTION = 'L'; + public static final char TAG_INT_ARRAY = 'A'; + public static final char TAG_PARAM_MAP = 'M'; + public static final char TAG_TIMEUNIT = 'U'; +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java new file mode 100644 index 000000000..efca235b1 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.util.lines; + +import org.openjdk.jmh.runner.options.TimeValue; +import org.openjdk.jmh.util.Optional; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import static org.openjdk.jmh.util.lines.Constants.*; + +public class TestLineReader { + + private final String line; + private final boolean correct; + private int cursor; + + public TestLineReader(String line) { + this.line = line; + this.correct = (line.length() > MAGIC.length() && line.startsWith(MAGIC)); + this.cursor = MAGIC.length(); + } + + private int readLen() { + StringBuilder sb = new StringBuilder(); + char c = line.charAt(cursor); + while (Character.isDigit(c)) { + sb.append(c); + cursor++; + c = line.charAt(cursor); + } + cursor++; + return Integer.valueOf(sb.toString()); + } + + private String readString() { + int len = readLen(); + String s = line.substring(cursor, cursor + len); + cursor += len + 1; + return s; + } + + private char readChar() { + char c = line.charAt(cursor); + cursor += 2; + return c; + } + + public String nextString() { + char tag = readChar(); + if (tag == TAG_STRING) { + return readString(); + } else { + throw error("unexpected tag = " + tag); + } + } + + private RuntimeException error(String msg) { + return new IllegalStateException("Error: " + msg + "\n at \"" + line + "\", pos " + cursor); + } + + public boolean isCorrect() { + return correct; + } + + public Optional nextOptionalInt() { + char tag = readChar(); + if (tag == Constants.TAG_EMPTY_OPTIONAL) { + return Optional.none(); + } else if (tag == TAG_INT) { + return Optional.of(Integer.valueOf(readString())); + } else { + throw error("unexpected tag = " + tag); + } + } + + public Optional nextOptionalString() { + char tag = readChar(); + if (tag == Constants.TAG_EMPTY_OPTIONAL) { + return Optional.none(); + } else if (tag == TAG_STRING) { + return Optional.of(readString()); + } else { + throw error("unexpected tag = " + tag); + } + } + + public Optional nextOptionalTimeValue() { + char tag = readChar(); + if (tag == Constants.TAG_EMPTY_OPTIONAL) { + return Optional.none(); + } else if (tag == TAG_TIMEVALUE) { + return Optional.of(TimeValue.fromString(readString())); + } else { + throw error("unexpected tag = " + tag); + } + } + + public Optional nextOptionalTimeUnit() { + char tag = readChar(); + if (tag == Constants.TAG_EMPTY_OPTIONAL) { + return Optional.none(); + } else if (tag == TAG_TIMEUNIT) { + return Optional.of(TimeUnit.valueOf(readString())); + } else { + throw error("unexpected tag = " + tag); + } + } + + public Optional> nextOptionalStringCollection() { + char tag = readChar(); + if (tag == Constants.TAG_EMPTY_OPTIONAL) { + return Optional.none(); + } else if (tag == TAG_STRING_COLLECTION) { + int len = readLen(); + Collection list = new ArrayList(); + for (int c = 0; c < len; c++) { + list.add(readString()); + } + return Optional.of(list); + } else { + throw error("unexpected tag = " + tag); + } + } + + public int[] nextIntArray() { + char tag = readChar(); + if (tag == TAG_INT_ARRAY) { + int len = readLen(); + int[] rs = new int[len]; + for (int c = 0; c < len; c++) { + rs[c] = Integer.valueOf(readString()); + } + return rs; + } else { + throw error("unexpected tag = " + tag); + } + } + + public Optional> nextOptionalParamCollection() { + char tag = readChar(); + if (tag == Constants.TAG_EMPTY_OPTIONAL) { + return Optional.none(); + } else if (tag == TAG_PARAM_MAP) { + Map result = new HashMap(); + + int kvs = readLen(); + for (int kv = 0; kv < kvs; kv++) { + String key = readString(); + + int vlen = readLen(); + String[] values = new String[vlen]; + for (int v = 0; v < vlen; v++) { + values[v] = readString(); + } + + result.put(key, values); + } + return Optional.of(result); + } else { + throw error("unexpected tag = " + tag); + } + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineWriter.java b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineWriter.java new file mode 100644 index 000000000..56b42b064 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineWriter.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.util.lines; + +import org.openjdk.jmh.runner.options.TimeValue; +import org.openjdk.jmh.util.Optional; + +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import static org.openjdk.jmh.util.lines.Constants.*; + +public class TestLineWriter { + + private StringBuilder line; + + public TestLineWriter() { + line = new StringBuilder(); + line.append(MAGIC); + } + + private void appendWithLen(String s) { + appendLen(s.length()); + line.append(s); + line.append(" "); + } + + private void appendLen(int len) { + line.append(len); + line.append(" "); + } + + private void appendTag(char tag) { + line.append(tag); + line.append(" "); + } + + public void putString(String s) { + appendTag(TAG_STRING); + appendWithLen(s); + } + + public void putOptionalInt(Optional opt) { + if (!opt.hasValue()) { + appendTag(TAG_EMPTY_OPTIONAL); + } else { + appendTag(TAG_INT); + appendWithLen(String.valueOf(opt.get())); + } + } + + public void putOptionalString(Optional opt) { + if (!opt.hasValue()) { + appendTag(TAG_EMPTY_OPTIONAL); + } else { + appendTag(TAG_STRING); + appendWithLen(opt.get()); + } + } + + public void putIntArray(int[] arr) { + appendTag(TAG_INT_ARRAY); + appendLen(arr.length); + for (int v : arr) { + appendWithLen(String.valueOf(v)); + } + } + + public void putOptionalStringCollection(Optional> opt) { + if (!opt.hasValue()) { + appendTag(TAG_EMPTY_OPTIONAL); + } else { + appendTag(TAG_STRING_COLLECTION); + Collection coll = opt.get(); + appendLen(coll.size()); + for (String s : coll) { + appendWithLen(s); + } + } + } + + public void putOptionalTimeValue(Optional opt) { + if (!opt.hasValue()) { + appendTag(TAG_EMPTY_OPTIONAL); + } else { + appendTag(TAG_TIMEVALUE); + appendWithLen(opt.get().toString()); + } + } + + public void putOptionalTimeUnit(Optional opt) { + if (!opt.hasValue()) { + appendTag(TAG_EMPTY_OPTIONAL); + } else { + appendTag(TAG_TIMEUNIT); + appendWithLen(opt.get().toString()); + } + } + + public void putOptionalParamCollection(Optional> opt) { + if (!opt.hasValue()) { + appendTag(TAG_EMPTY_OPTIONAL); + } else { + appendTag(TAG_PARAM_MAP); + + Map map = opt.get(); + appendLen(map.size()); + + for (String key : map.keySet()) { + appendWithLen(key); + + String[] vals = map.get(key); + appendLen(vals.length); + + for (String value : vals) { + appendWithLen(value); + } + } + } + } + + @Override + public String toString() { + return line.toString(); + } + +} diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java index bbf82046e..0d7e68d1a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java @@ -26,14 +26,15 @@ import org.junit.BeforeClass; import org.junit.Test; +import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.runner.format.OutputFormat; import org.openjdk.jmh.runner.format.OutputFormatFactory; +import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; +import org.openjdk.jmh.util.Optional; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Set; +import java.util.*; +import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -46,9 +47,162 @@ public class TestBenchmarkList { private static BenchmarkList list; private static OutputFormat out; + private static void stub(StringBuilder sb, String userClassQName, String generatedClassQName, String method, Mode mode) { + BenchmarkListEntry br = new BenchmarkListEntry( + userClassQName, + generatedClassQName, + method, + mode, + Optional.none(), + new int[]{1}, + Optional.>none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.>none(), + Optional.>none(), + Optional.>none(), + Optional.>none(), + Optional.none(), + Optional.none(), + Optional.none() + ); + + sb.append(br.toLine()); + sb.append(String.format("%n")); + } + @BeforeClass public static void setUpClass() throws Exception { - list = BenchmarkList.fromResource("/org/openjdk/jmh/runner/MicroBenchmarks"); + StringBuilder sb = new StringBuilder(); + + stub(sb, + "oracle.micro.benchmarks.api.java.util.concurrent.NormalMaps", + "oracle.micro.benchmarks.api.java.util.concurrent.generated.NormalMaps", + "testConcurrentHashMap", + Mode.AverageTime); + + stub(sb, + "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", + "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", + "jbb2005HashMapGetIntThroughput", + Mode.AverageTime); + + stub(sb, + "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", + "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", + "jbb2005HashMapGetIntGCThroughput", + Mode.AverageTime); + + stub(sb, + "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", + "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", + "jbb2005HashMapGetIntegerThroughput", + Mode.AverageTime); + + stub(sb, + "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", + "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", + "jbb2005ResizedHashMapGetIntThroughput", + Mode.AverageTime); + + stub(sb, + "oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap", + "oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap", + "jbb2005ResizedHashMapGetIntegerThroughput", + Mode.AverageTime); + + stub(sb, + "oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64", + "oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64", + "printBase64Binary_128bytesThroughput", + Mode.AverageTime); + + stub(sb, + "oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64", + "oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64", + "printBase64Binary_32bytesThroughput", + Mode.AverageTime); + + stub(sb, + "oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64", + "oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64", + "printBase64Binary_512bytesThroughput", + Mode.AverageTime); + + stub(sb, + "oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps", + "oracle.micro.benchmarks.api.java.util.concurrent.generated.GeneratedMaps", + "testConcurrentHashMap", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestMicro", + "org.openjdk.jmh.runner.generated.TestMicro", + "dummy", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestMicro", + "org.openjdk.jmh.runner.generated.TestMicro", + "dummyWarmThroughput", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestMicro", + "org.openjdk.jmh.runner.generated.TestMicro", + "dummyWarmOnlyThroughput", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestMicro", + "org.openjdk.jmh.runner.generated.TestMicro", + "dummySetupPayloadThroughput", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestMicro", + "org.openjdk.jmh.runner.generated.TestMicro", + "boom_ExceptionThroughput", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestMicro", + "org.openjdk.jmh.runner.generated.TestMicro", + "boom_ErrorThroughput", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestMicro", + "org.openjdk.jmh.runner.generated.TestMicro", + "boom_ThrowableThroughput", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestMicro", + "org.openjdk.jmh.runner.generated.TestMicro", + "blackholedThroughput", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestBrokenMicro", + "org.openjdk.jmh.runner.generated.TestBrokenMicro", + "dummyPayloadThroughput", + Mode.AverageTime); + + stub(sb, + "org.openjdk.jmh.runner.TestExceptionThrowingMicro", + "org.openjdk.jmh.runner.generated.TestExceptionThrowingMicro", + "ouchThroughput", + Mode.AverageTime); + + list = BenchmarkList.fromString(sb.toString()); out = OutputFormatFactory.createFormatInstance(System.out, VerboseMode.NORMAL); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestFileUtils.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestFileUtils.java index 066143ebf..26d4b8b2a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestFileUtils.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestFileUtils.java @@ -37,7 +37,7 @@ public class TestFileUtils { @Test public void testExtractFromResource() throws Exception { - File test = FileUtils.extractFromResource("/org/openjdk/jmh/runner/MicroBenchmarks"); + File test = FileUtils.extractFromResource("/org/openjdk/jmh/results/format/output-golden.json"); test.deleteOnExit(); assertTrue(test.exists()); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestLineTest.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestLineTest.java new file mode 100644 index 000000000..7949b4b8b --- /dev/null +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestLineTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.util; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.runner.options.TimeValue; +import org.openjdk.jmh.util.lines.TestLineReader; +import org.openjdk.jmh.util.lines.TestLineWriter; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public class TestLineTest { + + @Test + public void test() { + TestLineWriter writer = new TestLineWriter(); + + writer.putString("jmh"); + writer.putString("test"); + writer.putOptionalString(Optional.eitherOf("full-optional")); + writer.putOptionalString(Optional.none()); + + writer.putOptionalInt(Optional.eitherOf(42)); + writer.putOptionalInt(Optional.none()); + + writer.putIntArray(new int[] {5, 3, 2}); + + writer.putOptionalTimeValue(Optional.eitherOf(TimeValue.milliseconds(14))); + writer.putOptionalTimeValue(Optional.none()); + + writer.putOptionalTimeUnit(Optional.eitherOf(TimeUnit.HOURS)); + writer.putOptionalTimeUnit(Optional.none()); + + writer.putOptionalStringCollection(Optional.>eitherOf(Arrays.asList("foo", "bar", "baz"))); + writer.putOptionalStringCollection(Optional.>none()); + + HashMap expectedMap = new HashMap(); + expectedMap.put("key1", new String[] {"val1", "val2"}); + expectedMap.put("key2", new String[] {"val3", "val4"}); + writer.putOptionalParamCollection(Optional.>eitherOf(expectedMap)); + writer.putOptionalParamCollection(Optional.>none()); + + String s = writer.toString(); + + TestLineReader reader = new TestLineReader(s); + + Assert.assertEquals("jmh", reader.nextString()); + Assert.assertEquals("test", reader.nextString()); + + Assert.assertEquals("full-optional", reader.nextOptionalString().get()); + Assert.assertEquals(false, reader.nextOptionalString().hasValue()); + + Assert.assertEquals(42, (int)reader.nextOptionalInt().get()); + Assert.assertEquals(false, reader.nextOptionalInt().hasValue()); + + Assert.assertTrue(Arrays.equals(new int[] {5, 3, 2}, reader.nextIntArray())); + + Assert.assertEquals(TimeValue.milliseconds(14), reader.nextOptionalTimeValue().get()); + Assert.assertEquals(false, reader.nextOptionalTimeValue().hasValue()); + + Assert.assertEquals(TimeUnit.HOURS, reader.nextOptionalTimeUnit().get()); + Assert.assertEquals(false, reader.nextOptionalTimeUnit().hasValue()); + + Assert.assertEquals(Arrays.asList("foo", "bar", "baz"), reader.nextOptionalStringCollection().get()); + Assert.assertEquals(false, reader.nextOptionalStringCollection().hasValue()); + + Map actualMap = reader.nextOptionalParamCollection().get(); + Assert.assertEquals(expectedMap.size(), actualMap.size()); + Assert.assertEquals(expectedMap.keySet(), actualMap.keySet()); + + for (String key : expectedMap.keySet()) { + String[] expectedVals = expectedMap.get(key); + String[] actualVals = actualMap.get(key); + Assert.assertTrue(Arrays.equals(expectedVals, actualVals)); + } + } + +} diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks b/jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks deleted file mode 100644 index f4040293c..000000000 --- a/jmh-core/src/test/resources/org/openjdk/jmh/runner/MicroBenchmarks +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - - -oracle.micro.benchmarks.api.java.util.concurrent.NormalMaps===,===oracle.micro.benchmarks.api.java.util.concurrent.generated.NormalMaps===,===testConcurrentHashMap===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005HashMapGetIntThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005HashMapGetIntGCThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005HashMapGetIntegerThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005ResizedHashMapGetIntThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.jbb05.GeneratedSPECjbb2005HashMap===,===oracle.micro.benchmarks.app.jbb05.generated.GeneratedSPECjbb2005HashMap===,===jbb2005ResizedHashMapGetIntegerThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64===,===printBase64Binary_128bytesThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64===,===printBase64Binary_32bytesThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.app.sjent.GeneratedPrintBase64===,===oracle.micro.benchmarks.app.sjent.generated.GeneratedPrintBase64===,===printBase64Binary_512bytesThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps===,===oracle.micro.benchmarks.api.java.util.concurrent.generated.GeneratedMaps===,===testConcurrentHashMap===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] - -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummy===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummyWarmThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummyWarmOnlyThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===dummySetupPayloadThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===boom_ExceptionThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===boom_ErrorThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===boom_ThrowableThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestMicro===,===org.openjdk.jmh.runner.generated.TestMicro===,===blackholedThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestBrokenMicro===,===org.openjdk.jmh.runner.generated.TestBrokenMicro===,===dummyPayloadThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] -org.openjdk.jmh.runner.TestExceptionThrowingMicro===,===org.openjdk.jmh.runner.generated.TestExceptionThrowingMicro===,===ouchThroughput===,===AverageTime===,===[4]===,===1====,===[]===,===[5]===,===[1 s]===,===[]===,===[5]===,===[4 s]===,===[]===,===[1]===,===[]===,===[]===,===[]===,===[]===,===[]===,===[prefixLen===SEP-K===0===SEP-V===10===SEP-V===100===SEP-V======PAIR-SEP===]===,===[NANOSECONDS]===,===[]===,===[10 min] From 96b2168e54b9665e9ab46b88919d2894f6d11dcf Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 19 Jul 2016 21:57:50 +0300 Subject: [PATCH 011/342] 7901735: JMH infrastructure classes (Blackhole, *Params, Control) should be treated specially --- .../it/infraparams/BenchmarkParamsTest.java | 80 +++++++ .../it/infraparams/IterationParamsTest.java | 80 +++++++ .../jmh/it/infraparams/ThreadParamsTest.java | 77 +++++++ .../generators/core/BenchmarkGenerator.java | 129 ++++++----- .../generators/core/StateObjectHandler.java | 201 ++++++++---------- .../openjdk/jmh/infra/BenchmarkParams.java | 33 --- .../java/org/openjdk/jmh/infra/Blackhole.java | 35 +-- .../java/org/openjdk/jmh/infra/Control.java | 13 +- .../openjdk/jmh/infra/IterationParams.java | 24 +-- .../org/openjdk/jmh/infra/ThreadParams.java | 31 +-- .../java/org/openjdk/jmh/BlackholeTest.java | 8 +- 11 files changed, 420 insertions(+), 291 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/BenchmarkParamsTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/IterationParamsTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/ThreadParamsTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/BenchmarkParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/BenchmarkParamsTest.java new file mode 100644 index 000000000..3b9d8e4e6 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/BenchmarkParamsTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.infraparams; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.BenchmarkParams; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.CommandLineOptionException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.TimeValue; + +import java.util.Collection; +import java.util.Collections; +import java.util.IdentityHashMap; + +@State(Scope.Thread) +public class BenchmarkParamsTest { + + Collection set; + + @Setup(Level.Iteration) + public void setup() { + set = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap())); + } + + @TearDown(Level.Iteration) + public void verify() { + Assert.assertEquals(1, set.size()); + } + + @Benchmark + @Threads(4) + public void test(BenchmarkParams params) { + set.add(params); + Fixtures.work(); + } + + @Test + public void test() throws RunnerException, CommandLineOptionException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .warmupIterations(5) + .warmupTime(TimeValue.seconds(1)) + .measurementIterations(5) + .measurementTime(TimeValue.seconds(1)) + .forks(1) + .shouldFailOnError(true) + .build(); + + new Runner(opts).run(); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/IterationParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/IterationParamsTest.java new file mode 100644 index 000000000..b1b758a04 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/IterationParamsTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.infraparams; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.IterationParams; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.CommandLineOptionException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.TimeValue; + +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Set; + +@State(Scope.Benchmark) +public class IterationParamsTest { + + Set set; + + @Setup(Level.Iteration) + public void setup() { + set = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap())); + } + + @TearDown(Level.Iteration) + public void verify() { + Assert.assertEquals(1, set.size()); + } + + @Benchmark + @Threads(4) + public void test(IterationParams params) { + set.add(params); + Fixtures.work(); + } + + @Test + public void test() throws RunnerException, CommandLineOptionException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .warmupIterations(5) + .warmupTime(TimeValue.seconds(1)) + .measurementIterations(5) + .measurementTime(TimeValue.seconds(1)) + .forks(1) + .shouldFailOnError(true) + .build(); + + new Runner(opts).run(); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/ThreadParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/ThreadParamsTest.java new file mode 100644 index 000000000..0da9bdaea --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/ThreadParamsTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.infraparams; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.ThreadParams; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.*; + +import java.util.Collection; +import java.util.Collections; +import java.util.IdentityHashMap; + +@State(Scope.Benchmark) +public class ThreadParamsTest { + + Collection set; + + @Setup(Level.Iteration) + public void setup() { + set = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap())); + } + + @TearDown(Level.Iteration) + public void verify() { + Assert.assertEquals(4, set.size()); + } + + @Benchmark + @Threads(4) + public void test(ThreadParams params) { + set.add(params); + Fixtures.work(); + } + + @Test + public void test() throws RunnerException, CommandLineOptionException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .warmupIterations(5) + .warmupTime(TimeValue.seconds(1)) + .measurementIterations(5) + .measurementTime(TimeValue.seconds(1)) + .forks(1) + .shouldFailOnError(true) + .build(); + + new Runner(opts).run(); + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 6d87ef4c2..9ba2caaa2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -25,10 +25,7 @@ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.infra.BenchmarkParams; -import org.openjdk.jmh.infra.Blackhole; -import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.infra.ThreadParams; +import org.openjdk.jmh.infra.*; import org.openjdk.jmh.results.*; import org.openjdk.jmh.runner.BenchmarkList; import org.openjdk.jmh.runner.BenchmarkListEntry; @@ -467,9 +464,6 @@ private void generateClass(GeneratorSource source, GeneratorDestination destinat // benchmark instance is implicit states.bindImplicit(classInfo, "bench", Scope.Thread); - // default blackhole is implicit - states.bindImplicit(source.resolveClass(Blackhole.class.getCanonicalName()), "blackhole", Scope.Thread); - // bind all methods states.bindMethodGroup(info.methodGroup); @@ -491,6 +485,11 @@ private void generateClass(GeneratorSource source, GeneratorDestination destinat Paddings.padding(writer); writer.println(ident(1) + "int startRndMask;"); + writer.println(ident(1) + "BenchmarkParams benchmarkParams;"); + writer.println(ident(1) + "IterationParams iterationParams;"); + writer.println(ident(1) + "ThreadParams threadParams;"); + writer.println(ident(1) + "Blackhole blackhole;"); + writer.println(ident(1) + "Control notifyControl;"); // write all methods for (Mode benchmarkKind : Mode.values()) { @@ -531,7 +530,8 @@ private void generateImport(PrintWriter writer) { SampleTimeResult.class, SingleShotResult.class, SampleBuffer.class, Mode.class, Fork.class, Measurement.class, Threads.class, Warmup.class, BenchmarkMode.class, RawResults.class, ResultRole.class, - Field.class, BenchmarkParams.class, IterationParams.class + Field.class, BenchmarkParams.class, IterationParams.class, + Blackhole.class, Control.class }; for (Class c : imports) { @@ -594,18 +594,14 @@ private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode be writer.println(); // control objects get a special treatment - for (StateObject so : states.getControls()) { - writer.println(ident(3) + so.localIdentifier + ".startMeasurement = true;"); - } + writer.println(ident(3) + "notifyControl.startMeasurement = true;"); // measurement loop call writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + - "(control, res" + prefix(states.getArgList(method)) + ");"); + "(" + getStubArgs() + prefix(states.getArgList(method)) + ");"); // control objects get a special treatment - for (StateObject so : states.getControls()) { - writer.println(ident(3) + so.localIdentifier + ".stopMeasurement = true;"); - } + writer.println(ident(3) + "notifyControl.stopMeasurement = true;"); // synchronize iterations epilog: announce ready writer.println(ident(3) + "control.announceWarmdownReady();"); @@ -641,8 +637,8 @@ private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode be It's prudent to make the multiplication first to get more accuracy. */ - writer.println(ident(3) + "int batchSize = control.iterationParams.getBatchSize();"); - writer.println(ident(3) + "int opsPerInv = control.benchmarkParams.getOpsPerInvocation();"); + writer.println(ident(3) + "int batchSize = iterationParams.getBatchSize();"); + writer.println(ident(3) + "int opsPerInv = benchmarkParams.getOpsPerInvocation();"); writer.println(ident(3) + "res.allOps *= opsPerInv;"); writer.println(ident(3) + "res.allOps /= batchSize;"); @@ -650,13 +646,16 @@ private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode be writer.println(ident(3) + "res.measuredOps /= batchSize;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);"); - writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); if (!isSingleMethod) { - writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } for (String ops : states.getAuxResultNames(method)) { - writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.SECONDARY, \"" + ops + "\", " + states.getAuxResultAccessor(method, ops) + ", res.getTime(), control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.SECONDARY, \"" + ops + "\", " + states.getAuxResultAccessor(method, ops) + ", res.getTime(), benchmarkParams.getTimeUnit()));"); } + + methodEpilog(writer, methodGroup); + writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); } @@ -671,7 +670,8 @@ private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode be compilerControl.defaultForceInline(method); - writer.println(ident(1) + "public" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + "(InfraControl control, RawResults result" + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); + writer.println(ident(1) + "public static" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + "(" + + getStubTypeArgs() + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); writer.println(ident(2) + "long operations = 0;"); writer.println(ident(2) + "long realTime = 0;"); writer.println(ident(2) + "result.startTime = System.nanoTime();"); @@ -722,17 +722,13 @@ private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode b writer.println(); // control objects get a special treatment - for (StateObject so : states.getControls()) { - writer.println(ident(3) + so.localIdentifier + ".startMeasurement = true;"); - } + writer.println(ident(3) + "notifyControl.startMeasurement = true;"); // measurement loop call - writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(control, res" + prefix(states.getArgList(method)) + ");"); + writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(" + getStubArgs() + prefix(states.getArgList(method)) + ");"); // control objects get a special treatment - for (StateObject so : states.getControls()) { - writer.println(ident(3) + so.localIdentifier + ".stopMeasurement = true;"); - } + writer.println(ident(3) + "notifyControl.stopMeasurement = true;"); // synchronize iterations epilog: announce ready writer.println(ident(3) + "control.announceWarmdownReady();"); @@ -767,8 +763,8 @@ private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode b It's prudent to make the multiplication first to get more accuracy. */ - writer.println(ident(3) + "int batchSize = control.iterationParams.getBatchSize();"); - writer.println(ident(3) + "int opsPerInv = control.benchmarkParams.getOpsPerInvocation();"); + writer.println(ident(3) + "int batchSize = iterationParams.getBatchSize();"); + writer.println(ident(3) + "int opsPerInv = benchmarkParams.getOpsPerInvocation();"); writer.println(ident(3) + "res.allOps *= opsPerInv;"); writer.println(ident(3) + "res.allOps /= batchSize;"); @@ -776,13 +772,15 @@ private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode b writer.println(ident(3) + "res.measuredOps /= batchSize;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);"); - writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); if (!isSingleMethod) { - writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } for (String ops : states.getAuxResultNames(method)) { - writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.SECONDARY, \"" + ops + "\", " + states.getAuxResultAccessor(method, ops) + ", res.getTime(), control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.SECONDARY, \"" + ops + "\", " + states.getAuxResultAccessor(method, ops) + ", res.getTime(), benchmarkParams.getTimeUnit()));"); } + methodEpilog(writer, methodGroup); + writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); } @@ -796,8 +794,8 @@ private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode b String methodName = method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX; compilerControl.defaultForceInline(method); - writer.println(ident(1) + "public" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + - "(InfraControl control, RawResults result" + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); + writer.println(ident(1) + "public static" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + + "(" + getStubTypeArgs() + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); writer.println(ident(2) + "long operations = 0;"); writer.println(ident(2) + "long realTime = 0;"); writer.println(ident(2) + "result.startTime = System.nanoTime();"); @@ -817,8 +815,27 @@ private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode b } } + private String getStubArgs() { + return "control, res, benchmarkParams, iterationParams, threadParams, blackhole, notifyControl, startRndMask"; + } + + private String getStubTypeArgs() { + return "InfraControl control, RawResults result, " + + "BenchmarkParams benchmarkParams, IterationParams iterationParams, ThreadParams threadParams, " + + "Blackhole blackhole, Control notifyControl, int startRndMask"; + } + private void methodProlog(PrintWriter writer, MethodGroup methodGroup) { // do nothing + writer.println(ident(2) + "this.benchmarkParams = control.benchmarkParams;"); + writer.println(ident(2) + "this.iterationParams = control.iterationParams;"); + writer.println(ident(2) + "this.threadParams = threadParams;"); + writer.println(ident(2) + "this.notifyControl = new Control();"); + writer.println(ident(2) + "this.blackhole = new Blackhole(\"Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.\");"); + } + + private void methodEpilog(PrintWriter writer, MethodGroup methodGroup) { + writer.println(ident(3) + "this.blackhole = null;"); } private String prefix(String argList) { @@ -860,21 +877,18 @@ private void generateSampleTime(ClassInfo classInfo, PrintWriter writer, Mode be writer.println(); // control objects get a special treatment - for (StateObject so : states.getControls()) { - writer.println(ident(3) + so.localIdentifier + ".startMeasurement = true;"); - } + writer.println(ident(3) + "notifyControl.startMeasurement = true;"); // measurement loop call writer.println(ident(3) + "int targetSamples = (int) (control.getDuration(TimeUnit.MILLISECONDS) * 20); // at max, 20 timestamps per millisecond"); - writer.println(ident(3) + "int batchSize = control.iterationParams.getBatchSize();"); - writer.println(ident(3) + "int opsPerInv = control.benchmarkParams.getOpsPerInvocation();"); + writer.println(ident(3) + "int batchSize = iterationParams.getBatchSize();"); + writer.println(ident(3) + "int opsPerInv = benchmarkParams.getOpsPerInvocation();"); writer.println(ident(3) + "SampleBuffer buffer = new SampleBuffer();"); - writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(control, res, buffer, targetSamples, opsPerInv, batchSize" + prefix(states.getArgList(method)) + ");"); + writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(" + + getStubArgs() + ", buffer, targetSamples, opsPerInv, batchSize" + prefix(states.getArgList(method)) + ");"); // control objects get a special treatment - for (StateObject so : states.getControls()) { - writer.println(ident(3) + so.localIdentifier + ".stopMeasurement = true;"); - } + writer.println(ident(3) + "notifyControl.stopMeasurement = true;"); // synchronize iterations epilog: announce ready writer.println(ident(3) + "control.announceWarmdownReady();"); @@ -912,10 +926,12 @@ private void generateSampleTime(ClassInfo classInfo, PrintWriter writer, Mode be writer.println(ident(3) + "res.measuredOps *= opsPerInv;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);"); - writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", buffer, control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); if (!isSingleMethod) { - writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", buffer, control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); } + methodEpilog(writer, methodGroup); + writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); } @@ -929,7 +945,9 @@ private void generateSampleTime(ClassInfo classInfo, PrintWriter writer, Mode be String methodName = method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX; compilerControl.defaultForceInline(method); - writer.println(ident(1) + "public" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + "(InfraControl control, RawResults result, SampleBuffer buffer, int targetSamples, long opsPerInv, int batchSize" + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); + writer.println(ident(1) + "public static" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + "(" + + getStubTypeArgs() + ", SampleBuffer buffer, int targetSamples, long opsPerInv, int batchSize" + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); + writer.println(ident(2) + "long realTime = 0;"); writer.println(ident(2) + "long operations = 0;"); writer.println(ident(2) + "int rnd = (int)System.nanoTime();"); @@ -991,8 +1009,9 @@ private void generateSingleShotTime(ClassInfo classInfo, PrintWriter writer, Mod // measurement loop call writer.println(ident(3) + "RawResults res = new RawResults();"); - writer.println(ident(3) + "int batchSize = control.iterationParams.getBatchSize();"); - writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(control, batchSize, res" + prefix(states.getArgList(method)) + ");"); + writer.println(ident(3) + "int batchSize = iterationParams.getBatchSize();"); + writer.println(ident(3) + method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX + "(" + + getStubArgs() + ", batchSize" + prefix(states.getArgList(method)) + ");"); writer.println(ident(3) + "control.preTearDown();"); @@ -1009,10 +1028,12 @@ private void generateSingleShotTime(ClassInfo classInfo, PrintWriter writer, Mod writer.println(ident(3) + "long totalOps = opsPerInv;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);"); - writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getTime(), control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); if (!isSingleMethod) { - writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.getTime(), control.benchmarkParams.getTimeUnit()));"); + writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); } + methodEpilog(writer, methodGroup); + writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); } @@ -1026,8 +1047,8 @@ private void generateSingleShotTime(ClassInfo classInfo, PrintWriter writer, Mod String methodName = method.getName() + "_" + benchmarkKind.shortLabel() + JMH_STUB_SUFFIX; compilerControl.defaultForceInline(method); - writer.println(ident(1) + "public" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + - "(InfraControl control, int batchSize, RawResults result" + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); + writer.println(ident(1) + "public static" + (methodGroup.isStrictFP() ? " strictfp" : "") + " void " + methodName + + "(" + getStubTypeArgs() + ", int batchSize" + prefix(states.getTypeArgList(method)) + ") throws Throwable {"); writer.println(ident(2) + "long realTime = 0;"); writer.println(ident(2) + "result.startTime = System.nanoTime();"); @@ -1090,7 +1111,7 @@ private String emitCall(MethodInfo method, StateObjectHandler states) { if ("void".equalsIgnoreCase(method.getReturnType())) { return states.getImplicit("bench").localIdentifier + "." + method.getName() + "(" + states.getBenchmarkArgList(method) + ")"; } else { - return states.getImplicit("blackhole").localIdentifier + ".consume(" + states.getImplicit("bench").localIdentifier + "." + method.getName() + "(" + states.getBenchmarkArgList(method) + "))"; + return "blackhole.consume(" + states.getImplicit("bench").localIdentifier + "." + method.getName() + "(" + states.getBenchmarkArgList(method) + "))"; } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 9b7647975..e0e05ec37 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -25,12 +25,10 @@ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.infra.BenchmarkParams; -import org.openjdk.jmh.infra.Control; -import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.infra.ThreadParams; +import org.openjdk.jmh.infra.*; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; +import org.openjdk.jmh.util.Utils; import java.io.IOException; import java.io.PrintWriter; @@ -45,21 +43,27 @@ class StateObjectHandler { private final Identifiers identifiers; - private final Multimap args; - private final Multimap stateHelperArgs; - private final Multimap stateObjectDeps; - private final Map implicits; + private final Multimap roots; + private final Multimap specials; + private final Set stateObjects; + private final Map implicits; + private final Multimap stateObjectDeps; + + private final Multimap benchmarkArgs; + private final Multimap stateHelperArgs; private final Multimap auxNames = new HashMultimap(); private final Map auxAccessors = new HashMap(); public StateObjectHandler(CompilerControlPlugin compileControl) { this.compileControl = compileControl; - this.args = new HashMultimap(); + this.roots = new HashMultimap(); + this.benchmarkArgs = new HashMultimap(); this.implicits = new HashMap(); + this.specials = new HashMultimap(); this.stateObjects = new HashSet(); - this.stateHelperArgs = new HashMultimap(); + this.stateHelperArgs = new HashMultimap(); this.stateObjectDeps = new HashMultimap(); this.identifiers = new Identifiers(); } @@ -129,27 +133,43 @@ public static void validateState(ClassInfo state) { // check @Setup/@TearDown have only @State arguments for (MethodInfo mi : BenchmarkGeneratorUtils.getAllMethods(state)) { if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) { - for (ParameterInfo var : mi.getParameters()) { - if (BenchmarkGeneratorUtils.getAnnSuper(var.getType(), State.class) == null) { - throw new GenerationException( - "Method parameters should be @" + State.class.getSimpleName() + " classes.", - mi); - } - } + validateStateArgs(mi); } } } public static void validateStateArgs(MethodInfo e) { for (ParameterInfo var : e.getParameters()) { - if (BenchmarkGeneratorUtils.getAnnSuper(var.getType(), State.class) == null) { - throw new GenerationException( - "Method parameters should be @" + State.class.getSimpleName() + " classes.", + if (BenchmarkGeneratorUtils.getAnnSuper(var.getType(), State.class) != null) continue; + if (isSpecialClass(var.getType())) continue; + + throw new GenerationException( + "Method parameters should be either @" + State.class.getSimpleName() + " classes", // TODO: Change the message e); - } } } + private static boolean isSpecialClass(ClassInfo ci) { + String name = ci.getQualifiedName(); + return + name.equals(BenchmarkParams.class.getCanonicalName()) || + name.equals(IterationParams.class.getCanonicalName()) || + name.equals(ThreadParams.class.getCanonicalName()) || + name.equals(Blackhole.class.getCanonicalName()) || + name.equals(Control.class.getCanonicalName()) + ; + } + + private String getSpecialClassAccessor(ClassInfo pci) { + String name = pci.getQualifiedName(); + if (name.equals(BenchmarkParams.class.getCanonicalName())) return "benchmarkParams"; + if (name.equals(IterationParams.class.getCanonicalName())) return "iterationParams"; + if (name.equals(ThreadParams.class.getCanonicalName())) return "threadParams"; + if (name.equals(Blackhole.class.getCanonicalName())) return "blackhole"; + if (name.equals(Control.class.getCanonicalName())) return "notifyControl"; + throw new GenerationException("Internal error, unhandled special class: " + pci, pci); + } + public State getState(ClassInfo ci, ParameterInfo pi) { State ann = BenchmarkGeneratorUtils.getAnnSuper(ci, State.class); if (ann == null) { @@ -168,14 +188,20 @@ public void bindMethodGroup(MethodGroup mg) { for (ParameterInfo ppi : method.getParameters()) { ClassInfo pci = ppi.getType(); - StateObject pso = new StateObject(identifiers, pci, getState(pci, ppi).value()); - stateObjects.add(pso); - args.put(method.getName(), pso); - bindState(method, pso, pci); + if (isSpecialClass(pci)) { + benchmarkArgs.put(method.getName(), getSpecialClassAccessor(pci)); + specials.put(method.getName(), pci); + } else { + StateObject pso = new StateObject(identifiers, pci, getState(pci, ppi).value()); + stateObjects.add(pso); + roots.put(method.getName(), pso); + benchmarkArgs.put(method.getName(), pso.toLocal()); + bindState(method, pso, pci); - seen.add(pso); + seen.add(pso); - recursiveStateResolve(method, pci, pso, seen); + recursiveStateResolve(method, pci, pso, seen); + } } } } @@ -190,24 +216,30 @@ private void recursiveStateResolve(MethodInfo method, ClassInfo pci, StateObject for (ParameterInfo pi : mi.getParameters()) { ClassInfo ci = pi.getType(); - StateObject so = new StateObject(identifiers, ci, getState(ci, pi).value()); + if (isSpecialClass(ci)) { + stateHelperArgs.put(mi.getQualifiedName(), getSpecialClassAccessor(ci)); + specials.put(mi.getQualifiedName(), ci); + } else { + StateObject so = new StateObject(identifiers, ci, getState(ci, pi).value()); - if (!seen.add(so)) { - throw new GenerationException("@" + State.class.getSimpleName() + " dependency cycle is detected.", pi); - } + if (!seen.add(so)) { + throw new GenerationException("@" + State.class.getSimpleName() + " dependency cycle is detected.", pi); + } - if (!stateHelperArgs.get(mi.getQualifiedName()).contains(so)) { - stateObjects.add(so); - stateObjectDeps.put(pso, so); - stateHelperArgs.put(mi.getQualifiedName(), so); - bindState(method, so, ci); - recursiveStateResolve(method, ci, so, seen); + if (!stateHelperArgs.get(mi.getQualifiedName()).contains(so.toLocal())) { + stateObjects.add(so); + stateObjectDeps.put(pso, so); + stateHelperArgs.put(mi.getQualifiedName(), so.toLocal()); + bindState(method, so, ci); + recursiveStateResolve(method, ci, so, seen); + } } } } } } + public void bindImplicit(ClassInfo ci, String label, Scope scope) { State ann = BenchmarkGeneratorUtils.getAnnSuper(ci, State.class); StateObject so = new StateObject(identifiers, ci, (ann != null) ? ann.value() : scope); @@ -438,7 +470,7 @@ private void checkHelpers(MethodInfo mi, Class annClass) { } public String getBenchmarkArgList(MethodInfo methodInfo) { - return getArgList(args.get(methodInfo.getName())); + return Utils.join(benchmarkArgs.get(methodInfo.getName()), ", "); } public String getArgList(MethodInfo methodInfo) { @@ -517,8 +549,8 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H if (type == HelperType.SETUP) { for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) { - Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); - result.add(so.localIdentifier + "." + mi.method.getName() + "(" + getArgList(args) + ");"); + Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); + result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } } @@ -530,8 +562,8 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H if (type == HelperType.TEARDOWN) { for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) { - Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); - result.add(so.localIdentifier + "." + mi.method.getName() + "(" + getArgList(args) + ");"); + Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); + result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } } @@ -547,8 +579,8 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H result.add(" if (!" + so.localIdentifier + ".ready" + helperLevel + ") {"); for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) { - Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); - result.add(" " + so.localIdentifier + "." + mi.method.getName() + "(" + getArgList(args) + ");"); + Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); + result.add(" " + so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } result.add(" " + so.localIdentifier + ".ready" + helperLevel + " = true;"); @@ -573,8 +605,8 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H result.add(" if (" + so.localIdentifier + ".ready" + helperLevel + ") {"); for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) { - Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); - result.add(" " + so.localIdentifier + "." + mi.method.getName() + "(" + getArgList(args) + ");"); + Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); + result.add(" " + so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } result.add(" " + so.localIdentifier + ".ready" + helperLevel + " = false;"); @@ -646,7 +678,7 @@ public List getStateInitializers() { result.add(""); result.add("static volatile " + so.type + " " + so.fieldIdentifier + ";"); result.add(""); - result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control, ThreadParams threadParams" + soDependency_TypeArgs(so) + ") throws Throwable {"); + result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control" + soDependency_TypeArgs(so) + ") throws Throwable {"); result.add(" " + so.type + " val = " + so.fieldIdentifier + ";"); result.add(" if (val != null) {"); result.add(" return val;"); @@ -670,8 +702,8 @@ public List getStateInitializers() { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel != Level.Trial) continue; if (hmi.type != HelperType.SETUP) continue; - Collection args = stateHelperArgs.get(hmi.method.getQualifiedName()); - result.add(" val." + hmi.method.getName() + "(" + getArgList(args) + ");"); + Collection args = stateHelperArgs.get(hmi.method.getQualifiedName()); + result.add(" val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");"); } result.add(" val.ready" + Level.Trial + " = true;"); result.add(" " + so.fieldIdentifier + " = val;"); @@ -686,25 +718,7 @@ public List getStateInitializers() { result.add(""); result.add(so.type + " " + so.fieldIdentifier + ";"); result.add(""); - result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control, ThreadParams threadParams" + soDependency_TypeArgs(so) + ") throws Throwable {"); - - // These special classes are copying the external environment. - if (so.userType.equals(BenchmarkParams.class.getCanonicalName())) { - result.add(" " + so.fieldIdentifier + " = new " + so.type + "(control.benchmarkParams);"); - result.add(" return " + so.fieldIdentifier + ";"); - result.add("}"); - continue; - } else if (so.userType.equals(IterationParams.class.getCanonicalName())) { - result.add(" " + so.fieldIdentifier + " = new " + so.type + "(control.iterationParams);"); - result.add(" return " + so.fieldIdentifier + ";"); - result.add("}"); - continue; - } else if (so.userType.equals(ThreadParams.class.getCanonicalName())) { - result.add(" " + so.fieldIdentifier + " = new " + so.type + "(threadParams);"); - result.add(" return " + so.fieldIdentifier + ";"); - result.add("}"); - continue; - } + result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control" + soDependency_TypeArgs(so) + ") throws Throwable {"); result.add(" " + so.type + " val = " + so.fieldIdentifier + ";"); result.add(" if (val == null) {"); @@ -723,8 +737,8 @@ public List getStateInitializers() { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel != Level.Trial) continue; if (hmi.type != HelperType.SETUP) continue; - Collection args = stateHelperArgs.get(hmi.method.getQualifiedName()); - result.add(" val." + hmi.method.getName() + "(" + getArgList(args) + ");"); + Collection args = stateHelperArgs.get(hmi.method.getQualifiedName()); + result.add(" val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");"); } result.add(" " + so.fieldIdentifier + " = val;"); result.add(" }"); @@ -738,13 +752,14 @@ public List getStateInitializers() { result.add(""); result.add("static java.util.Map " + so.fieldIdentifier + "_map = java.util.Collections.synchronizedMap(new java.util.HashMap());"); result.add(""); - result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control, ThreadParams threadParams" + soDependency_TypeArgs(so) + ") throws Throwable {"); - result.add(" " + so.type + " val = " + so.fieldIdentifier + "_map.get(threadParams.getGroupIndex());"); + result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control" + soDependency_TypeArgs(so) + ") throws Throwable {"); + result.add(" int groupIdx = threadParams.getGroupIndex();"); + result.add(" " + so.type + " val = " + so.fieldIdentifier + "_map.get(groupIdx);"); result.add(" if (val != null) {"); result.add(" return val;"); result.add(" }"); result.add(" synchronized(this.getClass()) {"); - result.add(" val = " + so.fieldIdentifier + "_map.get(threadParams.getGroupIndex());"); + result.add(" val = " + so.fieldIdentifier + "_map.get(groupIdx);"); result.add(" if (val != null) {"); result.add(" return val;"); result.add(" }"); @@ -762,11 +777,11 @@ public List getStateInitializers() { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel != Level.Trial) continue; if (hmi.type != HelperType.SETUP) continue; - Collection args = stateHelperArgs.get(hmi.method.getQualifiedName()); - result.add(" val." + hmi.method.getName() + "(" + getArgList(args) + ");"); + Collection args = stateHelperArgs.get(hmi.method.getQualifiedName()); + result.add(" val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");"); } result.add(" " + "val.ready" + Level.Trial + " = true;"); - result.add(" " + so.fieldIdentifier + "_map.put(threadParams.getGroupIndex(), val);"); + result.add(" " + so.fieldIdentifier + "_map.put(groupIdx, val);"); result.add(" }"); result.add(" return val;"); result.add("}"); @@ -810,7 +825,7 @@ public Collection getStateDestructors(MethodInfo method) { public List getStateGetters(MethodInfo method) { List result = new ArrayList(); for (StateObject so : stateOrder(method, true)) { - result.add(so.type + " " + so.localIdentifier + " = _jmh_tryInit_" + so.fieldIdentifier + "(control, threadParams" + soDependency_Args(so) + ");"); + result.add(so.type + " " + so.localIdentifier + " = _jmh_tryInit_" + so.fieldIdentifier + "(control" + soDependency_Args(so) + ");"); } return result; } @@ -822,9 +837,8 @@ private LinkedHashSet stateOrder(MethodInfo method, boolean reverse List stratum = new ArrayList(); // These are roots - stratum.addAll(args.get(method.getName())); + stratum.addAll(roots.get(method.getName())); stratum.addAll(implicits.values()); - stratum.addAll(getControls()); // Recursively walk the DAG while (!stratum.isEmpty()) { @@ -843,17 +857,6 @@ private LinkedHashSet stateOrder(MethodInfo method, boolean reverse return new LinkedHashSet(linearOrder); } - public void addSuperCall(PrintWriter writer, StateObject so, String suffix) throws IOException { - // These classes have copying constructor: - if (so.userType.equals(BenchmarkParams.class.getCanonicalName()) || - so.userType.equals(IterationParams.class.getCanonicalName()) || - so.userType.equals(ThreadParams.class.getCanonicalName())) { - writer.println(" public " + so.type + suffix + "(" + so.userType + " other) {"); - writer.println(" super(other);"); - writer.println(" }"); - } - } - public void writeStateOverrides(BenchmarkGeneratorSession sess, GeneratorDestination dst) throws IOException { for (StateObject so : cons(stateObjects)) { @@ -868,7 +871,6 @@ public void writeStateOverrides(BenchmarkGeneratorSession sess, GeneratorDestina pw.println("public class " + so.type + "_B1 extends " + so.userType + " {"); Paddings.padding(pw); - addSuperCall(pw, so, "_B1"); pw.println("}"); pw.close(); @@ -907,8 +909,6 @@ public void writeStateOverrides(BenchmarkGeneratorSession sess, GeneratorDestina throw new IllegalStateException("Unknown state scope: " + so.scope); } - addSuperCall(pw, so, "_B2"); - pw.println("}"); pw.close(); @@ -918,10 +918,8 @@ public void writeStateOverrides(BenchmarkGeneratorSession sess, GeneratorDestina PrintWriter pw = new PrintWriter(dst.newClass(so.packageName + "." + so.type + "_B3")); pw.println("package " + so.packageName + ";"); - pw.println("public class " + so.type + "_B3 extends " + so.type + "_B2 {"); Paddings.padding(pw); - addSuperCall(pw, so, "_B3"); pw.println("}"); pw.println(""); @@ -932,9 +930,7 @@ public void writeStateOverrides(BenchmarkGeneratorSession sess, GeneratorDestina PrintWriter pw = new PrintWriter(dst.newClass(so.packageName + "." + so.type)); pw.println("package " + so.packageName + ";"); - pw.println("public class " + so.type + " extends " + so.type + "_B3 {"); - addSuperCall(pw, so, ""); pw.println("}"); pw.println(""); @@ -951,16 +947,6 @@ public StateObject getImplicit(String label) { return implicits.get(label); } - public Collection getControls() { - Collection s = new ArrayList(); - for (StateObject so : cons(args.values())) { - if (so.userType.equals(Control.class.getName())) { - s.add(so); - } - } - return s; - } - public Collection getAuxResultNames(MethodInfo method) { return auxNames.get(method.getName()); } @@ -974,4 +960,5 @@ public void addImports(PrintWriter writer) { writer.println("import " + so.packageName + "." + so.type + ";"); } } + } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java index 85e958764..6878a249f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java @@ -49,7 +49,6 @@ * info about the benchmark * */ -@State(Scope.Thread) public class BenchmarkParams extends BenchmarkParamsL4 { private static final long serialVersionUID = -1068219503090299117L; @@ -66,10 +65,6 @@ public class BenchmarkParams extends BenchmarkParamsL4 { Utils.check(BenchmarkParams.class, "jvm", "jvmArgs"); } - public BenchmarkParams(BenchmarkParams other) { - super(other); - } - public BenchmarkParams(String benchmark, String generatedTarget, boolean synchIterations, int threads, int[] threadGroups, Collection threadGroupLabels, int forks, int warmupForks, @@ -109,10 +104,6 @@ public BenchmarkParamsL4(String benchmark, String generatedTarget, boolean synch jvm, jvmArgs, timeout); } - - public BenchmarkParamsL4(BenchmarkParams other) { - super(other); - } } abstract class BenchmarkParamsL3 extends BenchmarkParamsL2 { @@ -152,10 +143,6 @@ public BenchmarkParamsL3(String benchmark, String generatedTarget, boolean synch jvm, jvmArgs, timeout); } - - public BenchmarkParamsL3(BenchmarkParams other) { - super(other); - } } abstract class BenchmarkParamsL1 extends BenchmarkParamsL0 { @@ -229,26 +216,6 @@ public BenchmarkParamsL2(String benchmark, String generatedTarget, boolean synch this.timeout = timeout; } - public BenchmarkParamsL2(BenchmarkParams other) { - this.benchmark = other.benchmark; - this.generatedTarget = other.generatedTarget; - this.synchIterations = other.synchIterations; - this.threads = other.threads; - this.threadGroups = other.threadGroups; - this.threadGroupLabels = other.threadGroupLabels; - this.forks = other.forks; - this.warmupForks = other.warmupForks; - this.warmup = other.warmup; - this.measurement = other.measurement; - this.mode = other.mode; - this.params = other.params; - this.timeUnit = other.timeUnit; - this.opsPerInvocation = other.opsPerInvocation; - this.jvm = other.jvm; - this.jvmArgs = other.jvmArgs; - this.timeout = other.timeout; - } - /** * @return how long to wait for iteration to complete */ diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java index f888f8aa8..5d6d693dd 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java @@ -24,7 +24,6 @@ */ package org.openjdk.jmh.infra; -import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.util.Utils; import java.util.Random; @@ -152,8 +151,7 @@ abstract class BlackholeL4 extends BlackholeL3 { * value is actually used afterwards. This can save from the dead-code elimination * of the computations resulting in the given values.

*/ -@State(Scope.Thread) // Blackholes are always acting like a thread-local state -public class Blackhole extends BlackholeL4 { +public final class Blackhole extends BlackholeL4 { /** * IMPLEMENTATION NOTES: @@ -257,7 +255,7 @@ public class Blackhole extends BlackholeL4 { Utils.check(Blackhole.class, "obj1", "objs1"); } - public Blackhole() { + public Blackhole(String challengeResponse) { /* * Prevent instantiation by user code. Without additional countermeasures * to properly escape Blackhole, its magic is not working. The instances @@ -277,34 +275,9 @@ public Blackhole() { * directly though. */ - IllegalStateException iae = new IllegalStateException("Blackholes should not be instantiated directly."); - StackTraceElement[] stackTrace = iae.getStackTrace(); - - // Somebody disabled the stack traces? Oh well. - if (stackTrace.length == 0) { - return; - } - - for (StackTraceElement el : stackTrace) { - // Either we instantiate from the JMH generated code, - // or our user is a tricky bastard, and gets what's coming to him. - if (el.getMethodName().startsWith("_jmh_tryInit_") && - el.getClassName().contains("generated")) - return; + if (!challengeResponse.equals("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.")) { + throw new IllegalStateException("Blackholes should not be instantiated directly."); } - throw iae; - } - - /* - * Need to clear the sinks to break the GC from keeping the - * consumed objects forever. - */ - - @Setup(Level.Iteration) - @TearDown(Level.Iteration) - public void clearSinks() { - obj1 = new Object(); - objs1 = new Object[]{new Object()}; } /** diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/Control.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/Control.java index d64fc3e90..f094ece9b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Control.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Control.java @@ -24,18 +24,13 @@ */ package org.openjdk.jmh.infra; -import org.openjdk.jmh.annotations.Level; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.util.Utils; /** * Control object, used to communicate significant information from JMH to the benchmark. * WARNING: The API for this class is considered unstable, and can be changed without notice. */ -@State(Scope.Benchmark) -public class Control extends ControlL4 { +public final class Control extends ControlL4 { /** * Do the class hierarchy trick to evade false sharing, and check if it's working in runtime. @@ -72,12 +67,6 @@ abstract class ControlL1 extends ControlL0 { abstract class ControlL2 extends ControlL1 { - @Setup(Level.Iteration) - public void setup() { - startMeasurement = false; - stopMeasurement = false; - } - /** * Transitions to "true", once JMH had started the measurement for the current iteration. */ diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/IterationParams.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/IterationParams.java index 59f617eef..f64218028 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/IterationParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/IterationParams.java @@ -24,8 +24,6 @@ */ package org.openjdk.jmh.infra; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Utils; @@ -46,18 +44,13 @@ * info about the benchmark * */ -@State(Scope.Thread) -public class IterationParams extends IterationParamsL4 { +public final class IterationParams extends IterationParamsL4 { private static final long serialVersionUID = -8111111319033802892L; static { Utils.check(IterationParams.class, "type", "count", "timeValue", "batchSize"); } - public IterationParams(IterationParams other) { - super(other); - } - public IterationParams(IterationType type, int count, TimeValue time, int batchSize) { super(type, count, time, batchSize); } @@ -70,10 +63,6 @@ abstract class IterationParamsL4 extends IterationParamsL3 { public IterationParamsL4(IterationType type, int count, TimeValue time, int batchSize) { super(type, count, time, batchSize); } - - public IterationParamsL4(IterationParams other) { - super(other); - } } abstract class IterationParamsL3 extends IterationParamsL2 { @@ -99,10 +88,6 @@ abstract class IterationParamsL3 extends IterationParamsL2 { public IterationParamsL3(IterationType type, int count, TimeValue time, int batchSize) { super(type, count, time, batchSize); } - - public IterationParamsL3(IterationParams other) { - super(other); - } } abstract class IterationParamsL1 extends IterationParamsL0 { @@ -158,13 +143,6 @@ public IterationParamsL2(IterationType type, int count, TimeValue time, int batc this.batchSize = batchSize; } - public IterationParamsL2(IterationParams other) { - this.type = other.type; - this.count = other.count; - this.timeValue = other.timeValue; - this.batchSize = other.batchSize; - } - /** * Iteration type: separates warmup iterations vs. measurement iterations. * @return iteration type. diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/ThreadParams.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/ThreadParams.java index ff7c4f050..dd3252d0a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/ThreadParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/ThreadParams.java @@ -24,8 +24,6 @@ */ package org.openjdk.jmh.infra; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.util.Utils; /** @@ -35,18 +33,13 @@ * not limited to the number of threads, thread indicies, group information, etc. Some * of that info duplicates what is available in {@link org.openjdk.jmh.infra.BenchmarkParams}.

*/ -@State(Scope.Thread) -public class ThreadParams extends ThreadParamsL4 { +public final class ThreadParams extends ThreadParamsL4 { public ThreadParams(int threadIdx, int threadCount, int groupIdx, int groupCount, int subgroupIdx, int subgroupCount, int groupThreadIdx, int groupThreadCount, int subgroupThreadIdx, int subgroupThreadCount) { super(threadIdx, threadCount, groupIdx, groupCount, subgroupIdx, subgroupCount, groupThreadIdx, groupThreadCount, subgroupThreadIdx, subgroupThreadCount); } - public ThreadParams(ThreadParams other) { - super(other); - } - static { Utils.check(ThreadParams.class, "threadIdx", "threadCount"); Utils.check(ThreadParams.class, "groupIdx", "groupCount"); @@ -250,20 +243,6 @@ public ThreadParamsL2(int threadIdx, int threadCount, int groupIdx, int groupCou this.subgroupThreadIdx = subgroupThreadIdx; this.subgroupThreadCount = subgroupThreadCount; } - - public ThreadParamsL2(ThreadParams other) { - this.threadIdx = other.threadIdx; - this.threadCount = other.threadCount; - this.groupIdx = other.groupIdx; - this.groupCount = other.groupCount; - this.subgroupIdx = other.subgroupIdx; - this.subgroupCount = other.subgroupCount; - this.groupThreadIdx = other.groupThreadIdx; - this.subgroupThreadIdx = other.subgroupThreadIdx; - this.subgroupThreadCount = other.subgroupThreadCount; - this.groupThreadCount = other.groupThreadCount; - } - } abstract class ThreadParamsL3 extends ThreadParamsL2 { @@ -289,10 +268,6 @@ public ThreadParamsL3(int threadIdx, int threadCount, int groupIdx, int groupCou super(threadIdx, threadCount, groupIdx, groupCount, subgroupIdx, subgroupCount, groupThreadIdx, groupThreadCount, subgroupThreadIdx, subgroupThreadCount); } - - public ThreadParamsL3(ThreadParams other) { - super(other); - } } abstract class ThreadParamsL4 extends ThreadParamsL3 { @@ -303,8 +278,4 @@ public ThreadParamsL4(int threadIdx, int threadCount, int groupIdx, int groupCou super(threadIdx, threadCount, groupIdx, groupCount, subgroupIdx, subgroupCount, groupThreadIdx, groupThreadCount, subgroupThreadIdx, subgroupThreadCount); } - - public ThreadParamsL4(ThreadParams other) { - super(other); - } } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java b/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java index 570ef7532..ff61b97de 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java @@ -47,11 +47,17 @@ public void test() { @Test public void testUserConstructor() { try { - new Blackhole(); + new Blackhole("Boyaa"); Assert.fail("Should have failed"); } catch (IllegalStateException e) { // expected } + + try { + new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous."); + } catch (Throwable e) { + Assert.fail("Failed unexpectedly"); + } } } From afd2b5f188207fb373cdcf59b1aafc66f8a56ec4 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 19 Jul 2016 21:58:54 +0300 Subject: [PATCH 012/342] 7901736: JMH update interval should be greater --- jmh-core/src/main/java/org/openjdk/jmh/util/Version.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java index bc2030b35..52d15e331 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java @@ -37,6 +37,8 @@ public class Version { + private static final int UPDATE_INTERVAL = 180; + public static String getVersion() { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); @@ -84,7 +86,7 @@ private static void printVersion(PrintWriter pw) { long diff = (System.currentTimeMillis() - parse.getTime()) / TimeUnit.DAYS.toMillis(1); if (diff > 0) { pw.print(String.format("%d days ago", diff)); - if (diff > 90) { + if (diff > UPDATE_INTERVAL) { pw.print(", please consider updating!"); } } else { From ba861f9867f7e8b7aa729d7edefd7c94b3e42e14 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 20 Jul 2016 23:30:00 +0300 Subject: [PATCH 013/342] 7901737: perfasm should print the compiler, compilation level, method version --- .../jmh/profile/AbstractPerfAsmProfiler.java | 431 +++++++++--------- .../jmh/profile/LinuxPerfAsmProfiler.java | 17 +- .../jmh/profile/WinPerfAsmProfiler.java | 16 +- .../java/org/openjdk/jmh/util/Interval.java | 71 +++ .../org/openjdk/jmh/util/IntervalMap.java | 59 +++ .../main/java/org/openjdk/jmh/util/Utils.java | 40 +- 6 files changed, 414 insertions(+), 220 deletions(-) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/util/Interval.java create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/util/IntervalMap.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index b5b7521d1..01a136a4f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -396,12 +396,12 @@ public int compare(Region o1, Region o2) { for (Region r : regions) { if (r.getEventCount(events, mainEvent) > threshold) { if (!headerPrinted) { - pw.printf("Hottest code regions (>%.2f%% \"%s\" events):%n", regionRateThreshold * 100, mainEvent); + pw.printf("Hottest code regions (>%.2f%% \"%s\" events):%n%n", regionRateThreshold * 100, mainEvent); headerPrinted = true; } printDottedLine(pw, "Hottest Region " + cnt); - pw.printf(" [0x%x:0x%x] in %s%n%n", r.begin, r.end, r.getName()); + pw.printf("%s, %s (%d bytes) %n%n", r.desc().source(), r.desc().name(), r.end - r.begin); r.printCode(pw, events); printDottedLine(pw); @@ -420,6 +420,11 @@ public int compare(Region o1, Region o2) { pw.println(); } + int lenSource = 0; + for (Region r : regions) { + lenSource = Math.max(lenSource, r.desc().source().length()); + } + /** * 6. Print out the hottest regions */ @@ -434,7 +439,7 @@ public int compare(Region o1, Region o2) { for (String event : this.events) { printLine(pw, events, event, r.getEventCount(events, event)); } - pw.printf("[0x%x:0x%x] in %s%n", r.begin, r.end, r.getName()); + pw.printf("%" + lenSource + "s %s (%d bytes) %n", r.desc().source(), r.desc().name(), r.end - r.begin); } else { for (String event : this.events) { other.add(event, r.getEventCount(events, event)); @@ -461,8 +466,19 @@ public int compare(Region o1, Region o2) { } final Map> methodsByType = new HashMap>(); + final Map> methods = new HashMap>(); + for (String event : this.events) { methodsByType.put(event, new HashMultiset()); + methods.put(event, new HashMultiset()); + } + + for (Region r : regions) { + for (String event : this.events) { + long count = r.getEventCount(events, event); + methods.get(event).add(r.desc(), count); + methodsByType.get(event).add(r.desc().source(), count); + } } /** @@ -471,30 +487,17 @@ public int compare(Region o1, Region o2) { { printDottedLine(pw, "Hottest Methods (after inlining)"); - Map> methods = new HashMap>(); - for (String event : this.events) { - methods.put(event, new HashMultiset()); - } - - for (Region r : regions) { - for (String event : this.events) { - long count = r.getEventCount(events, event); - methods.get(event).add(r.getName(), count); - methodsByType.get(event).add(r.getType(), count); - } - } - Multiset total = new HashMultiset(); Multiset other = new HashMultiset(); int shownMethods = 0; - List top = Multisets.sortedDesc(methods.get(mainEvent)); - for (String m : top) { + List top = Multisets.sortedDesc(methods.get(mainEvent)); + for (MethodDesc m : top) { if (shownMethods++ < regionShowTop) { for (String event : this.events) { printLine(pw, events, event, methods.get(event).count(m)); } - pw.printf("%s%n", m); + pw.printf("%" + lenSource + "s %s %n", m.source(), m.name()); } else { for (String event : this.events) { other.add(event, methods.get(event).count(m)); @@ -524,13 +527,13 @@ public int compare(Region o1, Region o2) { * Print hot methods distribution */ { - printDottedLine(pw, "Distribution by Area"); + printDottedLine(pw, "Distribution by Source"); for (String m : Multisets.sortedDesc(methodsByType.get(mainEvent))) { for (String event : this.events) { printLine(pw, events, event, methodsByType.get(event).count(m)); } - pw.printf("%s%n", m); + pw.printf("%" + lenSource + "s%n", m); } printDottedLine(pw); @@ -667,50 +670,61 @@ void printDottedLine(PrintWriter pw, String header) { List makeRegions(Assembly asms, PerfEvents events) { List regions = new ArrayList(); - SortedSet addrs = events.getAllAddresses(); + SortedSet allAddrs = events.getAllAddresses(); + for (Interval intv : figureHotIntervals(allAddrs, allAddrs.first(), allAddrs.last())) { + SortedSet eventfulAddrs = allAddrs.subSet(intv.src, intv.dst + 1); - Set eventfulAddrs = new HashSet(); - Long lastBegin = null; - Long lastAddr = null; - for (Long addr : addrs) { - if (addr == 0) { - regions.add(new UnknownRegion()); - continue; - } + List regionLines = asms.getLines(intv.src, intv.dst, printMargin); - if (lastAddr == null) { - lastAddr = addr; - lastBegin = addr; - } else { - if (addr - lastAddr > mergeMargin) { - List regionLines = asms.getLines(lastBegin, lastAddr, printMargin); - - long minAddr = Long.MAX_VALUE; - long maxAddr = Long.MIN_VALUE; - for (ASMLine line : regionLines) { - if (line.addr != null) { - minAddr = Math.min(minAddr, line.addr); - maxAddr = Math.max(maxAddr, line.addr); - } - } + if (!regionLines.isEmpty()) { + // has some associated assembly - if (!regionLines.isEmpty()) { - regions.add(new GeneratedRegion(this.events, asms, minAddr, maxAddr, regionLines, eventfulAddrs, regionTooBigThreshold, drawIntraJumps, drawInterJumps)); - } else { - regions.add(new NativeRegion(events, lastBegin, lastAddr, eventfulAddrs)); - } + // TODO: Should scan and split regions for multiple descs? + MethodDesc desc = asms.getMethod(intv.src); + if (desc == null) { + desc = MethodDesc.unknown(); + } + + regions.add(new GeneratedRegion(this.events, asms, desc, intv.src, intv.dst, + regionLines, eventfulAddrs, regionTooBigThreshold, drawIntraJumps, drawInterJumps)); + } else { + // has no assembly, should be a native region - lastBegin = addr; - eventfulAddrs = new HashSet(); + // TODO: Should scan and split regions for multiple descs? + MethodDesc desc = events.getMethod(intv.src); + if (desc == null) { + desc = MethodDesc.unknown(); } - lastAddr = addr; + + regions.add(new NativeRegion(desc, intv.src, intv.dst, eventfulAddrs)); } - eventfulAddrs.add(addr); } return regions; } + + private List figureHotIntervals(SortedSet allAddrs, long from, long to) { + List intervals = new ArrayList(); + SortedSet addrs = allAddrs.subSet(from, to); + + long begAddr = addrs.first(); + long lastAddr = addrs.first(); + for (long addr : addrs) { + if (addr - lastAddr > mergeMargin) { + intervals.add(new Interval(begAddr, lastAddr)); + begAddr = addr; + } + lastAddr = addr; + } + + if (begAddr != lastAddr) { + intervals.add(new Interval(begAddr, lastAddr)); + } + + return intervals; + } + Collection> splitAssembly(File stdOut) { FileReader in = null; try { @@ -754,11 +768,13 @@ Collection> splitAssembly(File stdOut) { Assembly readAssembly(File stdOut) { List lines = new ArrayList(); SortedMap addressMap = new TreeMap(); - SortedMap methodMap = new TreeMap(); + + IntervalMap stubs = new IntervalMap(); + IntervalMap javaMethods = new IntervalMap(); + Set intervals = new HashSet(); for (Collection cs : splitAssembly(stdOut)) { - String method = null; String prevLine = ""; for (String line : cs) { String trim = line.trim(); @@ -769,26 +785,20 @@ Assembly readAssembly(File stdOut) { ASMLine asmLine = new ASMLine(line); // Handle the most frequent case first. - if (elements.length >= 1 && elements[0].startsWith("0x")) { + if (trim.startsWith("0x")) { // Seems to be line with address. try { - Long addr = Long.valueOf(elements[0].replace("0x", "").replace(":", ""), 16); + Long addr = parseAddress(elements[0]); int idx = lines.size(); addressMap.put(addr, idx); - // Record the starting address for the method, if any. - if (method != null) { - methodMap.put(addr, method); - method = null; - } - asmLine = new ASMLine(addr, line); - if (drawInterJumps || drawIntraJumps) { + if (elements.length > 1 && (drawInterJumps || drawIntraJumps)) { for (int c = 1; c < elements.length; c++) { if (elements[c].startsWith("0x")) { try { - Long target = Long.valueOf(elements[c].replace("0x", "").replace(":", ""), 16); + Long target = parseAddress(elements[c]); intervals.add(new Interval(addr, target)); } catch (NumberFormatException e) { // nope @@ -799,39 +809,77 @@ Assembly readAssembly(File stdOut) { } catch (NumberFormatException e) { // Nope, not the address line. } - } else if (line.contains("# {method}")) { - // Handle the compiled code line. - if (elements.length == 6) { - // old JDKs may print the line with 6 fields: # {method} in - method = (elements[5].replace("/", ".") + "::" + elements[2]).replace("'", ""); - } else if (elements.length == 7) { - // newer JDKs always print 7 fields: # {method}
in - method = (elements[6].replace("/", ".") + "::" + elements[3]).replace("'", ""); - } else { - // {method} line is corrupted, other writer had possibly interjected; - // honestly say we can't figure the method name out instead of lying. - method = ""; + } + + if (prevLine.contains("--------") || line.contains("StubRoutines::")) { + // Try parsing the interpreter/runtime stub: + // ---------------------------------------------------------------------- + // invokehandle 233 invokehandle [0x00007f631d023100, 0x00007f631d0233c0] 704 bytes + // StubRoutines::catch_exception [0x00007feb43fa7b27, 0x00007feb43fa7b46[ (31 bytes) + + Pattern pattern = Pattern.compile("(.+)( +)\\[(.+), (.+)[\\]\\[](.*)"); + Matcher matcher = pattern.matcher(line); + + if (matcher.matches()) { + Long startAddr = parseAddress(matcher.group(3)); + Long endAddr = parseAddress(matcher.group(4)); + + if (line.contains("StubRoutines::")) { + stubs.add(MethodDesc.runtimeStub(matcher.group(1)), startAddr, endAddr); + } else { + stubs.add(MethodDesc.interpreter(matcher.group(1)), startAddr, endAddr); + } } - method = method.replace("'", ""); - method = method.replace("<", "<"); - method = method.replace(">", ">"); - } else if (prevLine.contains("--------")) { - if (line.trim().endsWith("bytes")) { - // Handle the VM stub/interpreter line. - method = ""; + } + + if (line.contains(" + + Matcher matcher = Pattern.compile("(.*?)(.*?)").matcher(line); + if (matcher.matches()) { + String body = matcher.group(2); + body = body.replaceAll("='", "="); + String[] kvs = body.split("' "); + + HashMap map = new HashMap(); + for (String kv : kvs) { + String[] pair = kv.split("="); + map.put(pair[0], pair[1]); + } + + // Record the starting address for the method + Long addr = parseAddress(map.get("entry")); + + javaMethods.add( + MethodDesc.javaMethod(map.get("method"), map.get("compiler"), map.get("level"), map.get("compile_id")), + addr, + addr + Long.valueOf(map.get("size")) + ); } - } else if (line.contains("StubRoutines::")) { - // Handle the VM stub/interpreter line (another format) - method = elements[0]; } + lines.add(asmLine); prevLine = line; } } + + // Important to get the order right: all Java methods take precedence over interpreter/runtime stubs. + IntervalMap methodMap = new IntervalMap(); + methodMap.merge(stubs); + methodMap.merge(javaMethods); + return new Assembly(lines, addressMap, methodMap, intervals); } + private Long parseAddress(String address) { + return Long.valueOf(address.replace("0x", "").replace(":", ""), 16); + } + static class PerfResult extends Result { private static final long serialVersionUID = 6871141606856800453L; @@ -874,58 +922,14 @@ public PerfResult aggregate(Collection results) { } } - static class Interval implements Comparable { - private final long src; - private final long dst; - - public Interval(long src, long dst) { - this.src = src; - this.dst = dst; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Interval interval = (Interval) o; - - if (dst != interval.dst) return false; - if (src != interval.src) return false; - - return true; - } - - @Override - public int hashCode() { - int result = (int) (src ^ (src >>> 32)); - result = 31 * result + (int) (dst ^ (dst >>> 32)); - return result; - } - - @Override - public int compareTo(Interval o) { - if (src < o.src) { - return -1; - } else if (src > o.src) { - return 1; - } else { - return (dst < o.dst) ? -1 : ((dst == o.dst) ? 0 : 1); - } - } - } - - protected static class PerfEvents { final Map> events; - final Map methods; - final Map libs; + final IntervalMap methods; final Map totalCounts; - PerfEvents(Collection tracedEvents, Map> events, Map methods, Map libs) { + PerfEvents(Collection tracedEvents, Map> events, IntervalMap methods) { this.events = events; this.methods = methods; - this.libs = libs; this.totalCounts = new HashMap(); for (String event : tracedEvents) { totalCounts.put(event, events.get(event).size()); @@ -933,7 +937,7 @@ protected static class PerfEvents { } public PerfEvents(Collection tracedEvents) { - this(tracedEvents, Collections.>emptyMap(), Collections.emptyMap(), Collections.emptyMap()); + this(tracedEvents, Collections.>emptyMap(), new IntervalMap()); } public boolean isEmpty() { @@ -955,15 +959,19 @@ public SortedSet getAllAddresses() { public Long getTotalEvents(String event) { return totalCounts.get(event); } + + public MethodDesc getMethod(long addr) { + return methods.get(addr); + } } static class Assembly { final List lines; final SortedMap addressMap; - final SortedMap methodMap; + final IntervalMap methodMap; final Set intervals; - public Assembly(List lines, SortedMap addressMap, SortedMap methodMap, Set intervals) { + public Assembly(List lines, SortedMap addressMap, IntervalMap methodMap, Set intervals) { this.lines = lines; this.addressMap = addressMap; this.methodMap = methodMap; @@ -1009,16 +1017,8 @@ public List getLines(long begin, long end, int window) { } } - public String getMethod(long addr) { - if (methodMap.containsKey(addr)) { - return methodMap.get(addr); - } - SortedMap head = methodMap.headMap(addr); - if (head.isEmpty()) { - return ""; - } else { - return methodMap.get(head.lastKey()); - } + public MethodDesc getMethod(long addr) { + return methodMap.get(addr); } } @@ -1037,13 +1037,13 @@ static class ASMLine { } static class Region { - final String method; + final MethodDesc method; final long begin; final long end; final Set eventfulAddrs; final Map eventCountCache; - Region(String method, long begin, long end, Set eventfulAddrs) { + Region(MethodDesc method, long begin, long end, Set eventfulAddrs) { this.method = method; this.begin = begin; this.end = end; @@ -1067,13 +1067,9 @@ public void printCode(PrintWriter pw, PerfEvents events) { pw.println(""); } - public String getName() { + public MethodDesc desc() { return method; } - - public String getType() { - return ""; - } } static class GeneratedRegion extends Region { @@ -1084,10 +1080,10 @@ static class GeneratedRegion extends Region { final boolean drawIntraJumps; final boolean drawInterJumps; - GeneratedRegion(Collection tracedEvents, Assembly asms, long begin, long end, + GeneratedRegion(Collection tracedEvents, Assembly asms, MethodDesc desc, long begin, long end, Collection code, Set eventfulAddrs, int threshold, boolean drawIntraJumps, boolean drawInterJumps) { - super(generateName(asms, eventfulAddrs), begin, end, eventfulAddrs); + super(desc, begin, end, eventfulAddrs); this.tracedEvents = tracedEvents; this.asms = asms; this.code = code; @@ -1096,17 +1092,6 @@ static class GeneratedRegion extends Region { this.drawInterJumps = drawInterJumps; } - static String generateName(Assembly asm, Set eventfulAddrs) { - Set methods = new HashSet(); - for (Long ea : eventfulAddrs) { - String m = asm.getMethod(ea); - if (m != null) { - methods.add(m); - } - } - return Utils.join(methods, "; "); - } - @Override public void printCode(PrintWriter pw, PerfEvents events) { if (code.size() > threshold) { @@ -1194,66 +1179,106 @@ private void printInterval(PrintWriter pw, Interval it, long addr, long evAddr, } } } - - @Override - public String getType() { - return ""; - } } static class NativeRegion extends Region { - private final String lib; - NativeRegion(PerfEvents events, long begin, long end, Set eventfulAddrs) { - super(generateName(events, eventfulAddrs), begin, end, eventfulAddrs); - lib = resolveLib(events, eventfulAddrs); + NativeRegion(MethodDesc desc, long begin, long end, Set eventfulAddrs) { + super(desc, begin, end, eventfulAddrs); } - static String generateName(PerfEvents events, Set eventfulAddrs) { - Set methods = new HashSet(); - for (Long ea : eventfulAddrs) { - methods.add(events.methods.get(ea)); - } - return Utils.join(methods, "; "); + @Override + public void printCode(PrintWriter pw, PerfEvents events) { + pw.println(" "); } + } - static String resolveLib(PerfEvents events, Set eventfulAddrs) { - Set libs = new HashSet(); - for (Long ea : eventfulAddrs) { - libs.add(events.libs.get(ea)); - } - return Utils.join(libs, "; "); + static class UnknownRegion extends Region { + UnknownRegion() { + super(MethodDesc.unknown(), 0L, 0L, Collections.singleton(0L)); } @Override public void printCode(PrintWriter pw, PerfEvents events) { - pw.println(" "); + pw.println(" "); + } + } + + static class MethodDesc { + private final String name; + private final String source; + + protected MethodDesc(String name, String source) { + this.name = name; + this.source = source; } - @Override - public String getType() { - return ""; + public static MethodDesc unresolved() { + return new MethodDesc("", ""); } - @Override - public String getName() { - return method + " (" + lib + ")"; + public static MethodDesc unknown() { + return new MethodDesc("", ""); } - } - static class UnknownRegion extends Region { - UnknownRegion() { - super("", 0L, 0L, Collections.singleton(0L)); + public static MethodDesc kernel() { + return new MethodDesc("", "kernel"); + } + + public static MethodDesc interpreter(String name) { + return new MethodDesc(name, "interpreter"); + } + + public static MethodDesc runtimeStub(String name) { + return new MethodDesc(name, "runtime stub"); + } + + public static MethodDesc javaMethod(String name, String compiler, String level, String ver) { + String methodName = name.replace("/", ".").replaceFirst(" ", "::").split(" ")[0]; + return new MethodDesc( + methodName + ", version " + ver, + (compiler != null ? compiler : "Unknown") + (level != null ? ", level " + level : "") + ); + } + + public static MethodDesc nativeMethod(String symbol, String lib) { + return new MethodDesc(symbol, lib); + } + + public String name() { + return name; + } + + public String source() { + return source; } @Override - public void printCode(PrintWriter pw, PerfEvents events) { - pw.println(" "); + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + MethodDesc that = (MethodDesc) o; + + if (!name.equals(that.name)) return false; + return source.equals(that.source); + + } + + @Override + public int hashCode() { + int result = name.hashCode(); + result = 31 * result + source.hashCode(); + return result; } @Override - public String getType() { - return ""; + public String toString() { + return "MethodDesc{" + + "name='" + name + '\'' + + ", source='" + source + '\'' + + '}'; } } + } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index 212f4ae7f..ede0b707e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -107,13 +107,12 @@ protected void parseEvents() { protected PerfEvents readEvents(double skipSec) { FileReader fr = null; try { - Deduplicator dedup = new Deduplicator(); + Deduplicator dedup = new Deduplicator(); fr = new FileReader(perfParsedData); BufferedReader reader = new BufferedReader(fr); - Map methods = new HashMap(); - Map libs = new HashMap(); + Multimap methods = new HashMultimap(); Map> events = new LinkedHashMap>(); for (String evName : this.events) { events.put(evName, new TreeMultiset()); @@ -179,13 +178,16 @@ protected PerfEvents readEvents(double skipSec) { } evs.add(addr); - methods.put(addr, dedup.dedup(symbol)); - libs.put(addr, dedup.dedup(lib)); + methods.put(dedup.dedup(MethodDesc.nativeMethod(symbol, lib)), addr); } - methods.put(0L, ""); + IntervalMap methodMap = new IntervalMap(); + for (MethodDesc md : methods.keys()) { + Collection addrs = methods.get(md); + methodMap.add(md, Utils.min(addrs), Utils.max(addrs)); + } - return new PerfEvents(this.events, events, methods, libs); + return new PerfEvents(this.events, events, methodMap); } catch (IOException e) { return new PerfEvents(events); } finally { @@ -193,6 +195,7 @@ protected PerfEvents readEvents(double skipSec) { } } + @Override protected String perfBinaryExtension() { return ".perfbin"; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index 8c91f1557..e175dec00 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -183,13 +183,12 @@ protected void parseEvents() { protected PerfEvents readEvents(double skipSec) { FileReader fr = null; try { - Deduplicator dedup = new Deduplicator(); + Deduplicator dedup = new Deduplicator(); fr = new FileReader(perfParsedData); BufferedReader reader = new BufferedReader(fr); - Map methods = new HashMap(); - Map libs = new HashMap(); + Multimap methods = new HashMultimap(); Map> events = new LinkedHashMap>(); for (String evName : this.events) { events.put(evName, new TreeMultiset()); @@ -245,8 +244,7 @@ protected PerfEvents readEvents(double skipSec) { try { Long addr = Long.valueOf(addrStr, 16); evs.add(addr); - methods.put(addr, dedup.dedup(symbol)); - libs.put(addr, dedup.dedup(lib)); + methods.put(dedup.dedup(MethodDesc.nativeMethod(symbol, lib)), addr); } catch (NumberFormatException e) { // kernel addresses like "ffffffff810c1b00" overflow signed long, // record them as dummy address @@ -254,9 +252,13 @@ protected PerfEvents readEvents(double skipSec) { } } - methods.put(0L, ""); + IntervalMap methodMap = new IntervalMap(); + for (MethodDesc md : methods.keys()) { + Collection longs = methods.get(md); + methodMap.add(md, Utils.min(longs), Utils.max(longs)); + } - return new PerfEvents(this.events, events, methods, libs); + return new PerfEvents(this.events, events, methodMap); } catch (IOException e) { return new PerfEvents(events); } finally { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Interval.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Interval.java new file mode 100644 index 000000000..d06cb50fa --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Interval.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.util; + +public class Interval implements Comparable { + public final long src; + public final long dst; + + public Interval(long src, long dst) { + this.src = src; + this.dst = dst; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Interval interval = (Interval) o; + + if (dst != interval.dst) return false; + if (src != interval.src) return false; + + return true; + } + + @Override + public int hashCode() { + int result = (int) (src ^ (src >>> 32)); + result = 31 * result + (int) (dst ^ (dst >>> 32)); + return result; + } + + @Override + public int compareTo(Interval o) { + if (src < o.src) { + return -1; + } else if (src > o.src) { + return 1; + } else { + return (dst < o.dst) ? -1 : ((dst == o.dst) ? 0 : 1); + } + } + + @Override + public String toString() { + return "[" + src + ", " + dst + "]"; + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/IntervalMap.java b/jmh-core/src/main/java/org/openjdk/jmh/util/IntervalMap.java new file mode 100644 index 000000000..27b7c7324 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/IntervalMap.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.util; + +import java.util.SortedMap; +import java.util.TreeMap; + +public class IntervalMap { + + final SortedMap from; + + public IntervalMap() { + from = new TreeMap(); + } + + public void add(T val, long from, long to) { + // TODO: Check for intersections + this.from.put(from, val); + } + + public T get(long k) { + T key = from.get(k); + if (key != null) { + return key; + } + SortedMap head = from.headMap(k); + if (head.isEmpty()) { + return null; + } else { + return from.get(head.lastKey()); + } + } + + public void merge(IntervalMap other) { + from.putAll(other.from); + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 0fcebc659..da8fbb71b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -34,9 +34,8 @@ import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; +import java.util.concurrent.*; +import java.util.regex.Pattern; public class Utils { @@ -58,6 +57,41 @@ private Utils() { } + private static final ConcurrentMap PATTERNS = new ConcurrentHashMap(); + + public static Pattern lazyCompile(String pattern) { + Pattern patt = PATTERNS.get(pattern); + if (patt == null) { + patt = Pattern.compile(pattern); + PATTERNS.put(pattern, patt); + } + return patt; + } + + public static > T min(Collection ts) { + T min = null; + for (T t : ts) { + if (min == null) { + min = t; + } else { + min = min.compareTo(t) < 0 ? min : t; + } + } + return min; + } + + public static > T max(Collection ts) { + T max = null; + for (T t : ts) { + if (max == null) { + max = t; + } else { + max = max.compareTo(t) > 0 ? max : t; + } + } + return max; + } + public static String[] concat(String[] t1, String[] t2) { String[] r = new String[t1.length + t2.length]; System.arraycopy(t1, 0, r, 0, t1.length); From 748f3b220d783f55c4fd30cbbf3e056cc840a8f8 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 21 Jul 2016 17:02:51 +0300 Subject: [PATCH 014/342] 7901738: Update Kotlin benchmark archetype --- .../META-INF/maven/archetype-metadata.xml | 2 +- .../main/resources/archetype-resources/pom.xml | 17 ++++++++++++----- .../kotlin/{MyBenchmark.ktm => MyBenchmark.kt} | 2 +- .../projects/test/archetype.properties | 4 ++++ .../src/test/resources/projects/test/goal.txt | 1 + 5 files changed, 19 insertions(+), 7 deletions(-) rename jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/main/kotlin/{MyBenchmark.ktm => MyBenchmark.kt} (99%) create mode 100644 jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/archetype.properties create mode 100644 jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/goal.txt diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index ce267e15d..6d298328d 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -30,7 +30,7 @@ questions. src/main/kotlin - **/*.ktm + **/*.kt diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index f4417e388..929f98cfb 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -50,10 +50,11 @@ THE POSSIBILITY OF SUCH DAMAGE. jmh-core \${jmh.version} - + + org.jetbrains.kotlin + kotlin-stdlib + \${kotlin.version} + @@ -65,6 +66,12 @@ THE POSSIBILITY OF SUCH DAMAGE. ${project.version} default 1.6 + + 1.0.2 benchmarks @@ -80,7 +87,7 @@ THE POSSIBILITY OF SUCH DAMAGE. - PUT_THE_VERSION_HERE + \${kotlin.version} diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/main/kotlin/MyBenchmark.ktm b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/main/kotlin/MyBenchmark.kt similarity index 99% rename from jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/main/kotlin/MyBenchmark.ktm rename to jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/main/kotlin/MyBenchmark.kt index 45757e3a6..25c527efa 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/main/kotlin/MyBenchmark.ktm +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/src/main/kotlin/MyBenchmark.kt @@ -35,7 +35,7 @@ import org.openjdk.jmh.annotations.Benchmark open class MyBenchmark { - [Benchmark] + @Benchmark fun testMethod() { // This is a demo/sample template for building your JMH benchmarks. Edit as needed. // Put your benchmark code here. diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/archetype.properties b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/archetype.properties new file mode 100644 index 000000000..9fc09814c --- /dev/null +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/archetype.properties @@ -0,0 +1,4 @@ +groupId=org.openjdk.jmh +artifactId=jmh-kotlin-benchmark-archetype-test +version=1.0-SNAPSHOT +package=org.openjdk.jmh diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/goal.txt b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/goal.txt new file mode 100644 index 000000000..4a1a71d33 --- /dev/null +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/test/resources/projects/test/goal.txt @@ -0,0 +1 @@ +verify \ No newline at end of file From 391cee6e6afa01d142259bef45c415737d1cdee0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 21 Jul 2016 17:42:20 +0300 Subject: [PATCH 015/342] 7901739: Update benchmark archetypes: Java version, suggested plugin versions, etc --- .../resources/archetype-resources/pom.xml | 39 ++++++++++++--- .../projects/test/archetype.properties | 4 ++ .../src/test/resources/projects/test/goal.txt | 1 + .../resources/archetype-resources/pom.xml | 14 +++++- .../resources/archetype-resources/pom.xml | 24 +++++++++- .../resources/archetype-resources/pom.xml | 48 ++++++++++++++++--- .../projects/test/archetype.properties | 4 ++ .../src/test/resources/projects/test/goal.txt | 1 + 8 files changed, 119 insertions(+), 16 deletions(-) create mode 100644 jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/archetype.properties create mode 100644 jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/goal.txt create mode 100644 jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/archetype.properties create mode 100644 jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/goal.txt diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index d0ac3cb06..2c1df6433 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -49,10 +49,11 @@ THE POSSIBILITY OF SUCH DAMAGE. jmh-core \${jmh.version} - + + org.codehaus.groovy + groovy + \${groovy.version} + @@ -61,9 +62,35 @@ THE POSSIBILITY OF SUCH DAMAGE. UTF-8 + + ${project.version} - default - 1.6 + + + 1.8 + + + 2.4.7 + + + default + + benchmarks diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/archetype.properties b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/archetype.properties new file mode 100644 index 000000000..71f560e02 --- /dev/null +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/archetype.properties @@ -0,0 +1,4 @@ +groupId=org.openjdk.jmh +artifactId=jmh-groovy-benchmark-archetype-test +version=1.0-SNAPSHOT +package=org.openjdk.jmh diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/goal.txt b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/goal.txt new file mode 100644 index 000000000..4a1a71d33 --- /dev/null +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/test/resources/projects/test/goal.txt @@ -0,0 +1 @@ +verify \ No newline at end of file diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 5758962be..9286e9949 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -65,8 +65,20 @@ THE POSSIBILITY OF SUCH DAMAGE. UTF-8 + + ${project.version} - 1.6 + + + 1.8 + + benchmarks diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 929f98cfb..962a72754 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -63,15 +63,35 @@ THE POSSIBILITY OF SUCH DAMAGE. UTF-8 + + ${project.version} - default - 1.6 + + + 1.8 + 1.0.2 + + + default + + benchmarks diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 3819ecd79..f9312a9c6 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -49,10 +49,11 @@ THE POSSIBILITY OF SUCH DAMAGE. jmh-core \${jmh.version} - + + org.scala-lang + scala-library + \${scala.stdLib.version} + @@ -61,9 +62,42 @@ THE POSSIBILITY OF SUCH DAMAGE. UTF-8 + + ${project.version} - default - 1.6 + + + 1.8 + + + 2.11.8 + + + 3.2.2 + + + default + + benchmarks @@ -102,7 +136,7 @@ THE POSSIBILITY OF SUCH DAMAGE. net.alchim31.maven scala-maven-plugin - 3.1.6 + \${scala.mavenPlugin.version} incremental diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/archetype.properties b/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/archetype.properties new file mode 100644 index 000000000..72f4f0a13 --- /dev/null +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/archetype.properties @@ -0,0 +1,4 @@ +groupId=org.openjdk.jmh +artifactId=jmh-scala-benchmark-archetype-test +version=1.0-SNAPSHOT +package=org.openjdk.jmh diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/goal.txt b/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/goal.txt new file mode 100644 index 000000000..4a1a71d33 --- /dev/null +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/src/test/resources/projects/test/goal.txt @@ -0,0 +1 @@ +verify \ No newline at end of file From 4a35884bbfa61ca9994897ff2996ef0e0d6617c4 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Jul 2016 15:20:54 +0300 Subject: [PATCH 016/342] 7901743: @State DAG machinery miscompiles/rejects valid DAGs --- .../ExplicitCycleBenchmarkTest.java} | 6 +- .../ExplicitCycleThreadTest.java} | 6 +- .../cycles/ImplicitCycleBenchmarkTest.java | 60 ++++++++++ .../dag/cycles/ImplicitCycleThreadTest.java | 60 ++++++++++ .../dag/doublets/BenchmarkBenchmarkTest.java | 60 ++++++++++ .../dag/doublets/BenchmarkThreadTest.java | 60 ++++++++++ .../dag/doublets/ThreadBenchmarkTest.java | 60 ++++++++++ .../states/dag/doublets/ThreadThreadTest.java | 60 ++++++++++ .../dag/implicit/BenchmarkBenchmarkTest.java | 56 ++++++++++ .../dag/implicit/BenchmarkThreadTest.java | 56 ++++++++++ .../dag/implicit/ThreadBenchmarkTest.java | 56 ++++++++++ .../states/dag/implicit/ThreadThreadTest.java | 56 ++++++++++ .../generators/core/BenchmarkGenerator.java | 10 +- .../jmh/generators/core/StateObject.java | 10 +- .../generators/core/StateObjectHandler.java | 105 +++++++++++------- 15 files changed, 667 insertions(+), 54 deletions(-) rename jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/{CycleBenchmarkTest.java => cycles/ExplicitCycleBenchmarkTest.java} (91%) rename jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/{CycleThreadTest.java => cycles/ExplicitCycleThreadTest.java} (91%) create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleBenchmarkTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleThreadTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkBenchmarkTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkThreadTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadBenchmarkTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadThreadTest.java diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleBenchmarkTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleBenchmarkTest.java similarity index 91% rename from jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleBenchmarkTest.java rename to jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleBenchmarkTest.java index fcfc9f154..e5b431c1b 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleBenchmarkTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleBenchmarkTest.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package org.openjdk.jmh.ct.states.dag; +package org.openjdk.jmh.ct.states.dag.cycles; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; @@ -31,7 +31,7 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; -public class CycleBenchmarkTest { +public class ExplicitCycleBenchmarkTest { @State(Scope.Benchmark) public static class B1 { @@ -56,7 +56,7 @@ public void test(B1 b1) { @Test public void compileTest() { - CompileTest.assertFail(this.getClass()); + CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected"); } } diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleThreadTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleThreadTest.java similarity index 91% rename from jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleThreadTest.java rename to jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleThreadTest.java index 9e4fefef1..8cec3f3eb 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/CycleThreadTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ExplicitCycleThreadTest.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package org.openjdk.jmh.ct.states.dag; +package org.openjdk.jmh.ct.states.dag.cycles; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; @@ -31,7 +31,7 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.ct.CompileTest; -public class CycleThreadTest { +public class ExplicitCycleThreadTest { @State(Scope.Thread) public static class B1 { @@ -56,7 +56,7 @@ public void test(B1 b1) { @Test public void compileTest() { - CompileTest.assertFail(this.getClass()); + CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected"); } } diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleBenchmarkTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleBenchmarkTest.java new file mode 100644 index 000000000..13e00a2d6 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleBenchmarkTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.cycles; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +@State(Scope.Benchmark) +public class ImplicitCycleBenchmarkTest { + + @State(Scope.Benchmark) + public static class B1 { + @Setup + public void setup(ImplicitCycleBenchmarkTest b1) { + + } + } + + @Setup + public void setup(B1 b1) { + + } + + @Benchmark + public void test() { + + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleThreadTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleThreadTest.java new file mode 100644 index 000000000..3ea476f63 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/ImplicitCycleThreadTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.cycles; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +@State(Scope.Thread) +public class ImplicitCycleThreadTest { + + @State(Scope.Thread) + public static class B1 { + @Setup + public void setup(ImplicitCycleThreadTest b1) { + + } + } + + @Setup + public void setup(B1 b1) { + + } + + @Benchmark + public void test() { + + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "@State dependency cycle is detected"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java new file mode 100644 index 000000000..5a8324def --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.doublets; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class BenchmarkBenchmarkTest { + + @State(Scope.Benchmark) + public static class L { + + } + + @State(Scope.Benchmark) + public static class G { + @Setup + public void setup(L l1) { + + } + } + + @Benchmark + public void test(G g1, G g2) { + + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java new file mode 100644 index 000000000..48985b940 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.doublets; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class BenchmarkThreadTest { + + @State(Scope.Benchmark) + public static class L { + + } + + @State(Scope.Thread) + public static class G { + @Setup + public void setup(L l1) { + + } + } + + @Benchmark + public void test(G g1, G g2) { + + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java new file mode 100644 index 000000000..0e04ec36e --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.doublets; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ThreadBenchmarkTest { + + @State(Scope.Thread) + public static class L { + + } + + @State(Scope.Benchmark) + public static class G { + @Setup + public void setup(L l1) { + + } + } + + @Benchmark + public void test(G g1, G g2) { + + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java new file mode 100644 index 000000000..d53b65b56 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.doublets; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ThreadThreadTest { + + @State(Scope.Thread) + public static class L { + + } + + @State(Scope.Thread) + public static class G { + @Setup + public void setup(L l1) { + + } + } + + @Benchmark + public void test(G g1, G g2) { + + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkBenchmarkTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkBenchmarkTest.java new file mode 100644 index 000000000..50d0d86c8 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkBenchmarkTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.implicit; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +@State(Scope.Benchmark) +public class BenchmarkBenchmarkTest { + + @State(Scope.Benchmark) + public static class L { + + } + + @Setup + public void setup(L l1) { + + } + + @Benchmark + public void test(BenchmarkBenchmarkTest state) {} + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkThreadTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkThreadTest.java new file mode 100644 index 000000000..cbc45088d --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/BenchmarkThreadTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.implicit; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +@State(Scope.Benchmark) +public class BenchmarkThreadTest { + + @State(Scope.Thread) + public static class L { + + } + + @Setup + public void setup(L l1) { + + } + + @Benchmark + public void test(BenchmarkThreadTest state) {} + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadBenchmarkTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadBenchmarkTest.java new file mode 100644 index 000000000..f9fc54ce7 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadBenchmarkTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.implicit; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +@State(Scope.Thread) +public class ThreadBenchmarkTest { + + @State(Scope.Benchmark) + public static class L { + + } + + @Setup + public void setup(L l1) { + + } + + @Benchmark + public void test(ThreadBenchmarkTest state) {} + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadThreadTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadThreadTest.java new file mode 100644 index 000000000..72f27b3be --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/implicit/ThreadThreadTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.implicit; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +@State(Scope.Thread) +public class ThreadThreadTest { + + @State(Scope.Thread) + public static class L { + + } + + @Setup + public void setup(L l1) { + + } + + @Benchmark + public void test(ThreadThreadTest state) {} + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 9ba2caaa2..9900cd46b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -271,6 +271,11 @@ private void validateBenchmark(ClassInfo clazz, Collection methods) StateObjectHandler.validateState(clazz); } + // validate no @State cycles + for (MethodInfo e : methods) { + StateObjectHandler.validateNoCycles(e); + } + // validate against rogue fields if (!explicitState || clazz.isAbstract()) { for (FieldInfo fi : BenchmarkGeneratorUtils.getAllFields(clazz)) { @@ -461,11 +466,8 @@ private Collection makeBenchmarkInfo(ClassInfo clazz, Collection< private void generateClass(GeneratorSource source, GeneratorDestination destination, ClassInfo classInfo, BenchmarkInfo info) throws IOException { StateObjectHandler states = new StateObjectHandler(compilerControl); - // benchmark instance is implicit - states.bindImplicit(classInfo, "bench", Scope.Thread); - // bind all methods - states.bindMethodGroup(info.methodGroup); + states.bindMethods(classInfo, info.methodGroup); // Create file and open an outputstream PrintWriter writer = new PrintWriter(destination.newClass(info.generatedClassQName), false); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java index fede15da0..b330b8ba1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java @@ -25,13 +25,11 @@ package org.openjdk.jmh.generators.core; import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.TreeMultimap; -import java.util.Collection; -import java.util.Comparator; -import java.util.SortedSet; -import java.util.TreeSet; +import java.util.*; class StateObject { @@ -50,6 +48,8 @@ public int compare(StateObject o1, StateObject o2) { public final String fieldIdentifier; public final Multimap params; public final SortedSet helpers; + public final Multimap helperArgs; + public final List depends; public StateObject(Identifiers identifiers, ClassInfo info, Scope scope) { this.packageName = info.getPackageName() + ".generated"; @@ -63,6 +63,8 @@ public StateObject(Identifiers identifiers, ClassInfo info, Scope scope) { this.params = new TreeMultimap(); this.helpers = new TreeSet(); + this.helperArgs = new HashMultimap(); + this.depends = new ArrayList(); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index e0e05ec37..5d6e36d5c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -48,10 +48,9 @@ class StateObjectHandler { private final Set stateObjects; private final Map implicits; - private final Multimap stateObjectDeps; + private final Multimap benchmarkArgs; - private final Multimap stateHelperArgs; private final Multimap auxNames = new HashMultimap(); private final Map auxAccessors = new HashMap(); @@ -63,8 +62,6 @@ public StateObjectHandler(CompilerControlPlugin compileControl) { this.implicits = new HashMap(); this.specials = new HashMultimap(); this.stateObjects = new HashSet(); - this.stateHelperArgs = new HashMultimap(); - this.stateObjectDeps = new HashMultimap(); this.identifiers = new Identifiers(); } @@ -178,13 +175,24 @@ public State getState(ClassInfo ci, ParameterInfo pi) { return ann; } - public void bindMethodGroup(MethodGroup mg) { + public void bindMethods(ClassInfo holder, MethodGroup mg) { for (MethodInfo method : mg.methods()) { - Set seen = new HashSet(); + // Bind the holder implicitly: + { + State ann = BenchmarkGeneratorUtils.getAnnSuper(holder, State.class); + Scope scope = (ann != null) ? ann.value() : Scope.Thread; + StateObject holderSo = new StateObject(identifiers, holder, scope); + stateObjects.add(holderSo); + implicits.put("bench", holderSo); + bindState(method, holderSo, holder); + + resolveDependencies(method, holder, holderSo); + } // Check that all arguments are states. validateStateArgs(method); + // Bind all @Benchmark parameters for (ParameterInfo ppi : method.getParameters()) { ClassInfo pci = ppi.getType(); @@ -198,9 +206,41 @@ public void bindMethodGroup(MethodGroup mg) { benchmarkArgs.put(method.getName(), pso.toLocal()); bindState(method, pso, pci); - seen.add(pso); + resolveDependencies(method, pci, pso); + } + } + } + } + + public static void validateNoCycles(MethodInfo method) { + try { + validateNoCyclesStep(Collections.emptyList(), method, true); + } catch (StackOverflowError e) { + // "YOLO Engineering" + throw new GenerationException("@" + State.class.getSimpleName() + + " dependency cycle is detected.", method); + } + } - recursiveStateResolve(method, pci, pso, seen); + private static void validateNoCyclesStep(List states, MethodInfo method, boolean includeHolder) { + List stratum = new ArrayList(); + if (includeHolder) { + stratum.add(method.getDeclaringClass()); + } + for (ParameterInfo ppi : method.getParameters()) { + stratum.add(ppi.getType()); + } + + List newStates = new ArrayList(); + newStates.addAll(states); + for (ClassInfo ci : stratum) { + newStates.add(ci.getQualifiedName()); + } + + for (ClassInfo ci : stratum) { + for (MethodInfo mi : BenchmarkGeneratorUtils.getMethods(ci)) { + if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) { + validateNoCyclesStep(newStates, mi, false); } } } @@ -209,7 +249,7 @@ public void bindMethodGroup(MethodGroup mg) { /** * Recursively resolve if there are any other states referenced through helper methods. */ - private void recursiveStateResolve(MethodInfo method, ClassInfo pci, StateObject pso, Set seen) { + private void resolveDependencies(MethodInfo method, ClassInfo pci, StateObject pso) { for (MethodInfo mi : BenchmarkGeneratorUtils.getMethods(pci)) { if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) { @@ -217,21 +257,18 @@ private void recursiveStateResolve(MethodInfo method, ClassInfo pci, StateObject ClassInfo ci = pi.getType(); if (isSpecialClass(ci)) { - stateHelperArgs.put(mi.getQualifiedName(), getSpecialClassAccessor(ci)); + pso.helperArgs.put(mi.getQualifiedName(), getSpecialClassAccessor(ci)); specials.put(mi.getQualifiedName(), ci); } else { StateObject so = new StateObject(identifiers, ci, getState(ci, pi).value()); - if (!seen.add(so)) { - throw new GenerationException("@" + State.class.getSimpleName() + " dependency cycle is detected.", pi); - } - - if (!stateHelperArgs.get(mi.getQualifiedName()).contains(so.toLocal())) { + if (!pso.helperArgs.get(mi.getQualifiedName()).contains(so.toLocal())) { stateObjects.add(so); - stateObjectDeps.put(pso, so); - stateHelperArgs.put(mi.getQualifiedName(), so.toLocal()); + pso.depends.add(so); + pso.helperArgs.put(mi.getQualifiedName(), so.toLocal()); + bindState(method, so, ci); - recursiveStateResolve(method, ci, so, seen); + resolveDependencies(method, ci, so); } } } @@ -239,18 +276,6 @@ private void recursiveStateResolve(MethodInfo method, ClassInfo pci, StateObject } } - - public void bindImplicit(ClassInfo ci, String label, Scope scope) { - State ann = BenchmarkGeneratorUtils.getAnnSuper(ci, State.class); - StateObject so = new StateObject(identifiers, ci, (ann != null) ? ann.value() : scope); - stateObjects.add(so); - implicits.put(label, so); - bindState(null, so, ci); - - Set seen = new HashSet(); - recursiveStateResolve(null, ci, so, seen); - } - private void bindState(MethodInfo execMethod, StateObject so, ClassInfo ci) { // Check it is a valid state validateState(ci); @@ -549,7 +574,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H if (type == HelperType.SETUP) { for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) { - Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); + Collection args = so.helperArgs.get(mi.method.getQualifiedName()); result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } @@ -562,7 +587,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H if (type == HelperType.TEARDOWN) { for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) { - Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); + Collection args = so.helperArgs.get(mi.method.getQualifiedName()); result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } @@ -579,7 +604,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H result.add(" if (!" + so.localIdentifier + ".ready" + helperLevel + ") {"); for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) { - Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); + Collection args = so.helperArgs.get(mi.method.getQualifiedName()); result.add(" " + so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } @@ -605,7 +630,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H result.add(" if (" + so.localIdentifier + ".ready" + helperLevel + ") {"); for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) { - Collection args = stateHelperArgs.get(mi.method.getQualifiedName()); + Collection args = so.helperArgs.get(mi.method.getQualifiedName()); result.add(" " + so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); } } @@ -702,7 +727,7 @@ public List getStateInitializers() { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel != Level.Trial) continue; if (hmi.type != HelperType.SETUP) continue; - Collection args = stateHelperArgs.get(hmi.method.getQualifiedName()); + Collection args = so.helperArgs.get(hmi.method.getQualifiedName()); result.add(" val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");"); } result.add(" val.ready" + Level.Trial + " = true;"); @@ -737,7 +762,7 @@ public List getStateInitializers() { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel != Level.Trial) continue; if (hmi.type != HelperType.SETUP) continue; - Collection args = stateHelperArgs.get(hmi.method.getQualifiedName()); + Collection args = so.helperArgs.get(hmi.method.getQualifiedName()); result.add(" val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");"); } result.add(" " + so.fieldIdentifier + " = val;"); @@ -777,7 +802,7 @@ public List getStateInitializers() { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel != Level.Trial) continue; if (hmi.type != HelperType.SETUP) continue; - Collection args = stateHelperArgs.get(hmi.method.getQualifiedName()); + Collection args = so.helperArgs.get(hmi.method.getQualifiedName()); result.add(" val." + hmi.method.getName() + "(" + Utils.join(args, ",") + ");"); } result.add(" " + "val.ready" + Level.Trial + " = true;"); @@ -790,11 +815,11 @@ public List getStateInitializers() { } private String soDependency_TypeArgs(StateObject so) { - return (stateObjectDeps.get(so).isEmpty() ? "" : ", " + getTypeArgList(stateObjectDeps.get(so))); + return (so.depends.isEmpty() ? "" : ", " + getTypeArgList(so.depends)); } private String soDependency_Args(StateObject so) { - return (stateObjectDeps.get(so).isEmpty() ? "" : ", " + getArgList(stateObjectDeps.get(so))); + return (so.depends.isEmpty() ? "" : ", " + getArgList(so.depends)); } public Collection getStateDestructors(MethodInfo method) { @@ -845,7 +870,7 @@ private LinkedHashSet stateOrder(MethodInfo method, boolean reverse linearOrder.addAll(stratum); List newStratum = new ArrayList(); for (StateObject so : stratum) { - newStratum.addAll(stateObjectDeps.get(so)); + newStratum.addAll(so.depends); } stratum = newStratum; } From 77d3a61c4517990e0c9a446c7f7a47b244e3ee57 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Jul 2016 18:06:15 +0300 Subject: [PATCH 017/342] 7901744: Archetype verification should be enabled only on Java 8 --- .../jmh-groovy-benchmark-archetype/pom.xml | 19 ++---- .../jmh-java-benchmark-archetype/pom.xml | 19 ++---- .../jmh-kotlin-benchmark-archetype/pom.xml | 19 ++---- .../jmh-scala-benchmark-archetype/pom.xml | 19 ++---- jmh-archetypes/pom.xml | 62 +++++++++++++++++++ 5 files changed, 82 insertions(+), 56 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 390aa7cd1..a8f009158 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -8,7 +8,6 @@ 1.13-SNAPSHOT - org.openjdk.jmh jmh-groovy-benchmark-archetype maven-archetype @@ -27,25 +26,17 @@ - - - - maven-archetype-plugin - 2.2 - - - - + + org.apache.maven.plugins + maven-archetype-plugin + org.apache.maven.plugins maven-resources-plugin - 2.5 - - \ - + src/main/resources diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index d291a5acc..dc8ce9f79 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -33,7 +33,6 @@ questions. 1.13-SNAPSHOT - org.openjdk.jmh jmh-java-benchmark-archetype maven-archetype @@ -52,25 +51,17 @@ questions. - - - - maven-archetype-plugin - 2.2 - - - - + + org.apache.maven.plugins + maven-archetype-plugin + org.apache.maven.plugins maven-resources-plugin - 2.5 - - \ - + src/main/resources diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 01014942f..58ee8abaa 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -8,7 +8,6 @@ 1.13-SNAPSHOT - org.openjdk.jmh jmh-kotlin-benchmark-archetype maven-archetype @@ -27,25 +26,17 @@ - - - - maven-archetype-plugin - 2.2 - - - - + + org.apache.maven.plugins + maven-archetype-plugin + org.apache.maven.plugins maven-resources-plugin - 2.5 - - \ - + src/main/resources diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index ea49d3158..c46c75897 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -8,7 +8,6 @@ 1.13-SNAPSHOT - org.openjdk.jmh jmh-scala-benchmark-archetype maven-archetype @@ -27,25 +26,17 @@ - - - - maven-archetype-plugin - 2.2 - - - - + + org.apache.maven.plugins + maven-archetype-plugin + org.apache.maven.plugins maven-resources-plugin - 2.5 - - \ - + src/main/resources diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index e3fdd7ec6..9c05e0cc6 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -45,6 +45,68 @@ questions. UTF-8 + + + jdk8 + + 1.8 + + + + + + maven-archetype-plugin + 2.2 + + integration-test + + + false + + + + + + + + others + + true + + + + + + maven-archetype-plugin + 2.2 + + integration-test + + + true + + + + + + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + \ + + + + + + jmh-java-benchmark-archetype jmh-scala-benchmark-archetype From d9cf6089c4a75ff2833fec239ca52822dee0a2e3 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Jul 2016 21:18:12 +0300 Subject: [PATCH 018/342] 7901745: perfasm treats address lines in the region print margin as intrajump --- .../jmh/profile/AbstractPerfAsmProfiler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 01a136a4f..fc031f0f3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -1097,12 +1097,22 @@ public void printCode(PrintWriter pw, PerfEvents events) { if (code.size() > threshold) { pw.printf(" %n", code.size(), threshold); } else { + long beginLine = begin; + long endLine = end; + for (ASMLine line : code) { + Long addr = line.addr; + if (addr != null) { + beginLine = Math.min(beginLine, addr); + endLine = Math.max(endLine, addr); + } + } + Set interIvs = new TreeSet(); Set intraIvs = new TreeSet(); for (Interval it : asms.intervals) { - boolean srcInline = (begin < it.src && it.src < end); - boolean dstInline = (begin < it.dst && it.dst < end); + boolean srcInline = (beginLine < it.src && it.src < endLine); + boolean dstInline = (beginLine < it.dst && it.dst < endLine); if (srcInline && dstInline) { if (drawInterJumps) { interIvs.add(it); From 3d9636b0b7dee049d3920896c5153f4804edf594 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Jul 2016 21:31:06 +0300 Subject: [PATCH 019/342] JMH v1.13 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index a8f009158..5f7ed6025 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.13-SNAPSHOT + 1.13 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index dc8ce9f79..bd1809570 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.13-SNAPSHOT + 1.13 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 58ee8abaa..0f53a4951 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.13-SNAPSHOT + 1.13 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index c46c75897..4b16a6277 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.13-SNAPSHOT + 1.13 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 9c05e0cc6..b09f09d7b 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index e96e9d083..8b90f0b59 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 119e422de..23223f139 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index db56852e0..bfb2bbd78 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index ede197b46..8d6060eea 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index db06f162c..3fbcc1bd5 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 9e7aee1c2..56389327c 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 270d9b0fd..f465f3710 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 021cc9726..6af5da4d3 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 335c3b6fc..5aa626674 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.13-SNAPSHOT + 1.13 JMH Samples diff --git a/pom.xml b/pom.xml index 1eb5ed95e..ab2acd820 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.13-SNAPSHOT + 1.13 Java Microbenchmark Harness Parent From fbffb37d0640ad14d9ffc2184d17d09a75f5bdec Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Jul 2016 21:31:11 +0300 Subject: [PATCH 020/342] Added tag 1.13 for changeset 7ff584954008 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 09182b2a3..a641975c0 100644 --- a/.hgtags +++ b/.hgtags @@ -75,3 +75,4 @@ c5a34103cbb32c8aee3d6b3a151f15819a4ea664 1.11 4778686520db8eae8a26f78f4df48fcf2710515b 1.11.2 534d83d9137f2231b889188f6bff02e541d1e7bd 1.11.3 eb41bdab96cf7579db48fc39a9fa423b54bf4786 1.12 +7ff584954008f5dc877c590df5d902a0022f7456 1.13 From 9b8ef6b9b94b4645e75878231212e59ee50bbc37 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Jul 2016 21:31:24 +0300 Subject: [PATCH 021/342] Continue in 1.14-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 5f7ed6025..7fc5bd478 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.13 + 1.14-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index bd1809570..adf6d7c2f 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.13 + 1.14-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 0f53a4951..3d593bc72 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.13 + 1.14-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 4b16a6277..e861b4894 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.13 + 1.14-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index b09f09d7b..37eec460a 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 8b90f0b59..5e7fd8306 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 23223f139..d5d0a2a69 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index bfb2bbd78..ffb66c130 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 8d6060eea..f406a6790 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 3fbcc1bd5..9415a3482 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 56389327c..8619a59e8 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index f465f3710..24a919666 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 6af5da4d3..4c9d4bb49 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 5aa626674..24ce60e79 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.13 + 1.14-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index ab2acd820..6a7b75a44 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.13 + 1.14-SNAPSHOT Java Microbenchmark Harness Parent From 3652d8ce2cf07770fdc2de929afb82278b0a8d2f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 26 Jul 2016 00:02:32 +0300 Subject: [PATCH 022/342] 7901746: Command line options help should list default values --- .../org/openjdk/jmh/runner/BenchmarkList.java | 2 +- .../java/org/openjdk/jmh/runner/Defaults.java | 6 ++ .../runner/options/ChainedOptionsBuilder.java | 23 ++++++ .../runner/options/CommandLineOptions.java | 72 ++++++++++++------- .../jmh/runner/options/OptionFormatter.java | 3 + 5 files changed, 81 insertions(+), 25 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java index e52490b29..aad29438c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java @@ -84,7 +84,7 @@ public SortedSet find(OutputFormat out, List include // assume we match all benchmarks when include is empty List regexps = new ArrayList(includes); if (regexps.isEmpty()) { - regexps.add(".*"); + regexps.add(Defaults.INCLUDE_BENCHMARKS); } // compile all patterns diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java index 1ddbb19b6..dd3718e72 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java @@ -146,4 +146,10 @@ public class Defaults { * Default timeout. */ public static final TimeValue TIMEOUT = TimeValue.minutes(10); + + /** + * Default benchmarks to include. + */ + public static final String INCLUDE_BENCHMARKS = ".*"; + } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ChainedOptionsBuilder.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ChainedOptionsBuilder.java index 1de3fac0b..c91cf475a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ChainedOptionsBuilder.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ChainedOptionsBuilder.java @@ -53,6 +53,7 @@ public interface ChainedOptionsBuilder { * * @param regexp to match benchmarks against * @return builder + * @see org.openjdk.jmh.runner.Defaults#INCLUDE_BENCHMARKS */ ChainedOptionsBuilder include(String regexp); @@ -69,6 +70,7 @@ public interface ChainedOptionsBuilder { * ResultFormatType to use in the run * @param type resultformat type * @return builder + * @see org.openjdk.jmh.runner.Defaults#RESULT_FORMAT */ ChainedOptionsBuilder resultFormat(ResultFormatType type); @@ -83,6 +85,7 @@ public interface ChainedOptionsBuilder { * Output filename to write the result to * @param filename file name * @return builder + * @see org.openjdk.jmh.runner.Defaults#RESULT_FILE_PREFIX */ ChainedOptionsBuilder result(String filename); @@ -90,6 +93,7 @@ public interface ChainedOptionsBuilder { * Should do GC between measurementIterations? * @param value flag * @return builder + * @see org.openjdk.jmh.runner.Defaults#DO_GC */ ChainedOptionsBuilder shouldDoGC(boolean value); @@ -127,6 +131,7 @@ public interface ChainedOptionsBuilder { * Control verbosity level. * @param mode flag * @return builder + * @see org.openjdk.jmh.runner.Defaults#VERBOSITY */ ChainedOptionsBuilder verbosity(VerboseMode mode); @@ -134,6 +139,7 @@ public interface ChainedOptionsBuilder { * Should fail on first benchmark error? * @param value flag * @return builder + * @see org.openjdk.jmh.runner.Defaults#FAIL_ON_ERROR */ ChainedOptionsBuilder shouldFailOnError(boolean value); @@ -142,6 +148,7 @@ public interface ChainedOptionsBuilder { * @param count number of threads * @return builder * @see org.openjdk.jmh.annotations.Threads + * @see org.openjdk.jmh.runner.Defaults#THREADS */ ChainedOptionsBuilder threads(int count); @@ -158,6 +165,7 @@ public interface ChainedOptionsBuilder { * Should synchronize measurementIterations? * @param value flag * @return builder + * @see org.openjdk.jmh.runner.Defaults#SYNC_ITERATIONS */ ChainedOptionsBuilder syncIterations(boolean value); @@ -166,6 +174,8 @@ public interface ChainedOptionsBuilder { * @param value flag * @return builder * @see org.openjdk.jmh.annotations.Warmup + * @see org.openjdk.jmh.runner.Defaults#WARMUP_ITERATIONS + * @see org.openjdk.jmh.runner.Defaults#WARMUP_ITERATIONS_SINGLESHOT */ ChainedOptionsBuilder warmupIterations(int value); @@ -174,6 +184,7 @@ public interface ChainedOptionsBuilder { * @param value batch size * @return builder * @see org.openjdk.jmh.annotations.Warmup + * @see org.openjdk.jmh.runner.Defaults#WARMUP_BATCHSIZE */ ChainedOptionsBuilder warmupBatchSize(int value); @@ -182,6 +193,7 @@ public interface ChainedOptionsBuilder { * @param value time * @return builder * @see org.openjdk.jmh.annotations.Warmup + * @see org.openjdk.jmh.runner.Defaults#WARMUP_TIME */ ChainedOptionsBuilder warmupTime(TimeValue value); @@ -189,6 +201,7 @@ public interface ChainedOptionsBuilder { * Warmup mode to use * @param mode to use * @return builder + * @see org.openjdk.jmh.runner.Defaults#WARMUP_MODE */ ChainedOptionsBuilder warmupMode(WarmupMode mode); @@ -204,6 +217,8 @@ public interface ChainedOptionsBuilder { * @param count number of iterations * @return builder * @see org.openjdk.jmh.annotations.Measurement + * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_ITERATIONS + * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_ITERATIONS_SINGLESHOT */ ChainedOptionsBuilder measurementIterations(int count); @@ -212,6 +227,7 @@ public interface ChainedOptionsBuilder { * @param value batch size * @return builder * @see org.openjdk.jmh.annotations.Measurement + * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_BATCHSIZE */ ChainedOptionsBuilder measurementBatchSize(int value); @@ -220,6 +236,7 @@ public interface ChainedOptionsBuilder { * @param value time * @return builder * @see org.openjdk.jmh.annotations.Measurement + * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_TIME */ ChainedOptionsBuilder measurementTime(TimeValue value); @@ -230,6 +247,7 @@ public interface ChainedOptionsBuilder { * @param mode benchmark mode * @return builder * @see org.openjdk.jmh.annotations.BenchmarkMode + * @see org.openjdk.jmh.runner.Defaults#BENCHMARK_MODE */ ChainedOptionsBuilder mode(Mode mode); @@ -238,6 +256,7 @@ public interface ChainedOptionsBuilder { * @param tu time unit * @return builder * @see org.openjdk.jmh.annotations.OutputTimeUnit + * @see org.openjdk.jmh.runner.Defaults#OUTPUT_TIMEUNIT */ ChainedOptionsBuilder timeUnit(TimeUnit tu); @@ -246,6 +265,7 @@ public interface ChainedOptionsBuilder { * @param value operations per invocation. * @return builder * @see org.openjdk.jmh.annotations.OperationsPerInvocation + * @see org.openjdk.jmh.runner.Defaults#OPS_PER_INVOCATION */ ChainedOptionsBuilder operationsPerInvocation(int value); @@ -254,6 +274,7 @@ public interface ChainedOptionsBuilder { * @param value number of forks * @return builder * @see org.openjdk.jmh.annotations.Fork + * @see org.openjdk.jmh.runner.Defaults#MEASUREMENT_FORKS */ ChainedOptionsBuilder forks(int value); @@ -262,6 +283,7 @@ public interface ChainedOptionsBuilder { * @param value number of ignored forks * @return builder * @see org.openjdk.jmh.annotations.Fork + * @see org.openjdk.jmh.runner.Defaults#WARMUP_FORKS */ ChainedOptionsBuilder warmupForks(int value); @@ -325,6 +347,7 @@ public interface ChainedOptionsBuilder { * How long to wait for iteration execution? * @param value time * @return builder + * @see org.openjdk.jmh.runner.Defaults#TIMEOUT */ ChainedOptionsBuilder timeout(TimeValue value); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java index 901e99e51..e01d263eb 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java @@ -28,6 +28,7 @@ import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.profile.ProfilerFactory; import org.openjdk.jmh.results.format.ResultFormatType; +import org.openjdk.jmh.runner.Defaults; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.Optional; @@ -92,70 +93,88 @@ public CommandLineOptions(String... argv) throws CommandLineOptionException { parser.formatHelpWith(new OptionFormatter()); OptionSpec optMeasureCount = parser.accepts("i", "Number of measurement iterations to do. " + - "Measurement iterations are counted towards the benchmark score.") + "Measurement iterations are counted towards the benchmark score. " + + "(default: " + Defaults.MEASUREMENT_ITERATIONS_SINGLESHOT + " for " + Mode.SingleShotTime + ", and " + + Defaults.MEASUREMENT_ITERATIONS + " for all other modes)") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int"); OptionSpec optMeasureBatchSize = parser.accepts("bs", "Batch size: number of benchmark method " + - "calls per operation. Some benchmark modes may ignore this setting, please check this separately.") + "calls per operation. Some benchmark modes may ignore this setting, please check this separately. " + + "(default: " + Defaults.MEASUREMENT_BATCHSIZE + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int"); OptionSpec optMeasureTime = parser.accepts("r", "Minimum time to spend at each measurement " + - "iteration. Benchmarks may generally run longer than iteration duration.") + "iteration. Benchmarks may generally run longer than iteration duration. " + + "(default: " + Defaults.MEASUREMENT_TIME + ")") .withRequiredArg().ofType(TimeValue.class).describedAs("time"); OptionSpec optWarmupCount = parser.accepts("wi", "Number of warmup iterations to do. Warmup " + - "iterations are not counted towards the benchmark score.") + "iterations are not counted towards the benchmark score. " + + "(default: " + Defaults.WARMUP_ITERATIONS_SINGLESHOT + " for " + Mode.SingleShotTime + ", and " + + Defaults.WARMUP_ITERATIONS + " for all other modes)") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.NON_NEGATIVE).describedAs("int"); OptionSpec optWarmupBatchSize = parser.accepts("wbs", "Warmup batch size: number of benchmark " + - "method calls per operation. Some benchmark modes may ignore this setting.") + "method calls per operation. Some benchmark modes may ignore this setting. " + + "(default: " + Defaults.WARMUP_BATCHSIZE + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int"); OptionSpec optWarmupTime = parser.accepts("w", "Minimum time to spend at each warmup iteration. " + - "Benchmarks may generally run longer than iteration duration.") + "Benchmarks may generally run longer than iteration duration. " + + "(default: " + Defaults.WARMUP_TIME + ")") .withRequiredArg().ofType(TimeValue.class).describedAs("time"); OptionSpec optTimeoutTime = parser.accepts("to", "Timeout for benchmark iteration. After reaching " + "this timeout, JMH will try to interrupt the running tasks. Non-cooperating benchmarks may ignore " + - "this timeout.") + "this timeout. " + + "(default: " + Defaults.TIMEOUT + ")") .withRequiredArg().ofType(TimeValue.class).describedAs("time"); OptionSpec optThreads = parser.accepts("t", "Number of worker threads to run with. 'max' means the " + - "maximum number of hardware threads available on the machine, figured out by JMH itself.") + "maximum number of hardware threads available on the machine, figured out by JMH itself. " + + "(default: " + Defaults.THREADS + ")") .withRequiredArg().withValuesConvertedBy(ThreadsValueConverter.INSTANCE).describedAs("int"); - OptionSpec optBenchmarkMode = parser.accepts("bm", "Benchmark mode. Available modes are: " + Mode.getKnown()) + OptionSpec optBenchmarkMode = parser.accepts("bm", "Benchmark mode. Available modes are: " + Mode.getKnown() + ". " + + "(default: " + Defaults.BENCHMARK_MODE + ")") .withRequiredArg().ofType(String.class).withValuesSeparatedBy(',').describedAs("mode"); OptionSpec optSyncIters = parser.accepts("si", "Should JMH synchronize iterations? This would " + "significantly lower the noise in multithreaded tests, by making sure the measured part happens only " + - "when all workers are running.") + "when all workers are running. " + + "(default: " + Defaults.SYNC_ITERATIONS + ")") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optGC = parser.accepts("gc", "Should JMH force GC between iterations? Forcing the GC may " + "help to lower the noise in GC-heavy benchmarks, at the expense of jeopardizing GC ergonomics " + - "decisions. Use with care.") + "decisions. Use with care. " + + "(default: " + Defaults.DO_GC + ")") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); OptionSpec optFOE = parser.accepts("foe", "Should JMH fail immediately if any benchmark had " + "experienced an unrecoverable error? This helps to make quick sanity tests for benchmark suites, as " + - "well as make the automated runs with checking error codes.") + "well as make the automated runs with checking error codes. " + + "(default: " + Defaults.FAIL_ON_ERROR + ")") .withRequiredArg().ofType(Boolean.class).describedAs("bool"); - OptionSpec optVerboseMode = parser.accepts("v", "Verbosity mode. Available modes are: " + Arrays.toString(VerboseMode.values())) + OptionSpec optVerboseMode = parser.accepts("v", "Verbosity mode. Available modes are: " + Arrays.toString(VerboseMode.values()) + ". " + + "(default: " + Defaults.VERBOSITY + ")") .withRequiredArg().ofType(String.class).describedAs("mode"); - OptionSpec optArgs = parser.nonOptions("Benchmarks to run (regexp+).") + OptionSpec optArgs = parser.nonOptions("Benchmarks to run (regexp+). " + + "(default: " + Defaults.INCLUDE_BENCHMARKS + ")") .describedAs("regexp+"); OptionSpec optForks = parser.accepts("f", "How many times to fork a single benchmark. Use 0 to " + "disable forking altogether. Warning: disabling forking may have detrimental impact on benchmark and " + - "infrastructure reliability, you might want to use different warmup mode instead.") + "infrastructure reliability, you might want to use different warmup mode instead. " + + "(default: " + Defaults.MEASUREMENT_FORKS + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.NON_NEGATIVE).describedAs("int"); OptionSpec optWarmupForks = parser.accepts("wf", "How many warmup forks to make for a single benchmark. " + "All iterations within the warmup fork are not counted towards the benchmark score. Use 0 to disable " + - "warmup forks.") + "warmup forks. " + + "(default: " + Defaults.WARMUP_FORKS + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.NON_NEGATIVE).describedAs("int"); OptionSpec optOutput = parser.accepts("o", "Redirect human-readable output to a given file.") @@ -163,7 +182,8 @@ public CommandLineOptions(String... argv) throws CommandLineOptionException { OptionSpec optOutputResults = parser.accepts("rff", "Write machine-readable results to a given file. " + "The file format is controlled by -rf option. Please see the list of result formats for available " + - "formats.") + "formats. " + + "(default: " + Defaults.RESULT_FILE_PREFIX + ".)") .withRequiredArg().ofType(String.class).describedAs("filename"); OptionSpec optProfilers = parser.accepts("prof", "Use profilers to collect additional benchmark data. " + @@ -195,19 +215,23 @@ public CommandLineOptions(String... argv) throws CommandLineOptionException { .withRequiredArg().ofType(String.class).describedAs("string"); OptionSpec optTU = parser.accepts("tu", "Override time unit in benchmark results. Available time units " + - "are: [m, s, ms, us, ns].") + "are: [m, s, ms, us, ns]. " + + "(default: " + Defaults.OUTPUT_TIMEUNIT + ")") .withRequiredArg().ofType(String.class).describedAs("TU"); OptionSpec optOPI = parser.accepts("opi", "Override operations per invocation, see " + - "@OperationsPerInvocation Javadoc for details.") + "@OperationsPerInvocation Javadoc for details. " + + "(default: " + Defaults.OPS_PER_INVOCATION + ")") .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int"); OptionSpec optResultFormat = parser.accepts("rf", "Format type for machine-readable results. These " + - "results are written to a separate file (see -rff). See the list of available result formats with -lrf.") + "results are written to a separate file (see -rff). See the list of available result formats with -lrf. " + + "(default: " + Defaults.RESULT_FORMAT +")") .withRequiredArg().ofType(String.class).describedAs("type"); OptionSpec optWarmupMode = parser.accepts("wm", "Warmup mode for warming up selected benchmarks. " + - "Warmup modes are: " + warmupModesDesc()) + "Warmup modes are: " + warmupModesDesc() + + "(default: " + Defaults.WARMUP_MODE + ")") .withRequiredArg().ofType(String.class).describedAs("mode"); OptionSpec optExcludes = parser.accepts("e", "Benchmarks to exclude from the run.") @@ -225,9 +249,9 @@ public CommandLineOptions(String... argv) throws CommandLineOptionException { parser.accepts("l", "List the benchmarks that match a filter, and exit."); parser.accepts("lp", "List the benchmarks that match a filter, along with parameters, and exit."); - parser.accepts("lrf", "List machine-readable result formats."); - parser.accepts("lprof", "List profilers."); - parser.accepts("h", "Display help."); + parser.accepts("lrf", "List machine-readable result formats, and exit."); + parser.accepts("lprof", "List profilers, and exit."); + parser.accepts("h", "Display help, and exit."); try { OptionSet set = parser.parse(argv); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionFormatter.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionFormatter.java index 4dd3119e2..caf72ac37 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionFormatter.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionFormatter.java @@ -44,6 +44,9 @@ public String format(Map options) { sb.append(" \"+\" means comma-separated list of values.\n"); sb.append(" \"time\" arguments accept time suffixes, like \"100ms\".\n"); sb.append("\n"); + sb.append("Command line options usually take precedence over annotations."); + sb.append("\n"); + sb.append("\n"); for (OptionDescriptor each : options.values()) { sb.append(lineFor(each)); } From 9ec2adea76ecab1463fafabdc91db080bced2536 Mon Sep 17 00:00:00 2001 From: Petr Stefan Date: Tue, 16 Aug 2016 16:18:15 +0300 Subject: [PATCH 023/342] 7901769: JSON output should include histogram data where available --- .../jmh/results/format/JSONResultFormat.java | 63 ++++++++++++++----- .../org/openjdk/jmh/util/ListStatistics.java | 27 ++++++++ .../openjdk/jmh/util/MultisetStatistics.java | 9 ++- .../openjdk/jmh/util/SingletonStatistics.java | 29 +++++++++ .../java/org/openjdk/jmh/util/Statistics.java | 13 ++++ .../main/java/org/openjdk/jmh/util/Utils.java | 16 +++++ .../openjdk/jmh/util/TestListStatistics.java | 18 ++++++ .../jmh/util/TestMultisetStatistics.java | 48 ++++++++++++++ .../jmh/util/TestSingletonStatistics.java | 16 +++++ .../jmh/results/format/output-golden.json | 12 ++-- 10 files changed, 225 insertions(+), 26 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java index 5dc00471a..8bf5c6edd 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java @@ -30,6 +30,7 @@ import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.util.Statistics; +import org.openjdk.jmh.util.Utils; import java.io.PrintStream; import java.io.PrintWriter; @@ -40,6 +41,9 @@ class JSONResultFormat implements ResultFormat { + private static final boolean PRINT_RAW_DATA = + Boolean.parseBoolean(System.getProperty("jmh.json.rawData", "true")); + private final PrintStream out; public JSONResultFormat(PrintStream out) { @@ -59,6 +63,7 @@ public void writeOut(Collection results) { if (first) { first = false; + pw.println(); } else { pw.println(","); } @@ -88,21 +93,19 @@ public void writeOut(Collection results) { pw.println("\"scoreConfidence\" : " + emit(primaryResult.getScoreConfidence()) + ","); pw.println(emitPercentiles(primaryResult.getStatistics())); pw.println("\"scoreUnit\" : \"" + primaryResult.getScoreUnit() + "\","); - pw.println("\"rawData\" :"); - { - Collection l1 = new ArrayList(); - for (BenchmarkResult benchmarkResult : runResult.getBenchmarkResults()) { - Collection scores = new ArrayList(); - for (IterationResult r : benchmarkResult.getIterationResults()) { - scores.add(emit(r.getPrimaryResult().getScore())); - } - l1.add(printMultiple(scores, "[", "]")); - } - pw.println(printMultiple(l1, "[", "]")); - pw.println("},"); + switch (params.getMode()) { + case SampleTime: + pw.println("\"rawDataHistogram\" :"); + pw.println(getRawData(runResult, true)); + break; + default: + pw.println("\"rawData\" :"); + pw.println(getRawData(runResult, false)); } + pw.println("},"); // primaryMetric end + Collection secondaries = new ArrayList(); for (Map.Entry e : runResult.getSecondaryResults().entrySet()) { String secondaryName = e.getKey(); @@ -137,14 +140,39 @@ public void writeOut(Collection results) { pw.println(printMultiple(secondaries, "", "")); pw.println("}"); - pw.println("}"); - + pw.print("}"); // benchmark end } pw.println("]"); out.println(tidy(sw.toString())); } + private String getRawData(RunResult runResult, boolean histogram) { + StringBuilder sb = new StringBuilder(); + Collection runs = new ArrayList(); + + if (PRINT_RAW_DATA) { + for (BenchmarkResult benchmarkResult : runResult.getBenchmarkResults()) { + Collection iterations = new ArrayList(); + for (IterationResult r : benchmarkResult.getIterationResults()) { + if (histogram) { + Collection singleIter = new ArrayList(); + for (Map.Entry item : Utils.adaptForLoop(r.getPrimaryResult().getStatistics().getRawData())) { + singleIter.add("< " + emit(item.getKey()) + "; " + item.getValue() + " >"); + } + iterations.add(printMultiple(singleIter, "[", "]")); + } else { + iterations.add(emit(r.getPrimaryResult().getScore())); + } + } + runs.add(printMultiple(iterations, "[", "]")); + } + } + sb.append(printMultiple(runs, "[", "]")); + + return sb.toString(); + } + private String emitParams(BenchmarkParams params) { StringBuilder sb = new StringBuilder(); boolean isFirst = true; @@ -218,6 +246,11 @@ private String tidy(String s) { s = s.replaceAll("\\}\n,\n", "},\n"); s = s.replaceAll("\n( *)\n", "\n"); + // Keep these inline: + s = s.replaceAll(";", ","); + s = s.replaceAll("\\<", "["); + s = s.replaceAll("\\>", "]"); + String[] lines = s.split("\n"); StringBuilder sb = new StringBuilder(); @@ -228,7 +261,7 @@ private String tidy(String s) { if (prevL != null && (prevL.endsWith("{") || prevL.endsWith("["))) { ident++; } - if (l.endsWith("}") || l.endsWith("]") || l.endsWith("},") || l.endsWith("],")) { + if (l.equals("}") || l.equals("]") || l.equals("},") || l.equals("],")) { ident--; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java index 4119ea91c..19ad96914 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java @@ -26,7 +26,10 @@ import org.apache.commons.math3.stat.descriptive.rank.Percentile; +import java.util.AbstractMap; import java.util.Arrays; +import java.util.Iterator; +import java.util.Map; /** * Calculate statistics over a list of doubles. @@ -149,6 +152,11 @@ public int[] getHistogram(double[] levels) { return result; } + @Override + public Iterator> getRawData() { + return new ListStatisticsIterator(); + } + @Override public double getVariance() { if (count > 1) { @@ -163,4 +171,23 @@ public double getVariance() { } } + private class ListStatisticsIterator implements Iterator> { + private int currentIndex = 0; + + @Override + public boolean hasNext() { + return currentIndex < count; + } + + @Override + public Map.Entry next() { + return new AbstractMap.SimpleImmutableEntry(values[currentIndex++], 1L); + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Element cannot be removed."); + } + } + } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java index a1533e4ae..4192dcab5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java @@ -24,9 +24,7 @@ */ package org.openjdk.jmh.util; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; public class MultisetStatistics extends AbstractStatistics { private static final long serialVersionUID = -4401871054963903938L; @@ -136,4 +134,9 @@ public int[] getHistogram(double[] levels) { return result; } + + @Override + public Iterator> getRawData() { + return values.entrySet().iterator(); + } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java index 939aa35b3..527a9e8e6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java @@ -24,6 +24,10 @@ */ package org.openjdk.jmh.util; +import java.util.AbstractMap; +import java.util.Iterator; +import java.util.Map; + /** * Calculate statistics with just a single value. */ @@ -78,4 +82,29 @@ public int[] getHistogram(double[] levels) { } return result; } + + @Override + public Iterator> getRawData() { + return new SingletonStatisticsIterator(); + } + + private class SingletonStatisticsIterator implements Iterator> { + private boolean entryReturned = false; + + @Override + public boolean hasNext() { + return !entryReturned; + } + + @Override + public Map.Entry next() { + entryReturned = true; + return new AbstractMap.SimpleImmutableEntry(value, 1L); + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Element cannot be removed."); + } + } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Statistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Statistics.java index 18b14c7ab..445f71827 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Statistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Statistics.java @@ -27,6 +27,9 @@ import org.apache.commons.math3.stat.descriptive.StatisticalSummary; import java.io.Serializable; +import java.util.Iterator; +import java.util.Map.Entry; + public interface Statistics extends Serializable, StatisticalSummary, Comparable { @@ -133,4 +136,14 @@ public interface Statistics extends Serializable, StatisticalSummary, Comparable * @return histogram data */ int[] getHistogram(double[] levels); + + /** + * Returns the raw data for this statistics. This data can be useful for + * custom postprocessing and statistics computations. Note, that values of + * multiple calls may not be unique. Ordering of the values is not specified. + * + * @return iterator to raw data. Each item is pair of actual value and + * number of occurrences of this value. + */ + Iterator> getRawData(); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index da8fbb71b..0ed330dbf 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -477,4 +477,20 @@ public static Collection runWith(List cmd) { return messages; } + /** + * Adapts Iterator for Iterable. + * Can be iterated only once! + * + * @param it iterator + * @return iterable for given iterator + */ + public static Iterable adaptForLoop(final Iterator it) { + return new Iterable() { + @Override + public Iterator iterator() { + return it; + } + }; + } + } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java index 819c83e66..2242b4e7a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java @@ -28,6 +28,9 @@ import org.junit.BeforeClass; import org.junit.Test; +import java.util.Iterator; +import java.util.Map; + import static org.junit.Assert.assertEquals; /** @@ -392,4 +395,19 @@ public strictfp void testHistogram_increasing() { ); } + /** + * Test of iterator which make accessible raw data. + */ + @Test + public strictfp void testRawDataIterator() { + Iterator> listIter = instance.getRawData(); + for (double item : VALUES) { + Assert.assertTrue(listIter.hasNext()); + Map.Entry entry = listIter.next(); + Assert.assertEquals(entry.getKey(), item); + Assert.assertEquals(entry.getValue().longValue(), 1L); + } + Assert.assertFalse(listIter.hasNext()); + } + } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java index 88a7c0654..cd0eb052a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java @@ -28,6 +28,8 @@ import org.junit.BeforeClass; import org.junit.Test; +import java.util.Map; + import static org.junit.Assert.assertEquals; /** @@ -385,4 +387,50 @@ public strictfp void testHistogram_increasing() { ); } + /** + * Test of iterator which make accessible raw data. + * Iterate over default instance with no duplicates. + */ + @Test + public strictfp void testRawDataIterator_no_duplicates() { + int itemCount = 0; + for (Map.Entry entry : Utils.adaptForLoop(instance.getRawData())) { + Assert.assertEquals(entry.getValue().longValue(), 1L); + + // Check if key (the actual data) is in the VALUES collection, + // else fail the test (the Multiset was constructed with values + // from VALUES collection, so it should be there). + boolean keyIsPresent = false; + double key = entry.getKey(); + for (double value : VALUES) { + if (Double.compare(value, key) == 0) { + keyIsPresent = true; + } + } + Assert.assertTrue("Value from iterator is not present in source collection", keyIsPresent); + + itemCount++; + } + Assert.assertEquals(itemCount, VALUES.length); + } + + /** + * Test of iterator which make accessible raw data. + * Iterate over new instance with duplicates. + */ + @Test + public strictfp void testRawDataIterator_duplicates() { + MultisetStatistics s = new MultisetStatistics(); + for (int c = 0; c <= 10; c++) { + s.addValue(c * 10, c); + } + + int itemCount = 0; + for (Map.Entry entry : Utils.adaptForLoop(s.getRawData())) { + Assert.assertEquals(entry.getKey(), (double)(entry.getValue() * 10)); + itemCount++; + } + Assert.assertEquals(itemCount, 10); + } + } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java index 7ba95a9db..a96bf985a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java @@ -28,6 +28,9 @@ import org.junit.BeforeClass; import org.junit.Test; +import java.util.Iterator; +import java.util.Map; + import static org.junit.Assert.assertEquals; /** @@ -245,4 +248,17 @@ public strictfp void testHistogram_emptyLevels_middle() { ); } + /** + * Test of iterator which make accessible raw data. + */ + @Test + public strictfp void testRawDataIterator() { + Iterator> singIter = singStats.getRawData(); + Assert.assertTrue(singIter.hasNext()); + Map.Entry entry = singIter.next(); + Assert.assertEquals(entry.getKey(), VALUE); + Assert.assertEquals(entry.getValue().longValue(), 1L); + Assert.assertFalse(singIter.hasNext()); + } + } diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json index 706e75907..a42cb7864 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json @@ -214,8 +214,7 @@ ] } } - } - , + }, { "benchmark" : "benchmark_1", "mode" : "thrpt", @@ -314,8 +313,7 @@ ] } } - } - , + }, { "benchmark" : "benchmark_2", "mode" : "thrpt", @@ -476,8 +474,7 @@ ] } } - } - , + }, { "benchmark" : "benchmark_3", "mode" : "thrpt", @@ -670,8 +667,7 @@ ] } } - } - , + }, { "benchmark" : "benchmark_4", "mode" : "thrpt", From a2faed68da8a0c83d5ba79f3357f11eaaad0dac5 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 5 Sep 2016 10:37:29 +0300 Subject: [PATCH 024/342] 7901779: JMH APT processor claims all annotations Should only capture JMH annotations. --- .../jmh/it/annsteal/CustomAnnotation.java | 35 +++++++++ .../it/annsteal/CustomBenchmarkProcessor.java | 71 +++++++++++++++++++ .../openjdk/jmh/it/annsteal/CustomTest.java | 53 ++++++++++++++ .../javax.annotation.processing.Processor | 28 ++++++++ .../jmh/generators/BenchmarkProcessor.java | 2 +- 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomAnnotation.java create mode 100644 jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomBenchmarkProcessor.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java create mode 100644 jmh-core-it/src/test/resources/META-INF/services/javax.annotation.processing.Processor diff --git a/jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomAnnotation.java b/jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomAnnotation.java new file mode 100644 index 000000000..2c6074b13 --- /dev/null +++ b/jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomAnnotation.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.annsteal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomAnnotation { +} diff --git a/jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomBenchmarkProcessor.java b/jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomBenchmarkProcessor.java new file mode 100644 index 000000000..0b59ac841 --- /dev/null +++ b/jmh-core-it/src/main/java/org/openjdk/jmh/it/annsteal/CustomBenchmarkProcessor.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.annsteal; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.tools.FileObject; +import javax.tools.StandardLocation; +import java.io.IOException; +import java.io.Writer; +import java.util.Set; + +@SupportedAnnotationTypes("*") +public class CustomBenchmarkProcessor extends AbstractProcessor { + + public static final String CBP_LIST = "tmp/CBP.list"; + + @Override + public SourceVersion getSupportedSourceVersion() { + // We may claim to support the latest version, since we are not using + // any version-specific extensions. + return SourceVersion.latest(); + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (TypeElement te : annotations) { + if (te.getQualifiedName().toString().equals(CustomAnnotation.class.getCanonicalName())) { + try { + FileObject file = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", CBP_LIST); + Writer writer = file.openWriter(); + Set els = roundEnv.getElementsAnnotatedWith(te); + for (Element el : els) { + writer.append(el.getSimpleName()); + } + writer.close(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + } + return false; + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java new file mode 100644 index 000000000..e5eec014d --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.annsteal; + +import org.junit.Test; +import org.junit.Assert; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.util.FileUtils; +import org.openjdk.jmh.util.Utils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collection; + +@CustomAnnotation // here! +public class CustomTest { + + @Benchmark + public void bench() { + // intentionally left blank + } + + @Test + public void test() throws IOException { + File file = FileUtils.extractFromResource('/' + CustomBenchmarkProcessor.CBP_LIST); + Collection strings = FileUtils.readAllLines(file); + Assert.assertTrue(strings.contains(CustomTest.class.getSimpleName())); + } + +} diff --git a/jmh-core-it/src/test/resources/META-INF/services/javax.annotation.processing.Processor b/jmh-core-it/src/test/resources/META-INF/services/javax.annotation.processing.Processor new file mode 100644 index 000000000..add9c8464 --- /dev/null +++ b/jmh-core-it/src/test/resources/META-INF/services/javax.annotation.processing.Processor @@ -0,0 +1,28 @@ +# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# The order of these two processors is important: we want the JMH's processor +# to fire first, and then see if it claims all JMH annotations, and nothing else. +org.openjdk.jmh.generators.BenchmarkProcessor +org.openjdk.jmh.it.annsteal.CustomBenchmarkProcessor \ No newline at end of file diff --git a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/BenchmarkProcessor.java b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/BenchmarkProcessor.java index a8f01d6a4..2f6200b21 100644 --- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/BenchmarkProcessor.java +++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/BenchmarkProcessor.java @@ -38,7 +38,7 @@ import javax.lang.model.element.TypeElement; import java.util.Set; -@SupportedAnnotationTypes("*") +@SupportedAnnotationTypes("org.openjdk.jmh.annotations.*") public class BenchmarkProcessor extends AbstractProcessor { private final BenchmarkGenerator generator = new BenchmarkGenerator(); From 88496961f43b27dc94fbaed05b0060ec21d629f0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 7 Sep 2016 10:19:25 +0300 Subject: [PATCH 025/342] 7901781: Benchmark results should be able to produce the derivative results --- .../generators/core/BenchmarkGenerator.java | 24 ++++-- .../jmh/profile/AbstractHotspotProfiler.java | 8 +- .../jmh/profile/ClassloaderProfiler.java | 12 ++- .../openjdk/jmh/profile/CompilerProfiler.java | 8 +- .../org/openjdk/jmh/profile/GCProfiler.java | 21 +++-- .../profile/HotspotCompilationProfiler.java | 28 ++++--- .../jmh/profile/HotspotRuntimeProfiler.java | 24 +++--- .../jmh/profile/HotspotThreadProfiler.java | 10 +-- .../jmh/profile/LinuxPerfNormProfiler.java | 40 +--------- .../jmh/profile/LinuxPerfProfiler.java | 9 ++- .../jmh/profile/ProfilerResultAggregator.java | 47 ----------- .../openjdk/jmh/results/BenchmarkResult.java | 28 +++++-- .../jmh/{profile => results}/Defaults.java | 4 +- .../openjdk/jmh/results/IterationResult.java | 26 +++++-- .../java/org/openjdk/jmh/results/Result.java | 11 +++ .../org/openjdk/jmh/results/ResultRole.java | 11 ++- .../openjdk/jmh/results/SampleTimeResult.java | 31 +++----- .../jmh/results/ScalarDerivativeResult.java | 78 +++++++++++++++++++ .../ScalarResult.java} | 43 ++++++---- .../jmh/results/TestBenchmarkResult.java | 26 +++++++ 20 files changed, 287 insertions(+), 202 deletions(-) delete mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResultAggregator.java rename jmh-core/src/main/java/org/openjdk/jmh/{profile => results}/Defaults.java (95%) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/results/ScalarDerivativeResult.java rename jmh-core/src/main/java/org/openjdk/jmh/{profile/ProfilerResult.java => results/ScalarResult.java} (54%) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 9900cd46b..f6f826a87 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -648,8 +648,10 @@ private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode be writer.println(ident(3) + "res.measuredOps /= batchSize;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);"); - writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); - if (!isSingleMethod) { + if (isSingleMethod) { + writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); + } else { + writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } for (String ops : states.getAuxResultNames(method)) { @@ -774,8 +776,10 @@ private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode b writer.println(ident(3) + "res.measuredOps /= batchSize;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);"); - writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); - if (!isSingleMethod) { + if (isSingleMethod) { + writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); + } else { + writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } for (String ops : states.getAuxResultNames(method)) { @@ -928,8 +932,10 @@ private void generateSampleTime(ClassInfo classInfo, PrintWriter writer, Mode be writer.println(ident(3) + "res.measuredOps *= opsPerInv;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);"); - writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); - if (!isSingleMethod) { + if (isSingleMethod) { + writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); + } else { + writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); } methodEpilog(writer, methodGroup); @@ -1030,8 +1036,10 @@ private void generateSingleShotTime(ClassInfo classInfo, PrintWriter writer, Mod writer.println(ident(3) + "long totalOps = opsPerInv;"); writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);"); - writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); - if (!isSingleMethod) { + if (isSingleMethod) { + writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); + } else { + writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); } methodEpilog(writer, methodGroup); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java index 8b801aaa8..b9db80651 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java @@ -26,9 +26,7 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.AggregationPolicy; -import org.openjdk.jmh.results.IterationResult; -import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.*; import sun.management.counter.Counter; import java.lang.reflect.InvocationTargetException; @@ -55,9 +53,9 @@ public AbstractHotspotProfiler() throws ProfilerException { @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { HotspotInternalResult res = counters(); - Collection results = new ArrayList(); + Collection results = new ArrayList(); for (Map.Entry e : res.getDiff().entrySet()) { - results.add(new ProfilerResult(Defaults.PREFIX + "." + e.getKey(), e.getValue(), "?", AggregationPolicy.AVG)); + results.add(new ScalarResult(Defaults.PREFIX + e.getKey(), e.getValue(), "?", AggregationPolicy.AVG)); } return results; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java index b0e9c5677..ed8a972de 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java @@ -26,9 +26,7 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.AggregationPolicy; -import org.openjdk.jmh.results.IterationResult; -import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.*; import java.lang.management.ClassLoadingMXBean; import java.lang.management.ManagementFactory; @@ -81,8 +79,8 @@ public Collection afterIteration(BenchmarkParams benchmarkPara try { long loadedClassCount = cl.getTotalLoadedClassCount(); long loaded = loadedClassCount - loadedClasses; - results.add(new ProfilerResult(Defaults.PREFIX + "class.load", loaded / time, "classes/sec", AggregationPolicy.AVG)); - results.add(new ProfilerResult(Defaults.PREFIX + "class.load.norm", 1.0 * loaded / allOps, "classes/op", AggregationPolicy.AVG)); + results.add(new ScalarResult(Defaults.PREFIX + "class.load", loaded / time, "classes/sec", AggregationPolicy.AVG)); + results.add(new ScalarResult(Defaults.PREFIX + "class.load.norm", 1.0 * loaded / allOps, "classes/op", AggregationPolicy.AVG)); } catch (UnsupportedOperationException e) { // do nothing } @@ -90,8 +88,8 @@ public Collection afterIteration(BenchmarkParams benchmarkPara try { long unloadedClassCount = cl.getUnloadedClassCount(); long unloaded = unloadedClassCount - unloadedClasses; - results.add(new ProfilerResult(Defaults.PREFIX + "class.unload", unloaded / time, "classes/sec", AggregationPolicy.AVG)); - results.add(new ProfilerResult(Defaults.PREFIX + "class.unload.norm", 1.0 * unloaded / allOps, "classes/op", AggregationPolicy.AVG)); + results.add(new ScalarResult(Defaults.PREFIX + "class.unload", unloaded / time, "classes/sec", AggregationPolicy.AVG)); + results.add(new ScalarResult(Defaults.PREFIX + "class.unload.norm", 1.0 * unloaded / allOps, "classes/op", AggregationPolicy.AVG)); } catch (UnsupportedOperationException e) { // do nothing diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/CompilerProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/CompilerProfiler.java index 9a901aa43..705255a18 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/CompilerProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/CompilerProfiler.java @@ -26,9 +26,7 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.AggregationPolicy; -import org.openjdk.jmh.results.IterationResult; -import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.*; import java.lang.management.CompilationMXBean; import java.lang.management.ManagementFactory; @@ -68,8 +66,8 @@ public Collection afterIteration(BenchmarkParams benchmarkPara try { long curTime = comp.getTotalCompilationTime(); return Arrays.asList( - new ProfilerResult(Defaults.PREFIX + "compiler.time.profiled", curTime - startCompTime, "ms", AggregationPolicy.SUM), - new ProfilerResult(Defaults.PREFIX + "compiler.time.total", curTime, "ms", AggregationPolicy.MAX) + new ScalarResult(Defaults.PREFIX + "compiler.time.profiled", curTime - startCompTime, "ms", AggregationPolicy.SUM), + new ScalarResult(Defaults.PREFIX + "compiler.time.total", curTime, "ms", AggregationPolicy.MAX) ); } catch (UnsupportedOperationException e) { return Collections.emptyList(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java index af710053a..a96528b35 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java @@ -26,9 +26,7 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.AggregationPolicy; -import org.openjdk.jmh.results.IterationResult; -import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.*; import org.openjdk.jmh.util.HashMultiset; import org.openjdk.jmh.util.Multiset; @@ -86,25 +84,25 @@ public Collection afterIteration(BenchmarkParams benchmarkPara gcTime += bean.getCollectionTime(); } - List results = new ArrayList(); + List results = new ArrayList(); if (beforeAllocated == HotspotAllocationSnapshot.EMPTY) { // When allocation profiling fails, make sure it is distinguishable in report - results.add(new ProfilerResult(Defaults.PREFIX + "gc.alloc.rate", + results.add(new ScalarResult(Defaults.PREFIX + "gc.alloc.rate", Double.NaN, "MB/sec", AggregationPolicy.AVG)); } else { HotspotAllocationSnapshot newSnapshot = VMSupport.getSnapshot(); long allocated = newSnapshot.subtract(beforeAllocated); // When no allocations measured, we still need to report results to avoid user confusion - results.add(new ProfilerResult(Defaults.PREFIX + "gc.alloc.rate", + results.add(new ScalarResult(Defaults.PREFIX + "gc.alloc.rate", (afterTime != beforeTime) ? 1.0 * allocated / 1024 / 1024 * TimeUnit.SECONDS.toNanos(1) / (afterTime - beforeTime) : Double.NaN, "MB/sec", AggregationPolicy.AVG)); if (allocated != 0) { long allOps = iResult.getMetadata().getAllOps(); - results.add(new ProfilerResult(Defaults.PREFIX + "gc.alloc.rate.norm", + results.add(new ScalarResult(Defaults.PREFIX + "gc.alloc.rate.norm", (allOps != 0) ? 1.0 * allocated / allOps : Double.NaN, @@ -112,14 +110,14 @@ public Collection afterIteration(BenchmarkParams benchmarkPara } } - results.add(new ProfilerResult( + results.add(new ScalarResult( Defaults.PREFIX + "gc.count", gcCount - beforeGCCount, "counts", AggregationPolicy.SUM)); if (gcCount != beforeGCCount || gcTime != beforeGCTime) { - results.add(new ProfilerResult( + results.add(new ScalarResult( Defaults.PREFIX + "gc.time", gcTime - beforeGCTime, "ms", @@ -136,13 +134,14 @@ public Collection afterIteration(BenchmarkParams benchmarkPara String spaceName = space.replaceAll(" ", "_"); - results.add(new ProfilerResult( + results.add(new ScalarResult( Defaults.PREFIX + "gc.churn." + spaceName + "", churnRate, "MB/sec", AggregationPolicy.AVG)); - results.add(new ProfilerResult(Defaults.PREFIX + "gc.churn." + spaceName + ".norm", + results.add(new ScalarResult( + Defaults.PREFIX + "gc.churn." + spaceName + ".norm", churnNorm, "B/op", AggregationPolicy.AVG)); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java index b6ce78676..455b6d79a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java @@ -26,9 +26,7 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.AggregationPolicy; -import org.openjdk.jmh.results.IterationResult; -import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.*; import sun.management.HotspotCompilationMBean; import sun.management.counter.Counter; @@ -57,51 +55,51 @@ public String getDescription() { public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { Map current = counters().getCurrent(); return Arrays.asList( - new ProfilerResult(Defaults.PREFIX + "compiler.totalTime", + new ScalarResult(Defaults.PREFIX + "compiler.totalTime", current.get("java.ci.totalTime") * 1D / TimeUnit.MILLISECONDS.toNanos(1), "ms", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.totalCompiles", + new ScalarResult(Defaults.PREFIX + "compiler.totalCompiles", current.get("sun.ci.totalCompiles"), "methods", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.totalBailouts", + new ScalarResult(Defaults.PREFIX + "compiler.totalBailouts", current.get("sun.ci.totalBailouts"), "methods", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.totalInvalidates", + new ScalarResult(Defaults.PREFIX + "compiler.totalInvalidates", current.get("sun.ci.totalInvalidates"), "methods", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.nmethodCodeSize", + new ScalarResult(Defaults.PREFIX + "compiler.nmethodCodeSize", current.get("sun.ci.nmethodCodeSize") / 1024d, "Kb", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.nmethodSize", + new ScalarResult(Defaults.PREFIX + "compiler.nmethodSize", current.get("sun.ci.nmethodSize") / 1024d, "Kb", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.osrCompiles", + new ScalarResult(Defaults.PREFIX + "compiler.osrCompiles", current.get("sun.ci.osrCompiles"), "methods", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.osrBytes", + new ScalarResult(Defaults.PREFIX + "compiler.osrBytes", current.get("sun.ci.osrBytes") / 1024d, "Kb", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.osrTime", + new ScalarResult(Defaults.PREFIX + "compiler.osrTime", current.get("sun.ci.osrTime") * 1d / TimeUnit.MILLISECONDS.toNanos(1), "ms", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.standardCompiles", + new ScalarResult(Defaults.PREFIX + "compiler.standardCompiles", current.get("sun.ci.standardCompiles"), "methods", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.standardBytes", + new ScalarResult(Defaults.PREFIX + "compiler.standardBytes", current.get("sun.ci.standardBytes") / 1024d, "Kb", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "compiler.standardTime", + new ScalarResult(Defaults.PREFIX + "compiler.standardTime", current.get("sun.ci.standardTime") * 1d / TimeUnit.MILLISECONDS.toNanos(1), "ms", AggregationPolicy.MAX) ); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java index 6b8316b87..276839efb 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java @@ -26,9 +26,7 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.AggregationPolicy; -import org.openjdk.jmh.results.IterationResult; -import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.*; import sun.management.HotspotRuntimeMBean; import sun.management.counter.Counter; @@ -57,43 +55,43 @@ public String getDescription() { public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { Map current = counters().getCurrent(); return Arrays.asList( - new ProfilerResult(Defaults.PREFIX + "rt.sync.fatMonitors", + new ScalarResult(Defaults.PREFIX + "rt.sync.fatMonitors", current.get("sun.rt._sync_MonExtant"), "monitors", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "rt.sync.monitorInflations", + new ScalarResult(Defaults.PREFIX + "rt.sync.monitorInflations", current.get("sun.rt._sync_Inflations"), "monitors", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "rt.sync.monitorDeflations", + new ScalarResult(Defaults.PREFIX + "rt.sync.monitorDeflations", current.get("sun.rt._sync_Deflations"), "monitors", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "rt.sync.contendedLockAttempts", + new ScalarResult(Defaults.PREFIX + "rt.sync.contendedLockAttempts", current.get("sun.rt._sync_ContendedLockAttempts"), "locks", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "rt.sync.parks", + new ScalarResult(Defaults.PREFIX + "rt.sync.parks", current.get("sun.rt._sync_Parks"), "counts", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "rt.sync.notifications", + new ScalarResult(Defaults.PREFIX + "rt.sync.notifications", current.get("sun.rt._sync_Notifications"), "counts", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "rt.sync.futileWakeups", + new ScalarResult(Defaults.PREFIX + "rt.sync.futileWakeups", current.get("sun.rt._sync_FutileWakeups"), "counts", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "rt.safepoints", + new ScalarResult(Defaults.PREFIX + "rt.safepoints", current.get("sun.rt.safepoints"), "counts", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "rt.safepointSyncTime", + new ScalarResult(Defaults.PREFIX + "rt.safepointSyncTime", current.get("sun.rt.safepointSyncTime") * 1d / TimeUnit.MILLISECONDS.toNanos(1), "ms", AggregationPolicy.MAX), - new ProfilerResult(Defaults.PREFIX + "rt.safepointTime", + new ScalarResult(Defaults.PREFIX + "rt.safepointTime", current.get("sun.rt.safepointTime") * 1d / TimeUnit.MILLISECONDS.toNanos(1), "ms", AggregationPolicy.MAX) ); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java index 707b7f007..1e5696103 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java @@ -26,9 +26,7 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.AggregationPolicy; -import org.openjdk.jmh.results.IterationResult; -import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.*; import sun.management.HotspotThreadMBean; import sun.management.counter.Counter; @@ -56,15 +54,15 @@ public String getDescription() { public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { Map current = counters().getCurrent(); return Arrays.asList( - new ProfilerResult(Defaults.PREFIX + "threads.alive", + new ScalarResult(Defaults.PREFIX + "threads.alive", current.get("java.threads.live"), "threads", AggregationPolicy.AVG), - new ProfilerResult(Defaults.PREFIX + "threads.daemon", + new ScalarResult(Defaults.PREFIX + "threads.daemon", current.get("java.threads.daemon"), "threads", AggregationPolicy.AVG), - new ProfilerResult(Defaults.PREFIX + "threads.started", + new ScalarResult(Defaults.PREFIX + "threads.started", current.get("java.threads.started"), "threads", AggregationPolicy.MAX) ); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index c181a073e..f5528a754 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -319,53 +319,19 @@ private Collection process(BenchmarkResult br, File stdOut, Fi } } - static class PerfResult extends Result { + static class PerfResult extends ScalarResult { private static final long serialVersionUID = -1262685915873231436L; - private final String key; - public PerfResult(String key, double value) { - this(key, of(value)); - } - - public PerfResult(String key, Statistics stat) { - super(ResultRole.SECONDARY, Defaults.PREFIX + key, stat, "#/op", AggregationPolicy.AVG); - this.key = key; - } - - @Override - protected Aggregator getThreadAggregator() { - return new PerfResultAggregator(); - } - - @Override - protected Aggregator getIterationAggregator() { - return new PerfResultAggregator(); - } - - @Override - public String toString() { - return String.format(" %s %s/op", ScoreFormatter.format(getScore()), key); + super(key, value, "#/op", AggregationPolicy.AVG); } @Override public String extendedInfo() { + // omit printing in extended info return ""; } } - static class PerfResultAggregator implements Aggregator { - - @Override - public PerfResult aggregate(Collection results) { - String key = ""; - ListStatistics stat = new ListStatistics(); - for (PerfResult r : results) { - key = r.key; - stat.addValue(r.getScore()); - } - return new PerfResult(key, stat); - } - } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java index 47ea28e1b..2f5ee02fd 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java @@ -194,7 +194,7 @@ static class PerfResult extends Result { private final long instructions; public PerfResult(String output, long cycles, long instructions) { - super(ResultRole.SECONDARY, Defaults.PREFIX + "cpi", of(1.0 * cycles / instructions), "CPI", AggregationPolicy.AVG); + super(ResultRole.SECONDARY, Defaults.PREFIX + "perf", of(Double.NaN), "---", AggregationPolicy.AVG); this.output = output; this.cycles = cycles; this.instructions = instructions; @@ -210,6 +210,13 @@ protected Aggregator getIterationAggregator() { return new PerfResultAggregator(); } + @Override + protected Collection getDerivativeResults() { + return Collections.singletonList( + new ScalarDerivativeResult(Defaults.PREFIX + "cpi", 1.0 * cycles / instructions, "CPI", AggregationPolicy.AVG) + ); + } + @Override public String toString() { return String.format("%s cycles per instruction", ScoreFormatter.format(1.0 * cycles / instructions)); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResultAggregator.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResultAggregator.java deleted file mode 100644 index 42ee75446..000000000 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResultAggregator.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.profile; - -import org.openjdk.jmh.results.AggregatorUtils; -import org.openjdk.jmh.results.Aggregator; -import org.openjdk.jmh.util.ListStatistics; - -import java.util.Collection; - -public class ProfilerResultAggregator implements Aggregator { - @Override - public ProfilerResult aggregate(Collection results) { - ListStatistics stats = new ListStatistics(); - for (ProfilerResult r : results) { - stats.addValue(r.getScore()); - } - return new ProfilerResult( - AggregatorUtils.aggregateLabels(results), - stats, - AggregatorUtils.aggregateUnits(results), - AggregatorUtils.aggregatePolicies(results) - ); - } -} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResult.java index 6daceaae5..ab54dc3b2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResult.java @@ -29,10 +29,7 @@ import org.openjdk.jmh.util.Multimap; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; /** * Benchmark result. @@ -106,6 +103,9 @@ public Map getSecondaryResults() { for (IterationResult ir : iterationResults) { Map secondaryResults = ir.getSecondaryResults(); for (Map.Entry entry : secondaryResults.entrySet()) { + // skip derivatives from aggregation here + if (entry.getValue().getRole().isDerivative()) continue; + allSecondary.put(entry.getKey(), entry.getValue()); } } @@ -142,7 +142,7 @@ public Map getSecondaryResults() { Aggregator aggregator = null; Collection results = new ArrayList(); for (Result r : benchmarkResults.get(label)) { - if (r.getRole().isSecondary()) { + if (r.getRole().isSecondary() && !r.getRole().isDerivative()) { results.add(r); aggregator = r.getIterationAggregator(); } @@ -152,9 +152,27 @@ public Map getSecondaryResults() { } } + // put all secondary derivative results on top: from primaries + answers.putAll(produceDerivative(getPrimaryResult())); + + // add all derivative results on top: from secondaries + Map adds = new HashMap(); + for (Result r : answers.values()) { + adds.putAll(produceDerivative(r)); + } + answers.putAll(adds); + return answers; } + private Map produceDerivative(Result r) { + Map map = new HashMap(); + for (Object rr : r.getDerivativeResults()) { + map.put(((Result) rr).getLabel(), (Result) rr); + } + return map; + } + public String getScoreUnit() { return getPrimaryResult().getScoreUnit(); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/Defaults.java b/jmh-core/src/main/java/org/openjdk/jmh/results/Defaults.java similarity index 95% rename from jmh-core/src/main/java/org/openjdk/jmh/profile/Defaults.java rename to jmh-core/src/main/java/org/openjdk/jmh/results/Defaults.java index 105ce9fb0..fabd43df9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/Defaults.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/Defaults.java @@ -22,9 +22,9 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package org.openjdk.jmh.profile; +package org.openjdk.jmh.results; -class Defaults { +public class Defaults { public static final String PREFIX = "\u00b7"; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResult.java index 4096f0cbb..18be0376e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResult.java @@ -30,12 +30,7 @@ import org.openjdk.jmh.util.TreeMultimap; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; /** * Class contains all info returned by benchmark iteration or/and collected during benchmark iteration. @@ -112,9 +107,28 @@ public Map getSecondaryResults() { Result result = aggregator.aggregate(results); answer.put(label, result); } + + // put all secondary derivative results on top: from primaries + answer.putAll(produceDerivative(getPrimaryResult())); + + // add all secondary derivative results on top: from secondaries + Map adds = new HashMap(); + for (Result r : answer.values()) { + adds.putAll(produceDerivative(r)); + } + answer.putAll(adds); + return answer; } + private Map produceDerivative(Result r) { + Map map = new HashMap(); + for (Object rr : r.getDerivativeResults()) { + map.put(((Result) rr).getLabel(), (Result) rr); + } + return map; + } + public Result getPrimaryResult() { @SuppressWarnings("unchecked") Aggregator aggregator = primaryResults.iterator().next().getThreadAggregator(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java index 348d20f32..152fd12f0 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java @@ -32,6 +32,8 @@ import java.io.PrintWriter; import java.io.Serializable; import java.io.StringWriter; +import java.util.Collection; +import java.util.Collections; /** * Base class for all types of results that can be returned by a benchmark. @@ -179,6 +181,15 @@ protected T getZeroResult() { return null; } + /** + * Get derivative results for this result. These do not participate in aggregation, + * and computed on the spot from the aggregated result. + * @return + */ + protected Collection getDerivativeResults() { + return Collections.emptyList(); + } + /** * Result as represented by a String. * diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/ResultRole.java b/jmh-core/src/main/java/org/openjdk/jmh/results/ResultRole.java index 8b350c2a6..2515c9474 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/ResultRole.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/ResultRole.java @@ -36,6 +36,11 @@ public enum ResultRole { */ SECONDARY, + /** + * Same as {@link #SECONDARY}, but always recomputed. + */ + SECONDARY_DERIVATIVE, + /** * Does not participate in any metric, garbage result. */ @@ -47,7 +52,11 @@ public boolean isPrimary() { } public boolean isSecondary() { - return this == SECONDARY; + return this == SECONDARY || this == SECONDARY_DERIVATIVE; + } + + public boolean isDerivative() { + return this == SECONDARY_DERIVATIVE; } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java index 686712ce9..b8415dd45 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java @@ -28,6 +28,7 @@ import org.openjdk.jmh.util.SampleBuffer; import org.openjdk.jmh.util.Statistics; +import java.util.Arrays; import java.util.Collection; import java.util.concurrent.TimeUnit; @@ -62,25 +63,17 @@ private static Statistics of(SampleBuffer buffer, TimeUnit outputTimeUnit) { } @Override - public String toString() { - Statistics stats = getStatistics(); - - StringBuilder sb = new StringBuilder(); - sb.append("n = ").append(stats.getN()).append(", "); - sb.append(String.format("mean = %.0f %s", - stats.getMean(), - getScoreUnit())); - sb.append(String.format(", p{0.00, 0.50, 0.90, 0.95, 0.99, 0.999, 0.9999, 1.00} = %.0f, %.0f, %.0f, %.0f, %.0f, %.0f, %.0f, %.0f %s", - stats.getPercentile(0), - stats.getPercentile(50), - stats.getPercentile(90), - stats.getPercentile(95), - stats.getPercentile(99), - stats.getPercentile(99.9), - stats.getPercentile(99.99), - stats.getPercentile(100), - getScoreUnit())); - return sb.toString(); + protected Collection getDerivativeResults() { + return Arrays.asList( + new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.00", statistics.getPercentile(0), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.50", statistics.getPercentile(50), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.90", statistics.getPercentile(90), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.95", statistics.getPercentile(95), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.99", statistics.getPercentile(99), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.999", statistics.getPercentile(99.9), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.9999", statistics.getPercentile(99.99), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(label + Defaults.PREFIX + "p1.00", statistics.getPercentile(100), getScoreUnit(), AggregationPolicy.AVG) + ); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/ScalarDerivativeResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/ScalarDerivativeResult.java new file mode 100644 index 000000000..cee503568 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/ScalarDerivativeResult.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.results; + +import org.openjdk.jmh.util.ListStatistics; +import org.openjdk.jmh.util.Statistics; + +import java.util.Collection; + +public class ScalarDerivativeResult extends Result { + private static final long serialVersionUID = 3407232747805728586L; + + public ScalarDerivativeResult(String label, double n, String unit, AggregationPolicy policy) { + this(label, of(n), unit, policy); + } + + ScalarDerivativeResult(String label, Statistics s, String unit, AggregationPolicy policy) { + super(ResultRole.SECONDARY_DERIVATIVE, label, s, unit, policy); + } + + @Override + protected Aggregator getThreadAggregator() { + return new ScalarResultAggregator(); + } + + @Override + protected Aggregator getIterationAggregator() { + return new ScalarResultAggregator(); + } + + @Override + protected ScalarDerivativeResult getZeroResult() { + return new ScalarDerivativeResult(label, 0, unit, policy); + } + + static class ScalarResultAggregator implements Aggregator { + @Override + public ScalarDerivativeResult aggregate(Collection results) { + ListStatistics stats = new ListStatistics(); + for (ScalarDerivativeResult r : results) { + stats.addValue(r.getScore()); + } + return new ScalarDerivativeResult( + AggregatorUtils.aggregateLabels(results), + stats, + AggregatorUtils.aggregateUnits(results), + AggregatorUtils.aggregatePolicies(results) + ); + } + } + + @Override + public String extendedInfo() { + return ""; + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/ScalarResult.java similarity index 54% rename from jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResult.java rename to jmh-core/src/main/java/org/openjdk/jmh/results/ScalarResult.java index 0055d0f46..e9f742fa3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/ScalarResult.java @@ -22,37 +22,52 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package org.openjdk.jmh.profile; +package org.openjdk.jmh.results; -import org.openjdk.jmh.results.AggregationPolicy; -import org.openjdk.jmh.results.Aggregator; -import org.openjdk.jmh.results.Result; -import org.openjdk.jmh.results.ResultRole; +import org.openjdk.jmh.util.ListStatistics; import org.openjdk.jmh.util.Statistics; -public class ProfilerResult extends Result { +import java.util.Collection; + +public class ScalarResult extends Result { private static final long serialVersionUID = 3407232747805728586L; - public ProfilerResult(String label, double n, String unit, AggregationPolicy policy) { + public ScalarResult(String label, double n, String unit, AggregationPolicy policy) { this(label, of(n), unit, policy); } - ProfilerResult(String label, Statistics s, String unit, AggregationPolicy policy) { + ScalarResult(String label, Statistics s, String unit, AggregationPolicy policy) { super(ResultRole.SECONDARY, label, s, unit, policy); } @Override - protected Aggregator getThreadAggregator() { - return new ProfilerResultAggregator(); + protected Aggregator getThreadAggregator() { + return new ScalarResultAggregator(); } @Override - protected Aggregator getIterationAggregator() { - return new ProfilerResultAggregator(); + protected Aggregator getIterationAggregator() { + return new ScalarResultAggregator(); } @Override - protected ProfilerResult getZeroResult() { - return new ProfilerResult(label, 0, unit, policy); + protected ScalarResult getZeroResult() { + return new ScalarResult(label, 0, unit, policy); + } + + static class ScalarResultAggregator implements Aggregator { + @Override + public ScalarResult aggregate(Collection results) { + ListStatistics stats = new ListStatistics(); + for (ScalarResult r : results) { + stats.addValue(r.getScore()); + } + return new ScalarResult( + AggregatorUtils.aggregateLabels(results), + stats, + AggregatorUtils.aggregateUnits(results), + AggregatorUtils.aggregatePolicies(results) + ); + } } } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestBenchmarkResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestBenchmarkResult.java index bf22d839e..d588d2485 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestBenchmarkResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestBenchmarkResult.java @@ -37,10 +37,13 @@ public class TestBenchmarkResult { @Test public void testMissingSecondaries() { IterationResult ir1 = new IterationResult(null, null, null); + ir1.addResult(new PrimaryResult()); ir1.addResult(new SecondaryResult("label1", 1)); IterationResult ir2 = new IterationResult(null, null, null); + ir2.addResult(new PrimaryResult()); ir2.addResult(new SecondaryResult("label2", 2)); IterationResult ir3 = new IterationResult(null, null, null); + ir3.addResult(new PrimaryResult()); ir3.addResult(new SecondaryResult("label2", 3)); BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir1, ir2, ir3)); @@ -50,6 +53,22 @@ public void testMissingSecondaries() { Assert.assertEquals(5.0D, sr.get("label2").getScore(), 0.001); } + public static class PrimaryResult extends Result { + public PrimaryResult() { + super(ResultRole.PRIMARY, "Boo", of(1.0D), "unit", AggregationPolicy.SUM); + } + + @Override + protected Aggregator getThreadAggregator() { + return new PrimaryResultAggregator(); + } + + @Override + protected Aggregator getIterationAggregator() { + return new PrimaryResultAggregator(); + } + } + public static class SecondaryResult extends Result { public SecondaryResult(String label, double val) { super(ResultRole.SECONDARY, label, of(val), "unit", AggregationPolicy.SUM); @@ -65,6 +84,13 @@ protected Aggregator getIterationAggregator() { } } + public static class PrimaryResultAggregator implements Aggregator { + @Override + public PrimaryResult aggregate(Collection results) { + return new PrimaryResult(); + } + } + public static class SecondaryResultAggregator implements Aggregator { @Override public SecondaryResult aggregate(Collection results) { From 1038afcd82550b2efdc56579223a3ad6f331bb25 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 7 Sep 2016 11:22:31 +0300 Subject: [PATCH 026/342] 7901782: "pauses" profiler --- .../openjdk/jmh/profile/PausesProfiler.java | 203 ++++++++++++++++++ .../openjdk/jmh/profile/ProfilerFactory.java | 1 + .../jmh/results/AggregationPolicy.java | 2 + .../java/org/openjdk/jmh/results/Result.java | 4 + 4 files changed, 210 insertions(+) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java new file mode 100644 index 000000000..70fbbfca6 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2016, Red Hat Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.profile; + +import joptsimple.OptionException; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; +import org.openjdk.jmh.infra.BenchmarkParams; +import org.openjdk.jmh.infra.IterationParams; +import org.openjdk.jmh.results.*; +import org.openjdk.jmh.runner.options.IntegerValueConverter; +import org.openjdk.jmh.util.SampleBuffer; +import org.openjdk.jmh.util.Statistics; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.LockSupport; + +public class PausesProfiler implements InternalProfiler { + + private Ticker ticker; + private SampleBuffer buffer; + private long expectedNs; + private long thresh; + + @Override + public String getDescription() { + return "Pauses profiler"; + } + + public PausesProfiler(String initLine) throws ProfilerException { + OptionParser parser = new OptionParser(); + parser.formatHelpWith(new ProfilerOptionFormatter(PausesProfiler.class.getCanonicalName())); + + OptionSpec optSamplePeriod = parser.accepts("period", "Sampling period, in us. " + + "Smaller values improve accuracy, at the expense of more profiling overhead.") + .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int").defaultsTo(50); + + OptionSpec optThreshold = parser.accepts("threshold", "Threshold to filter pauses, in us. " + + "If unset, the threshold is figured during the initial calibration.") + .withRequiredArg().withValuesConvertedBy(IntegerValueConverter.POSITIVE).describedAs("int").defaultsTo(-1); + + OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); + + try { + expectedNs = TimeUnit.MICROSECONDS.toNanos(set.valueOf(optSamplePeriod)); + if (set.valueOf(optThreshold) != -1) { + thresh = TimeUnit.MICROSECONDS.toNanos(set.valueOf(optThreshold)); + } else { + thresh = calibrate(); + } + } catch (OptionException e) { + throw new ProfilerException(e.getMessage()); + } + } + + @Override + public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { + buffer = new SampleBuffer(); + ticker = new Ticker(buffer); + ticker.start(); + } + + @Override + public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { + ticker.interrupt(); + try { + ticker.join(); + } catch (InterruptedException e) { + // do nothing, proceed + } + + return Collections.singletonList(new PausesProfilerResult(buffer)); + } + + private long calibrate() { + SampleBuffer buf = new SampleBuffer(); + + long lastTime = System.nanoTime(); + for (int c = 0; c < 10000; c++) { + LockSupport.parkNanos(expectedNs); + long time = System.nanoTime(); + + long actualNs = time - lastTime; + long delta = actualNs - expectedNs; + if (delta > 0) { + buf.add(delta); + } + lastTime = time; + } + + // The max observed pause during calibration must be our measurement + // threshold. We cannot reliably guess the pauses lower than this are + // caused by the benchmark pressure. + Statistics stat = buf.getStatistics(1); + return (long) stat.getMax(); + } + + + private class Ticker extends Thread { + private final SampleBuffer buffer; + public Ticker(SampleBuffer buffer) { + this.buffer = buffer; + setPriority(Thread.MAX_PRIORITY); + setDaemon(true); + } + + @Override + public void run() { + long lastTime = System.nanoTime(); + while (!Thread.interrupted()) { + LockSupport.parkNanos(expectedNs); + long time = System.nanoTime(); + + long actualNs = time - lastTime; + long delta = actualNs - expectedNs; + if (delta > thresh) { + // assume the actual pause starts within the sleep interval, + // we can adjust the measurement by a half the expected time + buffer.add(delta + expectedNs/2); + } + lastTime = time; + } + } + } + + static class PausesProfilerResult extends Result { + private SampleBuffer buffer; + + public PausesProfilerResult(SampleBuffer buffer) { + super(ResultRole.SECONDARY, Defaults.PREFIX + "pauses", buffer.getStatistics(1D / 1000000), "ms", AggregationPolicy.SUM); + this.buffer = buffer; + } + + @Override + protected Aggregator getThreadAggregator() { + return new JoiningAggregator(); + } + + @Override + protected Aggregator getIterationAggregator() { + return new JoiningAggregator(); + } + + @Override + protected Collection getDerivativeResults() { + return Arrays.asList( + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.avg", statistics.getMean(), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.count", statistics.getN(), "#", AggregationPolicy.SUM), + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.00", statistics.getMin(), "ms", AggregationPolicy.MIN), + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.50", statistics.getPercentile(50), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.90", statistics.getPercentile(90), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.95", statistics.getPercentile(95), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.99", statistics.getPercentile(99), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.999", statistics.getPercentile(99.9), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.9999", statistics.getPercentile(99.99),"ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p1.00", statistics.getMax(), "ms", AggregationPolicy.MAX) + ); + } + + /** + * Always add up all the samples into final result. + * This will allow aggregate result to achieve better accuracy. + */ + private static class JoiningAggregator implements Aggregator { + + @Override + public PausesProfilerResult aggregate(Collection results) { + SampleBuffer buffer = new SampleBuffer(); + for (PausesProfilerResult r : results) { + buffer.addAll(r.buffer); + } + return new PausesProfilerResult(buffer); + } + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java index 3b683c165..036185c85 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java @@ -187,6 +187,7 @@ public static void listProfilers(PrintStream out) { BUILT_IN.put("perfnorm", LinuxPerfNormProfiler.class); BUILT_IN.put("perfasm", LinuxPerfAsmProfiler.class); BUILT_IN.put("xperfasm", WinPerfAsmProfiler.class); + BUILT_IN.put("pauses", PausesProfiler.class); } private static List> getDiscoveredProfilers() { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/AggregationPolicy.java b/jmh-core/src/main/java/org/openjdk/jmh/results/AggregationPolicy.java index 53543d5f3..53ee3c0b9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/AggregationPolicy.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/AggregationPolicy.java @@ -32,6 +32,8 @@ public enum AggregationPolicy { MAX("Maximum"), + MIN("Minimum"), + ; private String label; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java index 152fd12f0..795c52bfb 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java @@ -112,6 +112,8 @@ public double getScore() { return statistics.getSum(); case MAX: return statistics.getMax(); + case MIN: + return statistics.getMin(); default: throw new IllegalStateException("Unknown aggregation policy: " + policy); } @@ -127,6 +129,7 @@ public double getScoreError() { case AVG: return statistics.getMeanErrorAt(0.999); case SUM: + case MIN: case MAX: return Double.NaN; default: @@ -144,6 +147,7 @@ public double[] getScoreConfidence() { case AVG: return statistics.getConfidenceIntervalAt(0.999); case MAX: + case MIN: case SUM: double score = getScore(); return new double[] {score, score}; From 30b6d5cbfbeab2f57a55234ad3e40b1edae75893 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 7 Sep 2016 18:54:20 +0300 Subject: [PATCH 027/342] 7901784: org.openjdk.jmh.it.annsteal.CustomTest fails with -P asm,reflection --- jmh-core-it/pom.xml | 11 ++++++++- .../openjdk/jmh/it/annsteal/CustomTest.java | 12 ++++++++-- .../java/org/openjdk/jmh/util/FileUtils.java | 24 +++++++++++++------ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index ffb66c130..2cc8deea7 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -73,7 +73,7 @@ questions. 2.14.1 - -Djmh.ignoreLock=true -Xms256m -Xmx256m + -Djmh.ignoreLock=true -Xms256m -Xmx256m -Djmh.core.it.profile=${jmh.core.it.profile} 1C true true @@ -107,6 +107,9 @@ questions. default + + default + org.openjdk.jmh @@ -136,6 +139,9 @@ questions. asm + + asm + org.openjdk.jmh @@ -223,6 +229,9 @@ questions. reflection + + reflection + org.openjdk.jmh diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java index e5eec014d..453ce241f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java @@ -45,8 +45,16 @@ public void bench() { @Test public void test() throws IOException { - File file = FileUtils.extractFromResource('/' + CustomBenchmarkProcessor.CBP_LIST); - Collection strings = FileUtils.readAllLines(file); + if (!"default".equals(System.getProperty("jmh.core.it.profile"))) { + return; + } + + InputStream list = CustomTest.class.getResourceAsStream('/' + CustomBenchmarkProcessor.CBP_LIST); + if (list == null) { + throw new IllegalStateException(CustomBenchmarkProcessor.class.getSimpleName() + " list is not found"); + } + + Collection strings = FileUtils.readAllLines(list); Assert.assertTrue(strings.contains(CustomTest.class.getSimpleName())); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java index e27850bd2..66b058c43 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java @@ -115,13 +115,13 @@ public static Collection tail(File file, int num) throws IOException { } public static Collection readAllLines(Reader src) throws IOException { - BufferedReader reader = new BufferedReader(src); - List lines = new ArrayList(); - String line; - while ((line = reader.readLine()) != null) { - lines.add(line); - } - return lines; + BufferedReader reader = new BufferedReader(src); + List lines = new ArrayList(); + String line; + while ((line = reader.readLine()) != null) { + lines.add(line); + } + return lines; } public static Collection readAllLines(File file) throws IOException { @@ -134,6 +134,16 @@ public static Collection readAllLines(File file) throws IOException { } } + public static Collection readAllLines(InputStream stream) throws IOException { + InputStreamReader reader = new InputStreamReader(stream); + try { + return readAllLines(reader); + } finally { + FileUtils.safelyClose(reader); + FileUtils.safelyClose(stream); + } + } + public static void writeLines(File file, Collection lines) throws IOException { PrintWriter pw = null; try { From a1b0df2b33b97c58b934ffc521b229856e04b57b Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 7 Sep 2016 20:56:07 +0300 Subject: [PATCH 028/342] JMH v1.14 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 7fc5bd478..29112bad8 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.14-SNAPSHOT + 1.14 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index adf6d7c2f..4f934fde7 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.14-SNAPSHOT + 1.14 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 3d593bc72..ad97536fc 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.14-SNAPSHOT + 1.14 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index e861b4894..cde2be35b 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.14-SNAPSHOT + 1.14 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 37eec460a..e36742e67 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 5e7fd8306..fe8309a66 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index d5d0a2a69..52706ec40 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 2cc8deea7..85d7089e6 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index f406a6790..f20b7f28c 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 9415a3482..f6e88a82a 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 8619a59e8..075ec8819 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 24a919666..8624cb620 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 4c9d4bb49..4d4c2bacc 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 24ce60e79..1ce880c8f 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.14-SNAPSHOT + 1.14 JMH Samples diff --git a/pom.xml b/pom.xml index 6a7b75a44..135f31893 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.14-SNAPSHOT + 1.14 Java Microbenchmark Harness Parent From 2530c9720e5bcd67abb3243772a5508400ad3e5e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 7 Sep 2016 20:56:10 +0300 Subject: [PATCH 029/342] Added tag 1.14 for changeset b9ea316668ae --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index a641975c0..5a618e090 100644 --- a/.hgtags +++ b/.hgtags @@ -76,3 +76,4 @@ c5a34103cbb32c8aee3d6b3a151f15819a4ea664 1.11 534d83d9137f2231b889188f6bff02e541d1e7bd 1.11.3 eb41bdab96cf7579db48fc39a9fa423b54bf4786 1.12 7ff584954008f5dc877c590df5d902a0022f7456 1.13 +b9ea316668ae3e6510bf6ebe21625218f966c15a 1.14 From bea023cdb25c033d9260191fe500d016ba44c2dc Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 7 Sep 2016 20:56:28 +0300 Subject: [PATCH 030/342] Continue in 1.15-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 29112bad8..cdb2722ff 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.14 + 1.15-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 4f934fde7..523aef765 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.14 + 1.15-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index ad97536fc..aa88d1cfc 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.14 + 1.15-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index cde2be35b..68aa9eb66 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.14 + 1.15-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index e36742e67..3b462b59e 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index fe8309a66..e68cd290c 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 52706ec40..ff6149209 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 85d7089e6..75df1d45b 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index f20b7f28c..1a0d5ae7a 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index f6e88a82a..6ebb37f08 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 075ec8819..5a4b3bfd6 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 8624cb620..7db6700d5 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 4d4c2bacc..175e68a35 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 1ce880c8f..56f1ba406 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.14 + 1.15-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 135f31893..de6794eca 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.14 + 1.15-SNAPSHOT Java Microbenchmark Harness Parent From cb81435620354d4655a198accb5f79e22cd3567a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Sep 2016 11:48:41 +0200 Subject: [PATCH 031/342] 7901789: Rework exception/timeout handling scheme: faster failure paths --- .../openjdk/jmh/runner/BenchmarkHandler.java | 83 +++++++++++-------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index a798ae8ba..e4f794d7d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -29,10 +29,7 @@ import org.openjdk.jmh.infra.ThreadParams; import org.openjdk.jmh.profile.InternalProfiler; import org.openjdk.jmh.profile.ProfilerFactory; -import org.openjdk.jmh.results.BenchmarkTaskResult; -import org.openjdk.jmh.results.IterationResult; -import org.openjdk.jmh.results.IterationResultMetaData; -import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.*; import org.openjdk.jmh.runner.format.OutputFormat; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.TimeValue; @@ -331,9 +328,10 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa startProfilers(benchmarkParams, params); // submit tasks to threadpool - Map> results = new HashMap>(); + List> completed = new ArrayList>(); + CompletionService srv = new ExecutorCompletionService(executor); for (BenchmarkTask runner : runners) { - results.put(runner, executor.submit(runner)); + srv.submit(runner); } // wait for all workers to transit to measurement @@ -346,7 +344,14 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa break; default: try { - runtime.sleep(); + Future failing = srv.poll(runtime.convertTo(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS); + if (failing != null) { + // Oops, some task has exited prematurely, without isDone check. + // Must be an exception. Record the failing result, and lift the + // timeout deadline: we care only to exit as fast as possible now. + completed.add(failing); + waitDeadline = System.nanoTime(); + } } catch (InterruptedException e) { // regardless... } @@ -358,40 +363,46 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa // wait for all workers to transit to teardown control.awaitWarmdownReady(); - // Wait for the result, continuously polling the worker threads. - // The abrupt exception in any worker will float up here. - long allOps = 0; - long measuredOps = 0; - IterationResult result; - - try { - int expected = numThreads; - while (expected > 0) { - for (Map.Entry> re : results.entrySet()) { - BenchmarkTask task = re.getKey(); - Future fr = re.getValue(); - try { - long waitFor = Math.max(TimeUnit.MILLISECONDS.toNanos(100), waitDeadline - System.nanoTime()); - - BenchmarkTaskResult btr = fr.get(waitFor, TimeUnit.NANOSECONDS); - iterationResults.addAll(btr.getResults()); - allOps += btr.getAllOps(); - measuredOps += btr.getMeasuredOps(); - expected--; - } catch (InterruptedException ex) { - throw new BenchmarkException(ex); - } catch (ExecutionException ex) { - // unwrap: ExecutionException -> Throwable-wrapper -> InvocationTargetException - Throwable cause = ex.getCause().getCause().getCause(); - throw new BenchmarkException(cause); - } catch (TimeoutException e) { - // try to kick the thread, if it was already started + // Wait for the result, handling timeouts + while (completed.size() < numThreads) { + try { + long waitFor = Math.max(TimeUnit.MILLISECONDS.toNanos(100), waitDeadline - System.nanoTime()); + Future fr = srv.poll(waitFor, TimeUnit.NANOSECONDS); + if (fr == null) { + // We are in the timeout mode now, kick all the still running threads. + out.print("(*interrupt*) "); + for (BenchmarkTask task : runners) { Thread runner = task.runner; if (runner != null) { - out.print("(*interrupt*) "); runner.interrupt(); } } + } else { + completed.add(fr); + } + } catch (InterruptedException ex) { + throw new BenchmarkException(ex); + } + } + + // Process the results: we get here after all worker threads have quit, + // either normally or abnormally. This means, Future.get() would never block. + long allOps = 0; + long measuredOps = 0; + IterationResult result; + try { + for (Future fr : completed) { + try { + BenchmarkTaskResult btr = fr.get(); + iterationResults.addAll(btr.getResults()); + allOps += btr.getAllOps(); + measuredOps += btr.getMeasuredOps(); + } catch (ExecutionException ex) { + // unwrap: ExecutionException -> Throwable-wrapper -> InvocationTargetException + Throwable cause = ex.getCause().getCause().getCause(); + throw new BenchmarkException(cause); + } catch (InterruptedException ex) { + throw new BenchmarkException(ex); } } } finally { From 2a6ec77aace2e012a5082ebe3c8adbc15080b6cd Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Sep 2016 11:53:02 +0200 Subject: [PATCH 032/342] Add missing test for 7901789 --- .../jmh/it/fails/AbruptFailureTest.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/AbruptFailureTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/AbruptFailureTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/AbruptFailureTest.java new file mode 100644 index 000000000..214c89293 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/AbruptFailureTest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.fails; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.ThreadParams; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +/** + * Baseline test: + * Checks if assertions are propagated back to integration tests. + */ +@BenchmarkMode(Mode.All) +@Warmup(iterations = 0) +@Measurement(iterations = 1, time = 60, timeUnit = TimeUnit.SECONDS) +@Fork(1) +@State(Scope.Benchmark) +public class AbruptFailureTest { + + @Benchmark + @Threads(4) + public void test(ThreadParams tp) { + if (tp.getThreadIndex() == 0) { + throw new IllegalStateException(); // fail one thread + } + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + long time1 = System.nanoTime(); + try { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .build(); + new Runner(opt).run(); + + Assert.fail("Should have failed"); + } catch (Throwable t) { + // expected + long time2 = System.nanoTime(); + long delay = TimeUnit.NANOSECONDS.toSeconds(time2 - time1); + Assert.assertTrue("Delayed for too long: " + delay + "s", delay < 10); + } + } + +} From 1fe412f77fcccf127b8be2613d5b79a46878a2d0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Sep 2016 12:48:53 +0200 Subject: [PATCH 033/342] 7901790: Revisit result aggregation checks: labels, roles, units --- .../openjdk/jmh/results/AggregatorUtils.java | 29 ++++++++----------- .../openjdk/jmh/results/SampleTimeResult.java | 6 +++- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/AggregatorUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/results/AggregatorUtils.java index 043d5a2e9..aaa55432b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/AggregatorUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/AggregatorUtils.java @@ -32,54 +32,49 @@ private AggregatorUtils() { // prevent instantation } - public static ResultRole aggregateRoles(Collection results) { + static ResultRole aggregateRoles(Collection results) { ResultRole result = null; for (Result r : results) { if (result == null) { result = r.role; - } else { - if (result != r.role) { - throw new IllegalStateException("Combining the results with different roles"); - } + } else if (result != r.role) { + throw new IllegalStateException("Combining the results with different roles"); } } return result; } - public static String aggregateUnits(Collection results) { + static String aggregateUnits(Collection results) { String result = null; for (Result r : results) { if (result == null) { result = r.unit; - } else { - if (!result.equals(r.unit)) { - throw new IllegalStateException("Combining the results with different units"); - } + } else if (!result.equals(r.unit)) { + throw new IllegalStateException("Combining the results with different units"); } } return result; } - public static String aggregateLabels(Collection results) { + static String aggregateLabels(Collection results) { String result = null; for (Result r : results) { - // pick the first one if (result == null) { result = r.label; + } else if (!result.equals(r.label)) { + throw new IllegalStateException("Combining the results with different labels"); } } return result; } - public static AggregationPolicy aggregatePolicies(Collection results) { + static AggregationPolicy aggregatePolicies(Collection results) { AggregationPolicy result = null; for (Result r : results) { if (result == null) { result = r.policy; - } else { - if (!result.equals(r.policy)) { - throw new IllegalStateException("Combining the results with different aggregation policies"); - } + } else if (!result.equals(r.policy)) { + throw new IllegalStateException("Combining the results with different aggregation policies"); } } return result; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java index b8415dd45..40e7f4fc0 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java @@ -103,7 +103,11 @@ public SampleTimeResult aggregate(Collection results) { TimeUnit tu = null; for (SampleTimeResult r : results) { buffer.addAll(r.buffer); - tu = r.outputTimeUnit; + if (tu == null) { + tu = r.outputTimeUnit; + } else if (!tu.equals(r.outputTimeUnit)){ + throw new IllegalStateException("Combining the results with different timeunits"); + } } return new SampleTimeResult( AggregatorUtils.aggregateRoles(results), From 01699dd0f7267d7c6919c570c66556f178980617 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Sep 2016 17:44:47 +0200 Subject: [PATCH 034/342] 7901791: Console encoding detection code is broken with upcoming setAccessible changes --- .../main/java/org/openjdk/jmh/util/Utils.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 0ed330dbf..9c57f8cdd 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -248,19 +248,14 @@ public static Charset guessConsoleEncoding() { return Charset.forName((String) res); } } - } catch (NoSuchFieldException e) { - // fall-through - } catch (IllegalAccessException e) { - // fall-through - } catch (NoSuchMethodException e) { - // fall-through - } catch (InvocationTargetException e) { + } catch (Exception e) { // fall-through } // Try 2. Try to poke stdout. // When System.console() is null, that is, an application is not attached to a console, the actual // charset of standard output should be extracted from System.out, not from System.console(). + // If we indeed have the console, but failed to poll its charset, it is still better to poke stdout. try { PrintStream out = System.out; if (out != null) { @@ -274,15 +269,21 @@ public static Charset guessConsoleEncoding() { } } } - } catch (NoSuchFieldException e) { - // fall-through - } catch (IllegalAccessException e) { - // fall-through - } catch (UnsupportedCharsetException e) { + } catch (Exception e) { // fall-through } - // Try 3. Nothing left to do, except for returning a (possibly mismatched) default charset. + // Try 3. Try to poll internal properties. + String prop = System.getProperty("sun.stdout.encoding"); + if (prop != null) { + try { + return Charset.forName(prop); + } catch (Exception e) { + // fall-through + } + } + + // Try 4. Nothing left to do, except for returning a (possibly mismatched) default charset. return Charset.defaultCharset(); } From 4d7ef67c0b1149af055d6458f2ac817a41b3b21f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 20 Sep 2016 11:36:29 +0200 Subject: [PATCH 035/342] 7901799: Control objects should be notified consistently --- .../jmh/it/control/ControlStartStopTest.java | 65 +++++++++++++++++ .../jmh/it/control/ControlStopTest.java | 71 +++++++++++++++++++ .../generators/core/BenchmarkGenerator.java | 5 +- .../openjdk/jmh/runner/BenchmarkHandler.java | 7 +- .../org/openjdk/jmh/runner/InfraControl.java | 32 +++++++-- 5 files changed, 170 insertions(+), 10 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStartStopTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStopTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStartStopTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStartStopTest.java new file mode 100644 index 000000000..98dbadab2 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStartStopTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.control; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Control; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +public class ControlStartStopTest { + + @Benchmark + public void ping(Control cnt) { + boolean stop = cnt.stopMeasurement; + boolean start = cnt.startMeasurement; + + // stop should always be preceded by start + Assert.assertFalse(stop && !start); + } + + @Test + public void invokeAPI() throws RunnerException { + for (Mode m : Mode.values()) { + if (m == Mode.All) continue; + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .mode(m) + .build(); + new Runner(opt).runSingle(); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStopTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStopTest.java new file mode 100644 index 000000000..1d5c74117 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStopTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.control; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Control; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +public class ControlStopTest { + + @Benchmark + @Group("pingpong") + public void ping(Control cnt) { + while (!cnt.stopMeasurement) { + // this body is intentionally left blank + } + } + + @Benchmark + @Group("pingpong") + public void pong(Control cnt) { + while (!cnt.stopMeasurement) { + // this body is intentionally left blank + } + } + + @Test + public void invokeAPI() throws RunnerException { + for (Mode m : Mode.values()) { + if (m == Mode.All) continue; + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .mode(m) + .build(); + new Runner(opt).runSingle(); + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index f6f826a87..c9aef95f6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -836,7 +836,7 @@ private void methodProlog(PrintWriter writer, MethodGroup methodGroup) { writer.println(ident(2) + "this.benchmarkParams = control.benchmarkParams;"); writer.println(ident(2) + "this.iterationParams = control.iterationParams;"); writer.println(ident(2) + "this.threadParams = threadParams;"); - writer.println(ident(2) + "this.notifyControl = new Control();"); + writer.println(ident(2) + "this.notifyControl = control.notifyControl;"); writer.println(ident(2) + "this.blackhole = new Blackhole(\"Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.\");"); } @@ -1015,6 +1015,9 @@ private void generateSingleShotTime(ClassInfo classInfo, PrintWriter writer, Mod iterationProlog(writer, 3, method, states); + // control objects get a special treatment + writer.println(ident(3) + "notifyControl.startMeasurement = true;"); + // measurement loop call writer.println(ident(3) + "RawResults res = new RawResults();"); writer.println(ident(3) + "int batchSize = iterationParams.getBatchSize();"); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index e4f794d7d..c4faac39e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -25,6 +25,7 @@ package org.openjdk.jmh.runner; import org.openjdk.jmh.infra.BenchmarkParams; +import org.openjdk.jmh.infra.Control; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.infra.ThreadParams; import org.openjdk.jmh.profile.InternalProfiler; @@ -311,7 +312,9 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa // result object to accumulate the results in List iterationResults = new ArrayList(); - InfraControl control = new InfraControl(benchmarkParams, params, preSetupBarrier, preTearDownBarrier, last); + InfraControl control = new InfraControl(benchmarkParams, params, + preSetupBarrier, preTearDownBarrier, last, + new Control()); // preparing the worker runnables BenchmarkTask[] runners = new BenchmarkTask[numThreads]; @@ -358,7 +361,7 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa } // now we communicate all worker threads should stop - control.isDone = true; + control.announceDone(); // wait for all workers to transit to teardown control.awaitWarmdownReady(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java index aea957ea4..f5af4c9ab 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java @@ -25,6 +25,7 @@ package org.openjdk.jmh.runner; import org.openjdk.jmh.infra.BenchmarkParams; +import org.openjdk.jmh.infra.Control; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.util.Utils; @@ -54,8 +55,10 @@ public class InfraControl extends InfraControlL4 { Utils.check(InfraControl.class, "shouldSynchIterations", "threads"); } - public InfraControl(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration) { - super(benchmarkParams, iterationParams, preSetup, preTearDown, lastIteration); + public InfraControl(BenchmarkParams benchmarkParams, IterationParams iterationParams, + CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, + Control notifyControl) { + super(benchmarkParams, iterationParams, preSetup, preTearDown, lastIteration, notifyControl); } /** @@ -98,6 +101,12 @@ public void preTearDownForce() { public boolean isLastIteration() { return lastIteration; } + + public void announceDone() { + isDone = true; + notifyControl.stopMeasurement = true; + } + } abstract class InfraControlL0 { @@ -141,11 +150,14 @@ abstract class InfraControlL2 extends InfraControlL1 { public final BenchmarkParams benchmarkParams; public final IterationParams iterationParams; + public final Control notifyControl; private final boolean shouldSynchIterations; private final int threads; - public InfraControlL2(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration) { + public InfraControlL2(BenchmarkParams benchmarkParams, IterationParams iterationParams, + CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, + Control notifyControl) { warmupVisited = new AtomicInteger(); warmdownVisited = new AtomicInteger(); @@ -158,6 +170,8 @@ public InfraControlL2(BenchmarkParams benchmarkParams, IterationParams iteration warmupShouldWait = shouldSynchIterations; warmdownShouldWait = shouldSynchIterations; + this.notifyControl = notifyControl; + this.preSetup = preSetup; this.preTearDown = preTearDown; this.lastIteration = lastIteration; @@ -240,16 +254,20 @@ abstract class InfraControlL3 extends InfraControlL2 { private boolean q161, q162, q163, q164, q165, q166, q167, q168; private boolean q171, q172, q173, q174, q175, q176, q177, q178; - public InfraControlL3(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration) { - super(benchmarkParams, iterationParams, preSetup, preTearDown, lastIteration); + public InfraControlL3(BenchmarkParams benchmarkParams, IterationParams iterationParams, + CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, + Control notifyControl) { + super(benchmarkParams, iterationParams, preSetup, preTearDown, lastIteration, notifyControl); } } abstract class InfraControlL4 extends InfraControlL3 { private int markerEnd; - public InfraControlL4(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration) { - super(benchmarkParams, iterationParams, preSetup, preTearDown, lastIteration); + public InfraControlL4(BenchmarkParams benchmarkParams, IterationParams iterationParams, + CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, + Control notifyControl) { + super(benchmarkParams, iterationParams, preSetup, preTearDown, lastIteration, notifyControl); } } From a9fa5fd2db3f1ff9e871853766b70e275e1993fc Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 20 Sep 2016 20:14:06 +0200 Subject: [PATCH 036/342] JMH v1.14.1 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index cdb2722ff..a392bf135 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.15-SNAPSHOT + 1.14.1 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 523aef765..3b76d885b 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.15-SNAPSHOT + 1.14.1 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index aa88d1cfc..35fe59178 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.15-SNAPSHOT + 1.14.1 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 68aa9eb66..29223a848 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.15-SNAPSHOT + 1.14.1 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 3b462b59e..8cd0e8e81 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index e68cd290c..932eb2980 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index ff6149209..fcc5e912d 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 75df1d45b..b5c7b3ea6 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 1a0d5ae7a..682f9f700 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 6ebb37f08..2d732d970 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 5a4b3bfd6..9b422f2d0 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 7db6700d5..fe318f344 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 175e68a35..ff4abfd9e 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 56f1ba406..d4b74bf5b 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.14.1 JMH Samples diff --git a/pom.xml b/pom.xml index de6794eca..05dd3e674 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.15-SNAPSHOT + 1.14.1 Java Microbenchmark Harness Parent From 61d5d62543b61a92dd4ea9c1ae7522db94030b6b Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 20 Sep 2016 20:14:12 +0200 Subject: [PATCH 037/342] Added tag 1.14.1 for changeset eaf181b4eac2 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 5a618e090..03713986d 100644 --- a/.hgtags +++ b/.hgtags @@ -77,3 +77,4 @@ c5a34103cbb32c8aee3d6b3a151f15819a4ea664 1.11 eb41bdab96cf7579db48fc39a9fa423b54bf4786 1.12 7ff584954008f5dc877c590df5d902a0022f7456 1.13 b9ea316668ae3e6510bf6ebe21625218f966c15a 1.14 +eaf181b4eac282ae20f9cb43ad221cf404a951c0 1.14.1 From 71d5f1b8dff7302bedde034d0fa3d23e3fd0ea45 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 20 Sep 2016 20:14:30 +0200 Subject: [PATCH 038/342] Continue in 1.15-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index a392bf135..cdb2722ff 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.14.1 + 1.15-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 3b76d885b..523aef765 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.14.1 + 1.15-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 35fe59178..aa88d1cfc 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.14.1 + 1.15-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 29223a848..68aa9eb66 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.14.1 + 1.15-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 8cd0e8e81..3b462b59e 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 932eb2980..e68cd290c 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index fcc5e912d..ff6149209 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index b5c7b3ea6..75df1d45b 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 682f9f700..1a0d5ae7a 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 2d732d970..6ebb37f08 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 9b422f2d0..5a4b3bfd6 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index fe318f344..7db6700d5 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index ff4abfd9e..175e68a35 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index d4b74bf5b..56f1ba406 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.14.1 + 1.15-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 05dd3e674..de6794eca 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.14.1 + 1.15-SNAPSHOT Java Microbenchmark Harness Parent From 67e97e505487731941032eece8ab3e71a86f190c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 28 Sep 2016 21:57:04 +0200 Subject: [PATCH 039/342] 7901810: Group thread distribution is unstable between iterations --- .../GroupThreadParamsStabilityTest.java | 82 ++++ .../ThreadParamsStabilityTest.java | 75 ++++ .../GroupThreadStateHelperTimesTest.java | 120 ++++++ .../openjdk/jmh/runner/BenchmarkHandler.java | 61 ++- .../jmh/runner/DistributeGroupsTest.java | 356 +++++++++--------- 5 files changed, 501 insertions(+), 193 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/GroupThreadParamsStabilityTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/ThreadParamsStabilityTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupThreadStateHelperTimesTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/GroupThreadParamsStabilityTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/GroupThreadParamsStabilityTest.java new file mode 100644 index 000000000..1fa9cb3fd --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/GroupThreadParamsStabilityTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.threadparams; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.ThreadParams; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.All) +@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +public class GroupThreadParamsStabilityTest { + + @State(Scope.Thread) + public static class Data { + ThreadParams last; + + void test(ThreadParams params) { + if (last == null) { + last = params; + } else { + // simple equality suffices + Assert.assertEquals(last, params); + } + } + } + + @Group("T") + @Benchmark + public void test1(ThreadParams tp, Data d) { + d.test(tp); + } + + @Group("T") + @Benchmark + public void test2(ThreadParams tp, Data d) { + d.test(tp); + } + + @Test + public void test() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .build(); + new Runner(opt).run(); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/ThreadParamsStabilityTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/ThreadParamsStabilityTest.java new file mode 100644 index 000000000..65552555b --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threadparams/ThreadParamsStabilityTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.threadparams; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.ThreadParams; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.All) +@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +public class ThreadParamsStabilityTest { + + @State(Scope.Thread) + public static class Data { + ThreadParams last; + + void test(ThreadParams params) { + if (last == null) { + last = params; + } else { + // simple equality suffices + Assert.assertEquals(last, params); + } + } + } + + @Benchmark + public void test1(ThreadParams tp, Data d) { + d.test(tp); + } + + @Test + public void test() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .build(); + new Runner(opt).run(); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupThreadStateHelperTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupThreadStateHelperTimesTest.java new file mode 100644 index 000000000..9a0b79fd7 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupThreadStateHelperTimesTest.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests if harness executes setup, run, and tearDown in the same workers. + */ +@BenchmarkMode(Mode.All) +@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +@State(Scope.Benchmark) +public class GroupThreadStateHelperTimesTest { + + @State(Scope.Thread) + public static class State1 { + static final AtomicInteger setupTimes = new AtomicInteger(); + static final AtomicInteger tearDownTimes = new AtomicInteger(); + + @Setup + public void setup() { + setupTimes.incrementAndGet(); + } + + @Setup + public void tearDown() { + tearDownTimes.incrementAndGet(); + } + } + + @State(Scope.Thread) + public static class State2 { + static final AtomicInteger setupTimes = new AtomicInteger(); + static final AtomicInteger tearDownTimes = new AtomicInteger(); + + @Setup + public void setup() { + setupTimes.incrementAndGet(); + } + + @Setup + public void tearDown() { + tearDownTimes.incrementAndGet(); + } + } + + @Setup + public void reset() { + State1.setupTimes.set(0); + State1.tearDownTimes.set(0); + State2.setupTimes.set(0); + State2.tearDownTimes.set(0); + } + + @TearDown + public void verify() { + Assert.assertEquals(1, State1.setupTimes.get()); + Assert.assertEquals(1, State1.tearDownTimes.get()); + Assert.assertEquals(1, State2.setupTimes.get()); + Assert.assertEquals(1, State2.tearDownTimes.get()); + } + + @Benchmark + @Group("T") + public void test1(State1 state1) { + Fixtures.work(); + } + + @Benchmark + @Group("T") + public void test2(State2 state2) { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .build(); + new Runner(opt).run(); + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index c4faac39e..7dd243c9a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -54,7 +54,7 @@ class BenchmarkHandler { private final ExecutorService executor; // (Aleksey) Forgive me, Father, for I have sinned. - private final ThreadLocal instances; + private final ThreadLocal threadData; private final OutputFormat out; private final List profilers; @@ -72,11 +72,19 @@ public BenchmarkHandler(OutputFormat out, Options options, BenchmarkParams execu this.profilersRev = new ArrayList(profilers); Collections.reverse(profilersRev); - this.instances = new ThreadLocal() { + final BlockingQueue tps = new ArrayBlockingQueue(executionParams.getThreads()); + tps.addAll(distributeThreads(executionParams.getThreads(), executionParams.getThreadGroups())); + + this.threadData = new ThreadLocal() { @Override - protected Object initialValue() { + protected ThreadData initialValue() { try { - return clazz.newInstance(); + Object o = clazz.newInstance(); + ThreadParams t = tps.poll(); + if (t == null) { + throw new IllegalStateException("Cannot get another thread params"); + } + return new ThreadData(o, t); } catch (InstantiationException e) { throw new RuntimeException("Class " + clazz.getName() + " instantiation error ", e); } catch (IllegalAccessException e) { @@ -84,6 +92,7 @@ protected Object initialValue() { } } }; + this.out = out; try { this.executor = EXECUTOR_TYPE.createExecutor(executionParams.getThreads(), executionParams.getBenchmark()); @@ -92,8 +101,8 @@ protected Object initialValue() { } } - static ThreadParams[] distributeThreads(int threads, int[] groups) { - ThreadParams[] result = new ThreadParams[threads]; + static List distributeThreads(int threads, int[] groups) { + List result = new ArrayList(); int totalGroupThreads = Utils.sum(groups); int totalGroups = (int) Math.ceil(1D * threads / totalGroupThreads); int totalSubgroups = groups.length; @@ -113,13 +122,14 @@ static ThreadParams[] distributeThreads(int threads, int[] groups) { currentSubgroupThread = 0; } - result[t] = new ThreadParams( + result.add(new ThreadParams( t, threads, currentGroup, totalGroups, currentSubgroup, totalSubgroups, currentGroupThread, totalGroupThreads, currentSubgroupThread, groups[currentSubgroup] - ); + ) + ); currentGroupThread++; currentSubgroupThread++; @@ -318,10 +328,8 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa // preparing the worker runnables BenchmarkTask[] runners = new BenchmarkTask[numThreads]; - - ThreadParams[] threadParamses = distributeThreads(numThreads, benchmarkParams.getThreadGroups()); for (int i = 0; i < runners.length; i++) { - runners[i] = new BenchmarkTask(control, threadParamses[i]); + runners[i] = new BenchmarkTask(control); } long waitDeadline = System.nanoTime() + benchmarkParams.getTimeout().convertTo(TimeUnit.NANOSECONDS); @@ -424,14 +432,11 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa * Worker body. */ class BenchmarkTask implements Callable { - private volatile Thread runner; private final InfraControl control; - private final ThreadParams threadParams; - BenchmarkTask(InfraControl control, ThreadParams threadParams) { + BenchmarkTask(InfraControl control) { this.control = control; - this.threadParams = threadParams; } @Override @@ -441,7 +446,8 @@ public BenchmarkTaskResult call() throws Exception { runner = Thread.currentThread(); // go for the run - return (BenchmarkTaskResult) method.invoke(instances.get(), control, threadParams); + ThreadData td = threadData.get(); + return (BenchmarkTaskResult) method.invoke(td.instance, control, td.params); } catch (Throwable e) { // about to fail the iteration; // compensate for missed sync-iteration latches, we don't care about that anymore @@ -470,4 +476,27 @@ public BenchmarkTaskResult call() throws Exception { } } + /** + * Handles thread-local data for each worker that should not change + * between the iterations. + */ + private static class ThreadData { + /** + * Synthetic benchmark instance, which holds the benchmark metadata. + * Expected to be touched by a single thread only. + */ + final Object instance; + + /** + * Thread parameters. Among other things, holds the thread's place + * in group distribution, and thus should be the same for a given thread. + */ + final ThreadParams params; + + public ThreadData(Object instance, ThreadParams params) { + this.instance = instance; + this.params = params; + } + } + } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/DistributeGroupsTest.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/DistributeGroupsTest.java index 4facd2185..3cdbf7506 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/DistributeGroupsTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/DistributeGroupsTest.java @@ -28,276 +28,278 @@ import org.junit.Test; import org.openjdk.jmh.infra.ThreadParams; +import java.util.List; + public class DistributeGroupsTest { @Test public void test1() { - ThreadParams[] controls = BenchmarkHandler.distributeThreads(1, new int[]{1}); + List controls = BenchmarkHandler.distributeThreads(1, new int[]{1}); - Assert.assertEquals(1, controls.length); + Assert.assertEquals(1, controls.size()); // threads agree on thread count, and enumerated - Assert.assertEquals(1, controls[0].getThreadCount()); - Assert.assertEquals(0, controls[0].getThreadIndex()); + Assert.assertEquals(1, controls.get(0).getThreadCount()); + Assert.assertEquals(0, controls.get(0).getThreadIndex()); // one group with a single thread - Assert.assertEquals(1, controls[0].getGroupCount()); - Assert.assertEquals(0, controls[0].getGroupIndex()); + Assert.assertEquals(1, controls.get(0).getGroupCount()); + Assert.assertEquals(0, controls.get(0).getGroupIndex()); // the thread is alone in the group - Assert.assertEquals(1, controls[0].getGroupThreadCount()); - Assert.assertEquals(0, controls[0].getGroupThreadIndex()); + Assert.assertEquals(1, controls.get(0).getGroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); // no subgroups in the group - Assert.assertEquals(1, controls[0].getSubgroupCount()); - Assert.assertEquals(0, controls[0].getSubgroupIndex()); + Assert.assertEquals(1, controls.get(0).getSubgroupCount()); + Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); // the thread is alone in the subgroup - Assert.assertEquals(1, controls[0].getSubgroupThreadCount()); - Assert.assertEquals(0, controls[0].getSubgroupThreadIndex()); + Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); } @Test public void test2() { - ThreadParams[] controls = BenchmarkHandler.distributeThreads(2, new int[]{1}); + List controls = BenchmarkHandler.distributeThreads(2, new int[]{1}); - Assert.assertEquals(2, controls.length); + Assert.assertEquals(2, controls.size()); // threads agree on thread count, and enumerated - Assert.assertEquals(2, controls[0].getThreadCount()); - Assert.assertEquals(2, controls[1].getThreadCount()); - Assert.assertEquals(0, controls[0].getThreadIndex()); - Assert.assertEquals(1, controls[1].getThreadIndex()); + Assert.assertEquals(2, controls.get(0).getThreadCount()); + Assert.assertEquals(2, controls.get(1).getThreadCount()); + Assert.assertEquals(0, controls.get(0).getThreadIndex()); + Assert.assertEquals(1, controls.get(1).getThreadIndex()); // two groups, each for a single thread - Assert.assertEquals(2, controls[0].getGroupCount()); - Assert.assertEquals(2, controls[1].getGroupCount()); - Assert.assertEquals(0, controls[0].getGroupIndex()); - Assert.assertEquals(1, controls[1].getGroupIndex()); + Assert.assertEquals(2, controls.get(0).getGroupCount()); + Assert.assertEquals(2, controls.get(1).getGroupCount()); + Assert.assertEquals(0, controls.get(0).getGroupIndex()); + Assert.assertEquals(1, controls.get(1).getGroupIndex()); // each thread is alone in the group - Assert.assertEquals(1, controls[0].getGroupThreadCount()); - Assert.assertEquals(1, controls[1].getGroupThreadCount()); - Assert.assertEquals(0, controls[0].getGroupThreadIndex()); - Assert.assertEquals(0, controls[1].getGroupThreadIndex()); + Assert.assertEquals(1, controls.get(0).getGroupThreadCount()); + Assert.assertEquals(1, controls.get(1).getGroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); + Assert.assertEquals(0, controls.get(1).getGroupThreadIndex()); // no subgroups in the group - Assert.assertEquals(1, controls[0].getSubgroupCount()); - Assert.assertEquals(1, controls[1].getSubgroupCount()); - Assert.assertEquals(0, controls[0].getSubgroupIndex()); - Assert.assertEquals(0, controls[1].getSubgroupIndex()); + Assert.assertEquals(1, controls.get(0).getSubgroupCount()); + Assert.assertEquals(1, controls.get(1).getSubgroupCount()); + Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); + Assert.assertEquals(0, controls.get(1).getSubgroupIndex()); // each thread is alone in the subgroup - Assert.assertEquals(1, controls[0].getSubgroupThreadCount()); - Assert.assertEquals(1, controls[1].getSubgroupThreadCount()); - Assert.assertEquals(0, controls[0].getSubgroupThreadIndex()); - Assert.assertEquals(0, controls[1].getSubgroupThreadIndex()); + Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); + Assert.assertEquals(1, controls.get(1).getSubgroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); + Assert.assertEquals(0, controls.get(1).getSubgroupThreadIndex()); } @Test public void test3() { // First "subgroup" is ignored - ThreadParams[] controls = BenchmarkHandler.distributeThreads(2, new int[]{0, 1}); + List controls = BenchmarkHandler.distributeThreads(2, new int[]{0, 1}); - Assert.assertEquals(2, controls.length); + Assert.assertEquals(2, controls.size()); // threads agree on thread count, and enumerated - Assert.assertEquals(2, controls[0].getThreadCount()); - Assert.assertEquals(2, controls[1].getThreadCount()); - Assert.assertEquals(0, controls[0].getThreadIndex()); - Assert.assertEquals(1, controls[1].getThreadIndex()); + Assert.assertEquals(2, controls.get(0).getThreadCount()); + Assert.assertEquals(2, controls.get(1).getThreadCount()); + Assert.assertEquals(0, controls.get(0).getThreadIndex()); + Assert.assertEquals(1, controls.get(1).getThreadIndex()); // two groups, each for a single thread - Assert.assertEquals(2, controls[0].getGroupCount()); - Assert.assertEquals(2, controls[1].getGroupCount()); - Assert.assertEquals(0, controls[0].getGroupIndex()); - Assert.assertEquals(1, controls[1].getGroupIndex()); + Assert.assertEquals(2, controls.get(0).getGroupCount()); + Assert.assertEquals(2, controls.get(1).getGroupCount()); + Assert.assertEquals(0, controls.get(0).getGroupIndex()); + Assert.assertEquals(1, controls.get(1).getGroupIndex()); // each thread is alone in the group - Assert.assertEquals(1, controls[0].getGroupThreadCount()); - Assert.assertEquals(1, controls[1].getGroupThreadCount()); - Assert.assertEquals(0, controls[0].getGroupThreadIndex()); - Assert.assertEquals(0, controls[1].getGroupThreadIndex()); + Assert.assertEquals(1, controls.get(0).getGroupThreadCount()); + Assert.assertEquals(1, controls.get(1).getGroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); + Assert.assertEquals(0, controls.get(1).getGroupThreadIndex()); // two subgroups, but first is not populated - Assert.assertEquals(2, controls[0].getSubgroupCount()); - Assert.assertEquals(2, controls[1].getSubgroupCount()); - Assert.assertEquals(1, controls[0].getSubgroupIndex()); - Assert.assertEquals(1, controls[1].getSubgroupIndex()); + Assert.assertEquals(2, controls.get(0).getSubgroupCount()); + Assert.assertEquals(2, controls.get(1).getSubgroupCount()); + Assert.assertEquals(1, controls.get(0).getSubgroupIndex()); + Assert.assertEquals(1, controls.get(1).getSubgroupIndex()); // each thread is alone in the subgroup - Assert.assertEquals(1, controls[0].getSubgroupThreadCount()); - Assert.assertEquals(1, controls[1].getSubgroupThreadCount()); - Assert.assertEquals(0, controls[0].getSubgroupThreadIndex()); - Assert.assertEquals(0, controls[1].getSubgroupThreadIndex()); + Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); + Assert.assertEquals(1, controls.get(1).getSubgroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); + Assert.assertEquals(0, controls.get(1).getSubgroupThreadIndex()); } @Test public void test4() { - ThreadParams[] controls = BenchmarkHandler.distributeThreads(2, new int[]{1, 1}); + List controls = BenchmarkHandler.distributeThreads(2, new int[]{1, 1}); - Assert.assertEquals(2, controls.length); + Assert.assertEquals(2, controls.size()); // threads agree on thread count, and enumerated - Assert.assertEquals(2, controls[0].getThreadCount()); - Assert.assertEquals(2, controls[1].getThreadCount()); - Assert.assertEquals(0, controls[0].getThreadIndex()); - Assert.assertEquals(1, controls[1].getThreadIndex()); + Assert.assertEquals(2, controls.get(0).getThreadCount()); + Assert.assertEquals(2, controls.get(1).getThreadCount()); + Assert.assertEquals(0, controls.get(0).getThreadIndex()); + Assert.assertEquals(1, controls.get(1).getThreadIndex()); // one group only - Assert.assertEquals(1, controls[0].getGroupCount()); - Assert.assertEquals(1, controls[1].getGroupCount()); - Assert.assertEquals(0, controls[0].getGroupIndex()); - Assert.assertEquals(0, controls[1].getGroupIndex()); + Assert.assertEquals(1, controls.get(0).getGroupCount()); + Assert.assertEquals(1, controls.get(1).getGroupCount()); + Assert.assertEquals(0, controls.get(0).getGroupIndex()); + Assert.assertEquals(0, controls.get(1).getGroupIndex()); // both threads share the group - Assert.assertEquals(2, controls[0].getGroupThreadCount()); - Assert.assertEquals(2, controls[1].getGroupThreadCount()); - Assert.assertEquals(0, controls[0].getGroupThreadIndex()); - Assert.assertEquals(1, controls[1].getGroupThreadIndex()); + Assert.assertEquals(2, controls.get(0).getGroupThreadCount()); + Assert.assertEquals(2, controls.get(1).getGroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); + Assert.assertEquals(1, controls.get(1).getGroupThreadIndex()); // two subgroups, threads in different subgroups - Assert.assertEquals(2, controls[0].getSubgroupCount()); - Assert.assertEquals(2, controls[1].getSubgroupCount()); - Assert.assertEquals(0, controls[0].getSubgroupIndex()); - Assert.assertEquals(1, controls[1].getSubgroupIndex()); + Assert.assertEquals(2, controls.get(0).getSubgroupCount()); + Assert.assertEquals(2, controls.get(1).getSubgroupCount()); + Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); + Assert.assertEquals(1, controls.get(1).getSubgroupIndex()); // each subgroup has a single thread - Assert.assertEquals(1, controls[0].getSubgroupThreadCount()); - Assert.assertEquals(1, controls[1].getSubgroupThreadCount()); - Assert.assertEquals(0, controls[0].getSubgroupThreadIndex()); - Assert.assertEquals(0, controls[1].getSubgroupThreadIndex()); + Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); + Assert.assertEquals(1, controls.get(1).getSubgroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); + Assert.assertEquals(0, controls.get(1).getSubgroupThreadIndex()); } @Test public void test5() { - ThreadParams[] controls = BenchmarkHandler.distributeThreads(3, new int[]{1, 2}); + List controls = BenchmarkHandler.distributeThreads(3, new int[]{1, 2}); - Assert.assertEquals(3, controls.length); + Assert.assertEquals(3, controls.size()); // threads agree on thread count, and enumerated - Assert.assertEquals(3, controls[0].getThreadCount()); - Assert.assertEquals(3, controls[1].getThreadCount()); - Assert.assertEquals(3, controls[2].getThreadCount()); - Assert.assertEquals(0, controls[0].getThreadIndex()); - Assert.assertEquals(1, controls[1].getThreadIndex()); - Assert.assertEquals(2, controls[2].getThreadIndex()); + Assert.assertEquals(3, controls.get(0).getThreadCount()); + Assert.assertEquals(3, controls.get(1).getThreadCount()); + Assert.assertEquals(3, controls.get(2).getThreadCount()); + Assert.assertEquals(0, controls.get(0).getThreadIndex()); + Assert.assertEquals(1, controls.get(1).getThreadIndex()); + Assert.assertEquals(2, controls.get(2).getThreadIndex()); // one group only - Assert.assertEquals(1, controls[0].getGroupCount()); - Assert.assertEquals(1, controls[1].getGroupCount()); - Assert.assertEquals(1, controls[2].getGroupCount()); - Assert.assertEquals(0, controls[0].getGroupIndex()); - Assert.assertEquals(0, controls[1].getGroupIndex()); - Assert.assertEquals(0, controls[2].getGroupIndex()); + Assert.assertEquals(1, controls.get(0).getGroupCount()); + Assert.assertEquals(1, controls.get(1).getGroupCount()); + Assert.assertEquals(1, controls.get(2).getGroupCount()); + Assert.assertEquals(0, controls.get(0).getGroupIndex()); + Assert.assertEquals(0, controls.get(1).getGroupIndex()); + Assert.assertEquals(0, controls.get(2).getGroupIndex()); // all threads share the group - Assert.assertEquals(3, controls[0].getGroupThreadCount()); - Assert.assertEquals(3, controls[1].getGroupThreadCount()); - Assert.assertEquals(3, controls[2].getGroupThreadCount()); - Assert.assertEquals(0, controls[0].getGroupThreadIndex()); - Assert.assertEquals(1, controls[1].getGroupThreadIndex()); - Assert.assertEquals(2, controls[2].getGroupThreadIndex()); + Assert.assertEquals(3, controls.get(0).getGroupThreadCount()); + Assert.assertEquals(3, controls.get(1).getGroupThreadCount()); + Assert.assertEquals(3, controls.get(2).getGroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); + Assert.assertEquals(1, controls.get(1).getGroupThreadIndex()); + Assert.assertEquals(2, controls.get(2).getGroupThreadIndex()); // two subgroups, first thread in distinct subgroup - Assert.assertEquals(2, controls[0].getSubgroupCount()); - Assert.assertEquals(2, controls[1].getSubgroupCount()); - Assert.assertEquals(2, controls[2].getSubgroupCount()); - Assert.assertEquals(0, controls[0].getSubgroupIndex()); - Assert.assertEquals(1, controls[1].getSubgroupIndex()); - Assert.assertEquals(1, controls[2].getSubgroupIndex()); + Assert.assertEquals(2, controls.get(0).getSubgroupCount()); + Assert.assertEquals(2, controls.get(1).getSubgroupCount()); + Assert.assertEquals(2, controls.get(2).getSubgroupCount()); + Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); + Assert.assertEquals(1, controls.get(1).getSubgroupIndex()); + Assert.assertEquals(1, controls.get(2).getSubgroupIndex()); // first subgroup has a single thread, second has two threads - Assert.assertEquals(1, controls[0].getSubgroupThreadCount()); - Assert.assertEquals(2, controls[1].getSubgroupThreadCount()); - Assert.assertEquals(2, controls[2].getSubgroupThreadCount()); - Assert.assertEquals(0, controls[0].getSubgroupThreadIndex()); - Assert.assertEquals(0, controls[1].getSubgroupThreadIndex()); - Assert.assertEquals(1, controls[2].getSubgroupThreadIndex()); + Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); + Assert.assertEquals(2, controls.get(1).getSubgroupThreadCount()); + Assert.assertEquals(2, controls.get(2).getSubgroupThreadCount()); + Assert.assertEquals(0, controls.get(0).getSubgroupThreadIndex()); + Assert.assertEquals(0, controls.get(1).getSubgroupThreadIndex()); + Assert.assertEquals(1, controls.get(2).getSubgroupThreadIndex()); } @Test public void test6() { - ThreadParams[] controls = BenchmarkHandler.distributeThreads(6, new int[]{1, 2}); + List controls = BenchmarkHandler.distributeThreads(6, new int[]{1, 2}); - Assert.assertEquals(6, controls.length); + Assert.assertEquals(6, controls.size()); // threads agree on thread count, and enumerated - Assert.assertEquals(6, controls[0].getThreadCount()); - Assert.assertEquals(6, controls[1].getThreadCount()); - Assert.assertEquals(6, controls[2].getThreadCount()); - Assert.assertEquals(6, controls[3].getThreadCount()); - Assert.assertEquals(6, controls[4].getThreadCount()); - Assert.assertEquals(6, controls[5].getThreadCount()); - - Assert.assertEquals(0, controls[0].getThreadIndex()); - Assert.assertEquals(1, controls[1].getThreadIndex()); - Assert.assertEquals(2, controls[2].getThreadIndex()); - Assert.assertEquals(3, controls[3].getThreadIndex()); - Assert.assertEquals(4, controls[4].getThreadIndex()); - Assert.assertEquals(5, controls[5].getThreadIndex()); + Assert.assertEquals(6, controls.get(0).getThreadCount()); + Assert.assertEquals(6, controls.get(1).getThreadCount()); + Assert.assertEquals(6, controls.get(2).getThreadCount()); + Assert.assertEquals(6, controls.get(3).getThreadCount()); + Assert.assertEquals(6, controls.get(4).getThreadCount()); + Assert.assertEquals(6, controls.get(5).getThreadCount()); + + Assert.assertEquals(0, controls.get(0).getThreadIndex()); + Assert.assertEquals(1, controls.get(1).getThreadIndex()); + Assert.assertEquals(2, controls.get(2).getThreadIndex()); + Assert.assertEquals(3, controls.get(3).getThreadIndex()); + Assert.assertEquals(4, controls.get(4).getThreadIndex()); + Assert.assertEquals(5, controls.get(5).getThreadIndex()); // two groups - Assert.assertEquals(2, controls[0].getGroupCount()); - Assert.assertEquals(2, controls[1].getGroupCount()); - Assert.assertEquals(2, controls[2].getGroupCount()); - Assert.assertEquals(2, controls[3].getGroupCount()); - Assert.assertEquals(2, controls[4].getGroupCount()); - Assert.assertEquals(2, controls[5].getGroupCount()); - - Assert.assertEquals(0, controls[0].getGroupIndex()); - Assert.assertEquals(0, controls[1].getGroupIndex()); - Assert.assertEquals(0, controls[2].getGroupIndex()); - Assert.assertEquals(1, controls[3].getGroupIndex()); - Assert.assertEquals(1, controls[4].getGroupIndex()); - Assert.assertEquals(1, controls[5].getGroupIndex()); + Assert.assertEquals(2, controls.get(0).getGroupCount()); + Assert.assertEquals(2, controls.get(1).getGroupCount()); + Assert.assertEquals(2, controls.get(2).getGroupCount()); + Assert.assertEquals(2, controls.get(3).getGroupCount()); + Assert.assertEquals(2, controls.get(4).getGroupCount()); + Assert.assertEquals(2, controls.get(5).getGroupCount()); + + Assert.assertEquals(0, controls.get(0).getGroupIndex()); + Assert.assertEquals(0, controls.get(1).getGroupIndex()); + Assert.assertEquals(0, controls.get(2).getGroupIndex()); + Assert.assertEquals(1, controls.get(3).getGroupIndex()); + Assert.assertEquals(1, controls.get(4).getGroupIndex()); + Assert.assertEquals(1, controls.get(5).getGroupIndex()); // two groups, three threads each - Assert.assertEquals(3, controls[0].getGroupThreadCount()); - Assert.assertEquals(3, controls[1].getGroupThreadCount()); - Assert.assertEquals(3, controls[2].getGroupThreadCount()); - Assert.assertEquals(3, controls[3].getGroupThreadCount()); - Assert.assertEquals(3, controls[4].getGroupThreadCount()); - Assert.assertEquals(3, controls[5].getGroupThreadCount()); - - Assert.assertEquals(0, controls[0].getGroupThreadIndex()); - Assert.assertEquals(1, controls[1].getGroupThreadIndex()); - Assert.assertEquals(2, controls[2].getGroupThreadIndex()); - Assert.assertEquals(0, controls[3].getGroupThreadIndex()); - Assert.assertEquals(1, controls[4].getGroupThreadIndex()); - Assert.assertEquals(2, controls[5].getGroupThreadIndex()); + Assert.assertEquals(3, controls.get(0).getGroupThreadCount()); + Assert.assertEquals(3, controls.get(1).getGroupThreadCount()); + Assert.assertEquals(3, controls.get(2).getGroupThreadCount()); + Assert.assertEquals(3, controls.get(3).getGroupThreadCount()); + Assert.assertEquals(3, controls.get(4).getGroupThreadCount()); + Assert.assertEquals(3, controls.get(5).getGroupThreadCount()); + + Assert.assertEquals(0, controls.get(0).getGroupThreadIndex()); + Assert.assertEquals(1, controls.get(1).getGroupThreadIndex()); + Assert.assertEquals(2, controls.get(2).getGroupThreadIndex()); + Assert.assertEquals(0, controls.get(3).getGroupThreadIndex()); + Assert.assertEquals(1, controls.get(4).getGroupThreadIndex()); + Assert.assertEquals(2, controls.get(5).getGroupThreadIndex()); // two subgroups: first subgroup has a single thread, second has two threads - Assert.assertEquals(2, controls[0].getSubgroupCount()); - Assert.assertEquals(2, controls[1].getSubgroupCount()); - Assert.assertEquals(2, controls[2].getSubgroupCount()); - Assert.assertEquals(2, controls[3].getSubgroupCount()); - Assert.assertEquals(2, controls[4].getSubgroupCount()); - Assert.assertEquals(2, controls[5].getSubgroupCount()); - - Assert.assertEquals(0, controls[0].getSubgroupIndex()); - Assert.assertEquals(1, controls[1].getSubgroupIndex()); - Assert.assertEquals(1, controls[2].getSubgroupIndex()); - Assert.assertEquals(0, controls[3].getSubgroupIndex()); - Assert.assertEquals(1, controls[4].getSubgroupIndex()); - Assert.assertEquals(1, controls[5].getSubgroupIndex()); + Assert.assertEquals(2, controls.get(0).getSubgroupCount()); + Assert.assertEquals(2, controls.get(1).getSubgroupCount()); + Assert.assertEquals(2, controls.get(2).getSubgroupCount()); + Assert.assertEquals(2, controls.get(3).getSubgroupCount()); + Assert.assertEquals(2, controls.get(4).getSubgroupCount()); + Assert.assertEquals(2, controls.get(5).getSubgroupCount()); + + Assert.assertEquals(0, controls.get(0).getSubgroupIndex()); + Assert.assertEquals(1, controls.get(1).getSubgroupIndex()); + Assert.assertEquals(1, controls.get(2).getSubgroupIndex()); + Assert.assertEquals(0, controls.get(3).getSubgroupIndex()); + Assert.assertEquals(1, controls.get(4).getSubgroupIndex()); + Assert.assertEquals(1, controls.get(5).getSubgroupIndex()); // first subgroup has a single thread, second has two threads - Assert.assertEquals(1, controls[0].getSubgroupThreadCount()); - Assert.assertEquals(2, controls[1].getSubgroupThreadCount()); - Assert.assertEquals(2, controls[2].getSubgroupThreadCount()); - Assert.assertEquals(0, controls[3].getSubgroupThreadIndex()); - Assert.assertEquals(0, controls[4].getSubgroupThreadIndex()); - Assert.assertEquals(1, controls[5].getSubgroupThreadIndex()); - - Assert.assertEquals(1, controls[0].getSubgroupThreadCount()); - Assert.assertEquals(2, controls[1].getSubgroupThreadCount()); - Assert.assertEquals(2, controls[2].getSubgroupThreadCount()); - Assert.assertEquals(0, controls[3].getSubgroupThreadIndex()); - Assert.assertEquals(0, controls[4].getSubgroupThreadIndex()); - Assert.assertEquals(1, controls[5].getSubgroupThreadIndex()); + Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); + Assert.assertEquals(2, controls.get(1).getSubgroupThreadCount()); + Assert.assertEquals(2, controls.get(2).getSubgroupThreadCount()); + Assert.assertEquals(0, controls.get(3).getSubgroupThreadIndex()); + Assert.assertEquals(0, controls.get(4).getSubgroupThreadIndex()); + Assert.assertEquals(1, controls.get(5).getSubgroupThreadIndex()); + + Assert.assertEquals(1, controls.get(0).getSubgroupThreadCount()); + Assert.assertEquals(2, controls.get(1).getSubgroupThreadCount()); + Assert.assertEquals(2, controls.get(2).getSubgroupThreadCount()); + Assert.assertEquals(0, controls.get(3).getSubgroupThreadIndex()); + Assert.assertEquals(0, controls.get(4).getSubgroupThreadIndex()); + Assert.assertEquals(1, controls.get(5).getSubgroupThreadIndex()); } From ad5531bc2fb92b12a2d2d4fc5720c93c62be27df Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 29 Sep 2016 17:44:27 +0200 Subject: [PATCH 040/342] 7901811: Improve @AuxCounters: count events, extend to more types, do not require reset each iteration --- .../{ => auxcounters}/AuxCountersTest.java | 4 +- .../privateFields/BooleanTest.java | 52 ++++++++++ .../counterTypes/privateFields/ByteTest.java | 52 ++++++++++ .../counterTypes/privateFields/CharTest.java | 52 ++++++++++ .../privateFields/DoubleTest.java | 52 ++++++++++ .../counterTypes/privateFields/FloatTest.java | 52 ++++++++++ .../counterTypes/privateFields/IntTest.java | 52 ++++++++++ .../counterTypes/privateFields/LongTest.java | 52 ++++++++++ .../counterTypes/privateFields/ShortTest.java | 52 ++++++++++ .../privateFields/StringTest.java | 52 ++++++++++ .../privateMethods/BooleanTest.java | 52 ++++++++++ .../counterTypes/privateMethods/ByteTest.java | 52 ++++++++++ .../counterTypes/privateMethods/CharTest.java | 52 ++++++++++ .../privateMethods/DoubleTest.java | 52 ++++++++++ .../privateMethods/FloatTest.java | 52 ++++++++++ .../counterTypes/privateMethods/IntTest.java | 52 ++++++++++ .../counterTypes/privateMethods/LongTest.java | 52 ++++++++++ .../privateMethods/ShortTest.java | 52 ++++++++++ .../privateMethods/StringTest.java | 52 ++++++++++ .../counterTypes/privateMethods/VoidTest.java | 52 ++++++++++ .../publicFields/BooleanTest.java | 52 ++++++++++ .../counterTypes/publicFields/ByteTest.java | 52 ++++++++++ .../counterTypes/publicFields/CharTest.java | 52 ++++++++++ .../counterTypes/publicFields/DoubleTest.java | 52 ++++++++++ .../counterTypes/publicFields/FloatTest.java | 52 ++++++++++ .../counterTypes/publicFields/IntTest.java | 52 ++++++++++ .../counterTypes/publicFields/LongTest.java | 52 ++++++++++ .../counterTypes/publicFields/ShortTest.java | 52 ++++++++++ .../counterTypes/publicFields/StringTest.java | 52 ++++++++++ .../publicMethods/BooleanTest.java | 52 ++++++++++ .../counterTypes/publicMethods/ByteTest.java | 52 ++++++++++ .../counterTypes/publicMethods/CharTest.java | 52 ++++++++++ .../publicMethods/DoubleTest.java | 52 ++++++++++ .../counterTypes/publicMethods/FloatTest.java | 52 ++++++++++ .../counterTypes/publicMethods/IntTest.java | 52 ++++++++++ .../counterTypes/publicMethods/LongTest.java | 52 ++++++++++ .../counterTypes/publicMethods/ShortTest.java | 52 ++++++++++ .../publicMethods/StringTest.java | 52 ++++++++++ .../counterTypes/publicMethods/VoidTest.java | 52 ++++++++++ .../auxcounters/scope/BenchmarkStateTest.java | 49 ++++++++++ .../auxcounters/scope/GroupStateTest.java | 50 ++++++++++ .../auxcounters/scope/ThreadStateTest.java | 52 ++++++++++ .../auxcounters/types/events/ByteTest.java | 52 ++++++++++ .../auxcounters/types/events/DoubleTest.java | 52 ++++++++++ .../auxcounters/types/events/FloatTest.java | 52 ++++++++++ .../auxcounters/types/events/IntTest.java | 52 ++++++++++ .../auxcounters/types/events/LongTest.java | 52 ++++++++++ .../auxcounters/types/events/ShortTest.java | 52 ++++++++++ .../types/operations/ByteTest.java | 52 ++++++++++ .../types/operations/DoubleTest.java | 52 ++++++++++ .../types/operations/FloatTest.java | 52 ++++++++++ .../auxcounters/types/operations/IntTest.java | 52 ++++++++++ .../types/operations/LongTest.java | 52 ++++++++++ .../types/operations/ShortTest.java | 52 ++++++++++ .../it/auxcounters/AuxCountersEventsTest.java | 95 ++++++++++++++++++ .../AuxCountersOperationsTest.java | 92 ++++++++++++++++++ .../openjdk/jmh/annotations/AuxCounters.java | 70 ++++++++++---- .../generators/core/BenchmarkGenerator.java | 23 +++-- .../generators/core/StateObjectHandler.java | 96 +++++++++++++------ .../jmh/results/AverageTimeResult.java | 4 +- .../openjdk/jmh/results/ThroughputResult.java | 4 +- .../jmh/samples/JMHSample_23_AuxCounters.java | 41 +++++--- 62 files changed, 3106 insertions(+), 74 deletions(-) rename jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/{ => auxcounters}/AuxCountersTest.java (95%) create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/BooleanTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/ByteTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/CharTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/DoubleTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/FloatTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/IntTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/LongTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/ShortTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/StringTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/BooleanTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/ByteTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/CharTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/DoubleTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/FloatTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/IntTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/LongTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/ShortTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/StringTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/VoidTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/BooleanTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/ByteTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/CharTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/DoubleTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/FloatTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/IntTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/LongTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/ShortTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/StringTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/BooleanTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/ByteTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/CharTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/DoubleTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/FloatTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/IntTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/LongTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/ShortTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/StringTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/VoidTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/BenchmarkStateTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/GroupStateTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/ThreadStateTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ByteTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/DoubleTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/FloatTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/IntTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/LongTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ShortTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/ByteTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/DoubleTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/FloatTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/IntTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/LongTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/ShortTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersEventsTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersOperationsTest.java diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/AuxCountersTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/AuxCountersTest.java similarity index 95% rename from jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/AuxCountersTest.java rename to jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/AuxCountersTest.java index 3e638dcb0..e2e23239f 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/AuxCountersTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/AuxCountersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package org.openjdk.jmh.ct.other; +package org.openjdk.jmh.ct.other.auxcounters; import org.junit.Test; import org.openjdk.jmh.annotations.AuxCounters; diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/BooleanTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/BooleanTest.java new file mode 100644 index 000000000..19f94f695 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/BooleanTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class BooleanTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + boolean cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/ByteTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/ByteTest.java new file mode 100644 index 000000000..f41ba8263 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/ByteTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ByteTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + byte cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/CharTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/CharTest.java new file mode 100644 index 000000000..4640ec98f --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/CharTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class CharTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + char cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/DoubleTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/DoubleTest.java new file mode 100644 index 000000000..9a42b1ec3 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/DoubleTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class DoubleTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + double cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/FloatTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/FloatTest.java new file mode 100644 index 000000000..5a68ff5c9 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/FloatTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class FloatTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + float cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/IntTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/IntTest.java new file mode 100644 index 000000000..dd8be8d2d --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/IntTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class IntTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + int cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/LongTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/LongTest.java new file mode 100644 index 000000000..f24b5c3fe --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/LongTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class LongTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + long cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/ShortTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/ShortTest.java new file mode 100644 index 000000000..4653472af --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/ShortTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ShortTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + short cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/StringTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/StringTest.java new file mode 100644 index 000000000..525e5f9b5 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateFields/StringTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class StringTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + String cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/BooleanTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/BooleanTest.java new file mode 100644 index 000000000..85245bd88 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/BooleanTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class BooleanTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + boolean cnt() { return false; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/ByteTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/ByteTest.java new file mode 100644 index 000000000..352ef123c --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/ByteTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ByteTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + byte cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/CharTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/CharTest.java new file mode 100644 index 000000000..8d82e78b8 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/CharTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class CharTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + char cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/DoubleTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/DoubleTest.java new file mode 100644 index 000000000..505f3aaf6 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/DoubleTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class DoubleTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + double cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/FloatTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/FloatTest.java new file mode 100644 index 000000000..f9aae0949 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/FloatTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class FloatTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + float cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/IntTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/IntTest.java new file mode 100644 index 000000000..c6453fc97 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/IntTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class IntTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + int cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/LongTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/LongTest.java new file mode 100644 index 000000000..33020cdf2 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/LongTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class LongTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + long cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/ShortTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/ShortTest.java new file mode 100644 index 000000000..eab063552 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/ShortTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ShortTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + short cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/StringTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/StringTest.java new file mode 100644 index 000000000..49bd820b0 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/StringTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class StringTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + String cnt() { return ""; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/VoidTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/VoidTest.java new file mode 100644 index 000000000..1344b9745 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/privateMethods/VoidTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.privateMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class VoidTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + void cnt() { } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/BooleanTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/BooleanTest.java new file mode 100644 index 000000000..96b5d982d --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/BooleanTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class BooleanTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public boolean cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "Illegal type for the public field"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/ByteTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/ByteTest.java new file mode 100644 index 000000000..375dceb03 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/ByteTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ByteTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public byte cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/CharTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/CharTest.java new file mode 100644 index 000000000..4c23f5ed3 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/CharTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class CharTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public char cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "Illegal type for the public field"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/DoubleTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/DoubleTest.java new file mode 100644 index 000000000..2452c4c60 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/DoubleTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class DoubleTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public double cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/FloatTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/FloatTest.java new file mode 100644 index 000000000..68a152ea9 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/FloatTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class FloatTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public float cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/IntTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/IntTest.java new file mode 100644 index 000000000..491b8acd1 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/IntTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class IntTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public int cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/LongTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/LongTest.java new file mode 100644 index 000000000..f71b0d314 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/LongTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class LongTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public long cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/ShortTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/ShortTest.java new file mode 100644 index 000000000..c05664fbd --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/ShortTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ShortTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public short cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/StringTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/StringTest.java new file mode 100644 index 000000000..351331d5b --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicFields/StringTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicFields; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class StringTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public String cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "Illegal type for the public field"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/BooleanTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/BooleanTest.java new file mode 100644 index 000000000..e643c2602 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/BooleanTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class BooleanTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public boolean cnt() { return false; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "Illegal type for the return type of public method"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/ByteTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/ByteTest.java new file mode 100644 index 000000000..aeff6dc22 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/ByteTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ByteTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public byte cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/CharTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/CharTest.java new file mode 100644 index 000000000..cd30fc9ae --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/CharTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class CharTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public char cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "Illegal type for the return type of public method"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/DoubleTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/DoubleTest.java new file mode 100644 index 000000000..3600d88f8 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/DoubleTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class DoubleTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public double cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/FloatTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/FloatTest.java new file mode 100644 index 000000000..0c51e97a1 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/FloatTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class FloatTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public float cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/IntTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/IntTest.java new file mode 100644 index 000000000..cd56f9b13 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/IntTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class IntTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public int cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/LongTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/LongTest.java new file mode 100644 index 000000000..5f2514f00 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/LongTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class LongTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public long cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/ShortTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/ShortTest.java new file mode 100644 index 000000000..80becb591 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/ShortTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ShortTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public short cnt() { return 0; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/StringTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/StringTest.java new file mode 100644 index 000000000..0385f25f4 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/StringTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class StringTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public String cnt() { return ""; } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "Illegal type for the return type of public method"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/VoidTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/VoidTest.java new file mode 100644 index 000000000..a601e5769 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/VoidTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.counterTypes.publicMethods; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class VoidTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + public void cnt() { } + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "Illegal type for the return type of public method"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/BenchmarkStateTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/BenchmarkStateTest.java new file mode 100644 index 000000000..e9d17affb --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/BenchmarkStateTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.scope; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.ct.CompileTest; + +public class BenchmarkStateTest { + + @AuxCounters + @State(Scope.Benchmark) + public static class S { + + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "can only be used with Scope.Thread states"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/GroupStateTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/GroupStateTest.java new file mode 100644 index 000000000..703f2406e --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/GroupStateTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.scope; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.ct.CompileTest; + +public class GroupStateTest { + + @AuxCounters + @State(Scope.Group) + public static class S { + + } + + @Benchmark + @Group("T") + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertFail(this.getClass(), "can only be used with Scope.Thread states"); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/ThreadStateTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/ThreadStateTest.java new file mode 100644 index 000000000..5dfe7deab --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/scope/ThreadStateTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.scope; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ThreadStateTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ByteTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ByteTest.java new file mode 100644 index 000000000..717484bcf --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ByteTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.events; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ByteTest { + + @AuxCounters(AuxCounters.Type.EVENTS) + @State(Scope.Thread) + public static class S { + public byte cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/DoubleTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/DoubleTest.java new file mode 100644 index 000000000..d43832b82 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/DoubleTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.events; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class DoubleTest { + + @AuxCounters(AuxCounters.Type.EVENTS) + @State(Scope.Thread) + public static class S { + public double cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/FloatTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/FloatTest.java new file mode 100644 index 000000000..662347291 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/FloatTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.events; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class FloatTest { + + @AuxCounters(AuxCounters.Type.EVENTS) + @State(Scope.Thread) + public static class S { + public float cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/IntTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/IntTest.java new file mode 100644 index 000000000..6e7fc0d8a --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/IntTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.events; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class IntTest { + + @AuxCounters(AuxCounters.Type.EVENTS) + @State(Scope.Thread) + public static class S { + public int cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/LongTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/LongTest.java new file mode 100644 index 000000000..5ba96859d --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/LongTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.events; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class LongTest { + + @AuxCounters(AuxCounters.Type.EVENTS) + @State(Scope.Thread) + public static class S { + public long cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ShortTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ShortTest.java new file mode 100644 index 000000000..28e8b1498 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/events/ShortTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.events; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ShortTest { + + @AuxCounters(AuxCounters.Type.EVENTS) + @State(Scope.Thread) + public static class S { + public short cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/ByteTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/ByteTest.java new file mode 100644 index 000000000..65b61f837 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/ByteTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.operations; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ByteTest { + + @AuxCounters(AuxCounters.Type.OPERATIONS) + @State(Scope.Thread) + public static class S { + public byte cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/DoubleTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/DoubleTest.java new file mode 100644 index 000000000..ab398fc05 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/DoubleTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.operations; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class DoubleTest { + + @AuxCounters(AuxCounters.Type.OPERATIONS) + @State(Scope.Thread) + public static class S { + public double cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/FloatTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/FloatTest.java new file mode 100644 index 000000000..67e87c645 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/FloatTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.operations; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class FloatTest { + + @AuxCounters(AuxCounters.Type.OPERATIONS) + @State(Scope.Thread) + public static class S { + public float cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/IntTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/IntTest.java new file mode 100644 index 000000000..b2123d221 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/IntTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.operations; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class IntTest { + + @AuxCounters(AuxCounters.Type.OPERATIONS) + @State(Scope.Thread) + public static class S { + public int cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/LongTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/LongTest.java new file mode 100644 index 000000000..b8a5da75a --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/LongTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.operations; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class LongTest { + + @AuxCounters(AuxCounters.Type.OPERATIONS) + @State(Scope.Thread) + public static class S { + public long cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/ShortTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/ShortTest.java new file mode 100644 index 000000000..40b70eb54 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/types/operations/ShortTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters.types.operations; + +import org.junit.Test; +import org.openjdk.jmh.annotations.AuxCounters; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +public class ShortTest { + + @AuxCounters(AuxCounters.Type.OPERATIONS) + @State(Scope.Thread) + public static class S { + public short cnt; + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersEventsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersEventsTest.java new file mode 100644 index 000000000..537a9bdd2 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersEventsTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.auxcounters; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.concurrent.TimeUnit; + + +@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +public class AuxCountersEventsTest { + + @AuxCounters(AuxCounters.Type.EVENTS) + @State(Scope.Thread) + public static class Counters { + public int cnt; + } + + @Benchmark + public void test(Counters cnt) { + if (cnt.cnt == 0) { + // set event once + cnt.cnt = 42; + } + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .shouldFailOnError(true) + .build(); + + RunResult result = new Runner(opts).runSingle(); + Result prim = result.getPrimaryResult(); + Result scnd = result.getSecondaryResults().get("cnt"); + + switch (mode) { + case Throughput: + case AverageTime: { + Assert.assertNotNull("@AuxCounter result exists for " + mode, scnd); + Assert.assertEquals(prim.getSampleCount(), scnd.getSampleCount()); + Assert.assertEquals("#", scnd.getScoreUnit()); + + // 5 iterations, each returns exactly 42 events + Assert.assertEquals(5 * 42, scnd.getScore(), 0.001); + Assert.assertEquals(Double.NaN, scnd.getScoreError(), 0.001); + break; + } + default: { + Assert.assertNull("@AuxCounter does not exist for " + mode, scnd); + } + } + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersOperationsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersOperationsTest.java new file mode 100644 index 000000000..413098433 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/auxcounters/AuxCountersOperationsTest.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.auxcounters; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.concurrent.TimeUnit; + + +@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +public class AuxCountersOperationsTest { + + @AuxCounters(AuxCounters.Type.OPERATIONS) + @State(Scope.Thread) + public static class Counters { + public int cnt; + } + + @Benchmark + public void test(Counters cnt) { + cnt.cnt++; + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .shouldFailOnError(true) + .build(); + + RunResult result = new Runner(opts).runSingle(); + Result prim = result.getPrimaryResult(); + Result scnd = result.getSecondaryResults().get("cnt"); + + switch (mode) { + case Throughput: + case AverageTime: { + Assert.assertNotNull("@AuxCounter result exists for " + mode, scnd); + + // Should match primary metric exactly. + Assert.assertEquals(prim.getSampleCount(), scnd.getSampleCount()); + Assert.assertEquals(prim.getScoreUnit(), scnd.getScoreUnit()); + Assert.assertEquals(prim.getScore(), scnd.getScore(), 0.001); + Assert.assertEquals(prim.getScoreError(), scnd.getScoreError(), 0.001); + break; + } + default: { + Assert.assertNull("@AuxCounter does not exist for " + mode, scnd); + } + } + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/AuxCounters.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/AuxCounters.java index 456d325a1..2c74de491 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/AuxCounters.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/AuxCounters.java @@ -32,31 +32,63 @@ /** *

{@link AuxCounters} annotation can be used to mark {@link State} objects * as the bearers of auxiliary secondary results. Marking the class with this annotation - * will enable JMH to look for public {int, long} fields, as well as public methods - * returning {int, long} values, and treat their values as the operation counts - * in current iteration.

+ * will make JMH to treat its public fields and result-returning public methods + * as the base for the secondary benchmark metrics.

* - *

This allows to override the default operations counter with the user-provided one. - * Instead of relying on JMH itself counting the number of {@link Benchmark} calls, - * users can tell JMH how many calls actually happened. Note that it might require - * modifying the counter at each {@link Benchmark} invocation.

- * - *

THIS IS AN EXPERIMENTAL API, which means, among other things:

+ *

Properties:

* *
    - *
  • It can be modified, deprecated, and/or removed in future
  • - *
  • It is not available for all {@link BenchmarkMode}-s
  • - *
  • It is currently allowed only at {@link Scope#Thread} level, because JMH metric - * aggregator expects the distinct counters coming from every measurement thread.
  • - *
  • You have to explicitly reset the state if you don't want the counters - * to be shared across the iterations.
  • - *
  • The counter names are plain field/method names. The namespace for counters - * is shared across all states participating in the run. JMH will fail to compile - * the benchmark if there is an ambiguity around what counter comes from what - * state class.
  • + *
  • Auxiliary counters are not available for every {@link BenchmarkMode}, + * because not every mode counts time or operations. {@link Mode#AverageTime} + * and {@link Mode#Throughput} are always supported.
  • + * + *
  • {@link AuxCounters} annotation is only available for {@link Scope#Thread} + * state objects. It is a compile-time error to use it with other states. This means + * the counters are thread-local in nature.
  • + * + *
  • Only public fields and methods are considered as metrics. If you don't want + * a field/method to be captured as metric, do not make it public.
  • + * + *
  • Only numeric fields and numeric-returning methods are considered as + * metrics. These include all primitives and their corresponding boxed counterTypes, + * except {@code boolean}/{@link Boolean} and {@code char}/{@link Character}
  • + * + *
  • Public fields in {@link AuxCounters} instances would be reset before + * starting the iteration, and read back at the end of iteration. This allows + * benchmark code to avoid complicated lifecycle handling for these objects.
  • + * + *
  • The counter names are generated from field/method names. The namespace for + * counters is shared across all states participating in the run. JMH will fail to + * compile the benchmark if there is an ambiguity around what counter comes from + * what {@link AuxCounters} class. + *
  • *
+ * + *

CAVEAT: THIS IS AN EXPERIMENTAL API, it may be changed or removed in future + * without prior warning. This is a sharp tool, use with care.

*/ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface AuxCounters { + + Type value() default Type.OPERATIONS; + + enum Type { + /** + * Counts "operations", which should be relevant to the number of + * times {@link Benchmark} method was executed. If this counter is + * incremented on each {@link Benchmark} method invocation, then it + * will produce a metric similar to the primary benchmark result. + * This counter will be normalized to benchmark time by the harness. + */ + OPERATIONS, + + /** + * Counts "events", the one-off things in the lifetime of workload. + * This counter would not get normalized to time. + */ + EVENTS, + + ; + } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index c9aef95f6..14ca6dc8e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -533,7 +533,8 @@ private void generateImport(PrintWriter writer) { Mode.class, Fork.class, Measurement.class, Threads.class, Warmup.class, BenchmarkMode.class, RawResults.class, ResultRole.class, Field.class, BenchmarkParams.class, IterationParams.class, - Blackhole.class, Control.class + Blackhole.class, Control.class, + ScalarResult.class, AggregationPolicy.class }; for (Class c : imports) { @@ -654,8 +655,8 @@ private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode be writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } - for (String ops : states.getAuxResultNames(method)) { - writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.SECONDARY, \"" + ops + "\", " + states.getAuxResultAccessor(method, ops) + ", res.getTime(), benchmarkParams.getTimeUnit()));"); + for (String res : states.getAuxResults(method, "ThroughputResult")) { + writer.println(ident(3) + "results.add(" + res + ");"); } methodEpilog(writer, methodGroup); @@ -695,6 +696,12 @@ private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode be } } + private void addAuxCounters(PrintWriter writer, String resName, StateObjectHandler states, MethodInfo method) { + for (String res : states.getAuxResults(method, resName)) { + writer.println(ident(3) + "results.add(" + res + ");"); + } + } + private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { writer.println(ident(1) + "public BenchmarkTaskResult " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {"); @@ -782,9 +789,8 @@ private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode b writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } - for (String ops : states.getAuxResultNames(method)) { - writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.SECONDARY, \"" + ops + "\", " + states.getAuxResultAccessor(method, ops) + ", res.getTime(), benchmarkParams.getTimeUnit()));"); - } + addAuxCounters(writer, "AverageTimeResult", states, method); + methodEpilog(writer, methodGroup); writer.println(ident(3) + "return results;"); @@ -1108,6 +1114,11 @@ private void iterationProlog(PrintWriter writer, int prefix, MethodInfo method, for (String s : states.getIterationSetups(method)) writer.println(ident(prefix) + s); writer.println(); + + // reset @AuxCounters + for (String s : states.getAuxResets(method)) writer.println(ident(prefix) + s); + writer.println(); + } private void iterationEpilog(PrintWriter writer, int prefix, MethodInfo method, StateObjectHandler states) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 5d6e36d5c..ee60800de 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -53,7 +53,9 @@ class StateObjectHandler { private final Multimap benchmarkArgs; private final Multimap auxNames = new HashMultimap(); + private final Map auxType = new HashMap(); private final Map auxAccessors = new HashMap(); + private final Map auxResettable = new HashMap(); public StateObjectHandler(CompilerControlPlugin compileControl) { this.compileControl = compileControl; @@ -281,7 +283,8 @@ private void bindState(MethodInfo execMethod, StateObject so, ClassInfo ci) { validateState(ci); // auxiliary result, produce the accessors - if (ci.getAnnotation(AuxCounters.class) != null) { + AuxCounters auxCountAnn = ci.getAnnotation(AuxCounters.class); + if (auxCountAnn != null) { if (so.scope != Scope.Thread) { throw new GenerationException("@" + AuxCounters.class.getSimpleName() + " can only be used with " + Scope.class.getSimpleName() + "." + Scope.Thread + " states.", ci); @@ -289,34 +292,39 @@ private void bindState(MethodInfo execMethod, StateObject so, ClassInfo ci) { for (FieldInfo sub : ci.getFields()) { if (sub.isPublic()) { - String fieldType = sub.getType().getQualifiedName(); - if (fieldType.equals("int") || fieldType.equals("long")) { - String name = sub.getName(); - String meth = execMethod.getName(); - auxNames.put(meth, name); - String prev = auxAccessors.put(meth + name, so.localIdentifier + "." + name); - if (prev != null) { - throw new GenerationException("Conflicting @" + AuxCounters.class.getSimpleName() + + if (!isAuxCompatible(sub.getType().getQualifiedName())) { + throw new GenerationException("Illegal type for the public field in @" + AuxCounters.class.getSimpleName() + ".", sub); + } + String name = sub.getName(); + String meth = execMethod.getName(); + auxNames.put(meth, name); + auxType.put(name, auxCountAnn.value()); + auxResettable.put(name, true); + String prev = auxAccessors.put(meth + name, so.localIdentifier + "." + name); + if (prev != null) { + throw new GenerationException("Conflicting @" + AuxCounters.class.getSimpleName() + " counters. Make sure there are no @" + State.class.getSimpleName() + "-s with the same counter " + " injected into this method.", sub); - } } } } for (MethodInfo sub : ci.getMethods()) { if (sub.isPublic()) { - String returnType = sub.getReturnType(); - if (returnType.equals("int") || returnType.equals("long")) { - String name = sub.getName(); - String meth = execMethod.getName(); - auxNames.put(meth, name); - String prev = auxAccessors.put(meth + name, so.localIdentifier + "." + name + "()"); - if (prev != null) { - throw new GenerationException("Conflicting @" + AuxCounters.class.getSimpleName() + - " counters. Make sure there are no @" + State.class.getSimpleName() + "-s with the same counter " + - " injected into this method.", sub); - } + if (!isAuxCompatible(sub.getReturnType())) { + throw new GenerationException("Illegal type for the return type of public method in @" + AuxCounters.class.getSimpleName() + ".", sub); + } + + String name = sub.getName(); + String meth = execMethod.getName(); + auxNames.put(meth, name); + auxType.put(name, auxCountAnn.value()); + auxResettable.put(name, false); + String prev = auxAccessors.put(meth + name, so.localIdentifier + "." + name + "()"); + if (prev != null) { + throw new GenerationException("Conflicting @" + AuxCounters.class.getSimpleName() + + " counters. Make sure there are no @" + State.class.getSimpleName() + "-s with the same counter " + + " injected into this method.", sub); } } } @@ -348,6 +356,16 @@ private void bindState(MethodInfo execMethod, StateObject so, ClassInfo ci) { } } + private boolean isAuxCompatible(String typeName) { + if (typeName.equals("byte") || typeName.equals("java.lang.Byte")) return true; + if (typeName.equals("short") || typeName.equals("java.lang.Short")) return true; + if (typeName.equals("int") || typeName.equals("java.lang.Integer")) return true; + if (typeName.equals("float") || typeName.equals("java.lang.Float")) return true; + if (typeName.equals("long") || typeName.equals("java.lang.Long")) return true; + if (typeName.equals("double") || typeName.equals("java.lang.Double")) return true; + return false; + } + private void checkParam(FieldInfo fi) { if (fi.isFinal()) { throw new GenerationException( @@ -972,18 +990,38 @@ public StateObject getImplicit(String label) { return implicits.get(label); } - public Collection getAuxResultNames(MethodInfo method) { - return auxNames.get(method.getName()); - } - - public String getAuxResultAccessor(MethodInfo method, String name) { - return auxAccessors.get(method.getName() + name); - } - public void addImports(PrintWriter writer) { for (StateObject so : cons(stateObjects)) { writer.println("import " + so.packageName + "." + so.type + ";"); } } + public Collection getAuxResets(MethodInfo method) { + Collection result = new ArrayList(); + for (String name : auxNames.get(method.getName())) { + if (auxResettable.get(name)) { + result.add(auxAccessors.get(method.getName() + name) + " = 0;"); + } + } + return result; + } + + public Collection getAuxResults(MethodInfo method, String opResName) { + Collection result = new ArrayList(); + for (String ops : auxNames.get(method.getName())) { + AuxCounters.Type type = auxType.get(ops); + switch (type) { + case OPERATIONS: + result.add("new " + opResName + "(ResultRole.SECONDARY, \"" + ops + "\", " + + auxAccessors.get(method.getName() + ops) + ", res.getTime(), benchmarkParams.getTimeUnit())"); + break; + case EVENTS: + result.add("new ScalarResult(\"" + ops + "\", " + auxAccessors.get(method.getName() + ops) + ", \"#\", AggregationPolicy.SUM)"); + break; + default: + throw new GenerationException("Unknown @" + AuxCounters.class + " type: " + type, method); + } + } + return result; + } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/AverageTimeResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/AverageTimeResult.java index 3a2e959b3..e21c509f8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/AverageTimeResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/AverageTimeResult.java @@ -37,9 +37,9 @@ public class AverageTimeResult extends Result { private static final long serialVersionUID = 6937689337229703312L; - public AverageTimeResult(ResultRole mode, String label, long operations, long durationNs, TimeUnit tu) { + public AverageTimeResult(ResultRole mode, String label, double operations, long durationNs, TimeUnit tu) { this(mode, label, - of(1.0D * durationNs / (operations * TimeUnit.NANOSECONDS.convert(1, tu))), + of(durationNs / (operations * TimeUnit.NANOSECONDS.convert(1, tu))), TimeValue.tuToString(tu) + "/op"); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/ThroughputResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/ThroughputResult.java index 1e5238100..91ce71b8e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/ThroughputResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/ThroughputResult.java @@ -37,9 +37,9 @@ public class ThroughputResult extends Result { private static final long serialVersionUID = 7269598073169413322L; - public ThroughputResult(ResultRole role, String label, long operations, long durationNs, TimeUnit outputTimeUnit) { + public ThroughputResult(ResultRole role, String label, double operations, long durationNs, TimeUnit outputTimeUnit) { this(role, label, - of(1.0D * operations * TimeUnit.NANOSECONDS.convert(1, outputTimeUnit) / durationNs), + of(operations * TimeUnit.NANOSECONDS.convert(1, outputTimeUnit) / durationNs), "ops/" + TimeValue.tuToString(outputTimeUnit), AggregationPolicy.SUM); } diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_23_AuxCounters.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_23_AuxCounters.java index f801fd144..af55df6e6 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_23_AuxCounters.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_23_AuxCounters.java @@ -33,11 +33,9 @@ import org.openjdk.jmh.annotations.AuxCounters; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; -import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; @@ -48,8 +46,8 @@ import java.util.concurrent.TimeUnit; @OutputTimeUnit(TimeUnit.SECONDS) -@Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) -@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) public class JMHSample_23_AuxCounters { @@ -62,30 +60,35 @@ public class JMHSample_23_AuxCounters { * the limitations. */ - @AuxCounters @State(Scope.Thread) - public static class AdditionalCounters { - public int case1, case2; - - @Setup(Level.Iteration) - public void clean() { - case1 = case2 = 0; - } + @AuxCounters(AuxCounters.Type.OPERATIONS) + public static class OpCounters { + // These fields would be counted as metrics + public int case1; + public int case2; + // This accessor will also produce a metric public int total() { return case1 + case2; } } + @State(Scope.Thread) + @AuxCounters(AuxCounters.Type.EVENTS) + public static class EventCounters { + // This field would be counted as metric + public int wows; + } + /* * This code measures the "throughput" in two parts of the branch. * The @AuxCounters state above holds the counters which we increment * ourselves, and then let JMH to use their values in the performance - * calculations. Note how we reset the counters on each iteration. + * calculations. */ @Benchmark - public void measure(AdditionalCounters counters) { + public void splitBranch(OpCounters counters) { if (Math.random() < 0.1) { counters.case1++; } else { @@ -93,6 +96,16 @@ public void measure(AdditionalCounters counters) { } } + @Benchmark + public void runSETI(EventCounters counters) { + float random = (float) Math.random(); + float wowSignal = (float) Math.PI / 4; + if (random == wowSignal) { + // WOW, that's unusual. + counters.wows++; + } + } + /* * ============================== HOW TO RUN THIS TEST: ==================================== * From bf50f5789983c2317d359d920462f0422b907957 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 30 Sep 2016 11:04:24 +0200 Subject: [PATCH 041/342] 7901812: ASM generator treats "" methods are regular methods --- .../main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java index 61f439b98..11f6d6793 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java @@ -120,9 +120,10 @@ public FieldVisitor visitField(int access, String name, String desc, String sign public MethodVisitor visitMethod(int access, final String methodName, String methodDesc, String signature, String[] exceptions) { ASMMethodInfo mi = new ASMMethodInfo(super.visitMethod(access, methodName, methodDesc, signature, exceptions), classInfos, this, access, methodName, methodDesc, signature); - methods.add(mi); if (methodName.equals("")) { constructors.add(mi); + } else { + methods.add(mi); } return mi; } From c9f5ea0039362dc83c87cc1c2cd3a2139807f191 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 30 Sep 2016 12:53:54 +0200 Subject: [PATCH 042/342] 7901809: Failing @Setup can be entered multiple times Implement quick abort when failures are detected in helper methods. --- .../BenchmarkInvocationFailureTimesTest.java | 76 ++++++++++++++++++ .../BenchmarkIterationFailureTimesTest.java | 76 ++++++++++++++++++ .../fail/BenchmarkTrialFailureTimesTest.java | 76 ++++++++++++++++++ .../fail/GroupInvocationFailureTimesTest.java | 78 ++++++++++++++++++ .../fail/GroupIterationFailureTimesTest.java | 79 +++++++++++++++++++ .../fail/GroupTrialFailureTimesTest.java | 77 ++++++++++++++++++ .../ThreadInvocationFailureTimesTest.java | 76 ++++++++++++++++++ .../fail/ThreadIterationFailureTimesTest.java | 76 ++++++++++++++++++ .../fail/ThreadTrialFailureTimesTest.java | 76 ++++++++++++++++++ .../generators/core/BenchmarkGenerator.java | 7 +- .../generators/core/StateObjectHandler.java | 24 +++++- .../jmh/runner/BenchmarkException.java | 4 + .../openjdk/jmh/runner/BenchmarkHandler.java | 58 +++++++++----- .../jmh/runner/FailureAssistException.java | 33 ++++++++ .../org/openjdk/jmh/runner/InfraControl.java | 11 ++- 15 files changed, 800 insertions(+), 27 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkInvocationFailureTimesTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkIterationFailureTimesTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkTrialFailureTimesTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupInvocationFailureTimesTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupIterationFailureTimesTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupTrialFailureTimesTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadInvocationFailureTimesTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadIterationFailureTimesTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadTrialFailureTimesTest.java create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/runner/FailureAssistException.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkInvocationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkInvocationFailureTimesTest.java new file mode 100644 index 000000000..2818c0b72 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkInvocationFailureTimesTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times.fail; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.atomic.AtomicInteger; + +@State(Scope.Benchmark) +public class BenchmarkInvocationFailureTimesTest { + + private static final AtomicInteger count = new AtomicInteger(); + + @Setup(Level.Invocation) + public void setup() { + count.incrementAndGet(); + throw new IllegalStateException("Failing"); + } + + @Benchmark + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + count.set(0); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .threads(Threads.MAX) + .forks(0) + .build(); + new Runner(opt).run(); + + Assert.assertEquals(1, count.get()); + } + } + } + + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkIterationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkIterationFailureTimesTest.java new file mode 100644 index 000000000..1429952d8 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkIterationFailureTimesTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times.fail; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.atomic.AtomicInteger; + +@State(Scope.Benchmark) +public class BenchmarkIterationFailureTimesTest { + + private static final AtomicInteger count = new AtomicInteger(); + + @Setup(Level.Iteration) + public void setup() { + count.incrementAndGet(); + throw new IllegalStateException("Failing"); + } + + @Benchmark + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + count.set(0); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .threads(Threads.MAX) + .forks(0) + .build(); + new Runner(opt).run(); + + Assert.assertEquals(1, count.get()); + } + } + } + + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkTrialFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkTrialFailureTimesTest.java new file mode 100644 index 000000000..fe399c8b5 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkTrialFailureTimesTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times.fail; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.atomic.AtomicInteger; + +@State(Scope.Benchmark) +public class BenchmarkTrialFailureTimesTest { + + private static final AtomicInteger count = new AtomicInteger(); + + @Setup(Level.Trial) + public void setup() { + count.incrementAndGet(); + throw new IllegalStateException("Failing"); + } + + @Benchmark + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + count.set(0); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .threads(Threads.MAX) + .forks(0) + .build(); + new Runner(opt).run(); + + Assert.assertEquals(1, count.get()); + } + } + } + + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupInvocationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupInvocationFailureTimesTest.java new file mode 100644 index 000000000..59d5a8238 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupInvocationFailureTimesTest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times.fail; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.atomic.AtomicInteger; + +@State(Scope.Group) +public class GroupInvocationFailureTimesTest { + + private static final AtomicInteger count = new AtomicInteger(); + + @Setup(Level.Invocation) + public void setup() { + count.incrementAndGet(); + throw new IllegalStateException("Failing"); + } + + @Benchmark + @Group + @GroupThreads(4) // should match the total number of threads + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + count.set(0); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .threads(4) + .forks(0) + .build(); + new Runner(opt).run(); + + Assert.assertEquals(1, count.get()); + } + } + } + + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupIterationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupIterationFailureTimesTest.java new file mode 100644 index 000000000..dbc65a7bb --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupIterationFailureTimesTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times.fail; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.atomic.AtomicInteger; + +@State(Scope.Group) +public class GroupIterationFailureTimesTest { + + private static final AtomicInteger count = new AtomicInteger(); + + @Setup(Level.Iteration) + public void setup() { + System.err.println("Enter " + Thread.currentThread()); + count.incrementAndGet(); + throw new IllegalStateException("Failing"); + } + + @Benchmark + @Group + @GroupThreads(4) // should match the total number of threads + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + count.set(0); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .threads(4) + .forks(0) + .build(); + new Runner(opt).run(); + + Assert.assertEquals(1, count.get()); + } + } + } + + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupTrialFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupTrialFailureTimesTest.java new file mode 100644 index 000000000..c7526cd2c --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupTrialFailureTimesTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times.fail; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.atomic.AtomicInteger; + +@State(Scope.Group) +public class GroupTrialFailureTimesTest { + + private static final AtomicInteger count = new AtomicInteger(); + + @Setup(Level.Trial) + public void setup() { + count.incrementAndGet(); + throw new IllegalStateException("Failing"); + } + + @Benchmark + @Group + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + count.set(0); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .threads(Threads.MAX) + .forks(0) + .build(); + new Runner(opt).run(); + + Assert.assertEquals(1, count.get()); + } + } + } + + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadInvocationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadInvocationFailureTimesTest.java new file mode 100644 index 000000000..f64c6adaf --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadInvocationFailureTimesTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times.fail; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.atomic.AtomicInteger; + +@State(Scope.Thread) +public class ThreadInvocationFailureTimesTest { + + private static final AtomicInteger count = new AtomicInteger(); + + @Setup(Level.Invocation) + public void setup() { + count.incrementAndGet(); + throw new IllegalStateException("Failing"); + } + + @Benchmark + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + count.set(0); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .threads(1) + .forks(0) + .build(); + new Runner(opt).run(); + + Assert.assertEquals(1, count.get()); + } + } + } + + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadIterationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadIterationFailureTimesTest.java new file mode 100644 index 000000000..e7825c9e0 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadIterationFailureTimesTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times.fail; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.atomic.AtomicInteger; + +@State(Scope.Thread) +public class ThreadIterationFailureTimesTest { + + private static final AtomicInteger count = new AtomicInteger(); + + @Setup(Level.Iteration) + public void setup() { + count.incrementAndGet(); + throw new IllegalStateException("Failing"); + } + + @Benchmark + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + count.set(0); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .threads(1) + .forks(0) + .build(); + new Runner(opt).run(); + + Assert.assertEquals(1, count.get()); + } + } + } + + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadTrialFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadTrialFailureTimesTest.java new file mode 100644 index 000000000..73cdc3555 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadTrialFailureTimesTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.times.fail; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.atomic.AtomicInteger; + +@State(Scope.Thread) +public class ThreadTrialFailureTimesTest { + + private static final AtomicInteger count = new AtomicInteger(); + + @Setup(Level.Trial) + public void setup() { + count.incrementAndGet(); + throw new IllegalStateException("Failing"); + } + + @Benchmark + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + + count.set(0); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .mode(mode) + .threads(1) + .forks(0) + .build(); + new Runner(opt).run(); + + Assert.assertEquals(1, count.get()); + } + } + } + + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 14ca6dc8e..44cb561ff 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -27,10 +27,8 @@ import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.*; import org.openjdk.jmh.results.*; -import org.openjdk.jmh.runner.BenchmarkList; -import org.openjdk.jmh.runner.BenchmarkListEntry; +import org.openjdk.jmh.runner.*; import org.openjdk.jmh.runner.Defaults; -import org.openjdk.jmh.runner.InfraControl; import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; @@ -534,7 +532,8 @@ private void generateImport(PrintWriter writer) { BenchmarkMode.class, RawResults.class, ResultRole.class, Field.class, BenchmarkParams.class, IterationParams.class, Blackhole.class, Control.class, - ScalarResult.class, AggregationPolicy.class + ScalarResult.class, AggregationPolicy.class, + FailureAssistException.class }; for (Class c : imports) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index ee60800de..f4fbf4348 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -619,6 +619,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H if (type == HelperType.SETUP) { result.add("if (" + so.type + ".setup" + helperLevel + "MutexUpdater.compareAndSet(" + so.localIdentifier + ", 0, 1)) {"); result.add(" try {"); + result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" if (!" + so.localIdentifier + ".ready" + helperLevel + ") {"); for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) { @@ -628,11 +629,15 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H } result.add(" " + so.localIdentifier + ".ready" + helperLevel + " = true;"); result.add(" }"); + result.add(" } catch (Throwable t) {"); + result.add(" control.isFailing = true;"); + result.add(" throw t;"); result.add(" } finally {"); result.add(" " + so.type + ".setup" + helperLevel + "MutexUpdater.set(" + so.localIdentifier + ", 0);"); result.add(" }"); result.add("} else {"); result.add(" while (" + so.type + ".setup" + helperLevel + "MutexUpdater.get(" + so.localIdentifier + ") == 1) {"); + result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" if (Thread.interrupted()) throw new InterruptedException();"); result.add(" }"); result.add("}"); @@ -645,6 +650,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H if (type == HelperType.TEARDOWN) { result.add("if (" + so.type + ".tear" + helperLevel + "MutexUpdater.compareAndSet(" + so.localIdentifier + ", 0, 1)) {"); result.add(" try {"); + result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" if (" + so.localIdentifier + ".ready" + helperLevel + ") {"); for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) { @@ -654,6 +660,9 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H } result.add(" " + so.localIdentifier + ".ready" + helperLevel + " = false;"); result.add(" }"); + result.add(" } catch (Throwable t) {"); + result.add(" control.isFailing = true;"); + result.add(" throw t;"); result.add(" } finally {"); result.add(" " + so.type + ".tear" + helperLevel + "MutexUpdater.set(" + so.localIdentifier + ", 0);"); result.add(" }"); @@ -673,6 +682,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H result.add(" " + so.localIdentifier + "_backoff = Math.max(1024, " + so.localIdentifier + "_backoff * 2);"); } + result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" if (Thread.interrupted()) throw new InterruptedException();"); result.add(" }"); result.add("}"); @@ -727,6 +737,8 @@ public List getStateInitializers() { result.add(" return val;"); result.add(" }"); result.add(" synchronized(this.getClass()) {"); + result.add(" try {"); + result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" val = " + so.fieldIdentifier + ";"); result.add(" if (val != null) {"); result.add(" return val;"); @@ -750,6 +762,10 @@ public List getStateInitializers() { } result.add(" val.ready" + Level.Trial + " = true;"); result.add(" " + so.fieldIdentifier + " = val;"); + result.add(" } catch (Throwable t) {"); + result.add(" control.isFailing = true;"); + result.add(" throw t;"); + result.add(" }"); result.add(" }"); result.add(" return val;"); result.add("}"); @@ -762,7 +778,7 @@ public List getStateInitializers() { result.add(so.type + " " + so.fieldIdentifier + ";"); result.add(""); result.add(so.type + " _jmh_tryInit_" + so.fieldIdentifier + "(InfraControl control" + soDependency_TypeArgs(so) + ") throws Throwable {"); - + result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" " + so.type + " val = " + so.fieldIdentifier + ";"); result.add(" if (val == null) {"); result.add(" val = new " + so.type + "();"); @@ -802,6 +818,8 @@ public List getStateInitializers() { result.add(" return val;"); result.add(" }"); result.add(" synchronized(this.getClass()) {"); + result.add(" try {"); + result.add(" if (control.isFailing) throw new FailureAssistException();"); result.add(" val = " + so.fieldIdentifier + "_map.get(groupIdx);"); result.add(" if (val != null) {"); result.add(" return val;"); @@ -825,6 +843,10 @@ public List getStateInitializers() { } result.add(" " + "val.ready" + Level.Trial + " = true;"); result.add(" " + so.fieldIdentifier + "_map.put(groupIdx, val);"); + result.add(" } catch (Throwable t) {"); + result.add(" control.isFailing = true;"); + result.add(" throw t;"); + result.add(" }"); result.add(" }"); result.add(" return val;"); result.add("}"); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java index 96ac567c9..35ae0b8c7 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java @@ -33,4 +33,8 @@ public class BenchmarkException extends RuntimeException { public BenchmarkException(Throwable ex) { super(ex); } + + public BenchmarkException(String msg, Throwable ex) { + super(msg, ex); + } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index 7dd243c9a..810b7f9f4 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -400,29 +400,43 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa // either normally or abnormally. This means, Future.get() would never block. long allOps = 0; long measuredOps = 0; - IterationResult result; - try { - for (Future fr : completed) { - try { - BenchmarkTaskResult btr = fr.get(); - iterationResults.addAll(btr.getResults()); - allOps += btr.getAllOps(); - measuredOps += btr.getMeasuredOps(); - } catch (ExecutionException ex) { - // unwrap: ExecutionException -> Throwable-wrapper -> InvocationTargetException - Throwable cause = ex.getCause().getCause().getCause(); - throw new BenchmarkException(cause); - } catch (InterruptedException ex) { - throw new BenchmarkException(ex); + + List errors = new ArrayList(); + for (Future fr : completed) { + try { + BenchmarkTaskResult btr = fr.get(); + iterationResults.addAll(btr.getResults()); + allOps += btr.getAllOps(); + measuredOps += btr.getMeasuredOps(); + } catch (ExecutionException ex) { + // unwrap: ExecutionException -> Throwable-wrapper -> InvocationTargetException + Throwable cause = ex.getCause().getCause().getCause(); + + // record exception, unless it is the assist exception + if (!(cause instanceof FailureAssistException)) { + errors.add(cause); } + } catch (InterruptedException ex) { + // cannot happen here, Future.get() should never block. + throw new BenchmarkException(ex); } - } finally { - result = new IterationResult(benchmarkParams, params, new IterationResultMetaData(allOps, measuredOps)); - result.addResults(iterationResults); + } + + IterationResult result = new IterationResult(benchmarkParams, params, new IterationResultMetaData(allOps, measuredOps)); + result.addResults(iterationResults); + + // profilers stop when after all threads are confirmed to be + // finished to capture the edge behaviors; or, on a failure path + stopProfilers(benchmarkParams, params, result); - // profilers stop when after all threads are confirmed to be - // finished to capture the edge behaviors; or, on a failure path - stopProfilers(benchmarkParams, params, result); + if (!errors.isEmpty()) { + Throwable first = errors.get(0); + if (errors.size() > 1) { + // TODO: Once we switch to JDK 7, make use of #addSupressed. + throw new BenchmarkException(errors.size() + " pending exceptions, reporting the first", first); + } else { + throw new BenchmarkException(first); + } } return result; @@ -450,6 +464,10 @@ public BenchmarkTaskResult call() throws Exception { return (BenchmarkTaskResult) method.invoke(td.instance, control, td.params); } catch (Throwable e) { // about to fail the iteration; + + // notify other threads we have failed + control.isFailing = true; + // compensate for missed sync-iteration latches, we don't care about that anymore control.preSetupForce(); control.preTearDownForce(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/FailureAssistException.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/FailureAssistException.java new file mode 100644 index 000000000..616d9edf8 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/FailureAssistException.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.runner; + +/** + * Thrown by worker threads when they detect other threads have failed. + */ +public class FailureAssistException extends RuntimeException { + + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java index f5af4c9ab..ac0743674 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java @@ -44,7 +44,7 @@ public class InfraControl extends InfraControlL4 { * @see org.openjdk.jmh.infra.Blackhole description for the rationale */ static { - Utils.check(InfraControl.class, "isDone"); + Utils.check(InfraControl.class, "isDone", "isFailing"); Utils.check(InfraControl.class, "volatileSpoiler"); Utils.check(InfraControl.class, "preSetup", "preTearDown"); Utils.check(InfraControl.class, "lastIteration"); @@ -133,11 +133,18 @@ abstract class InfraControlL1 extends InfraControlL0 { } abstract class InfraControlL2 extends InfraControlL1 { - /* Flag for if we are done or not. + /** + * Flag that checks for time expiration. * This is specifically the public field, so to spare one virtual call. */ public volatile boolean isDone; + /** + * Flag that checks for failure experienced by any measurement thread. + * This is specifically the public field, so to spare one virtual call. + */ + public volatile boolean isFailing; + public volatile boolean volatileSpoiler; public final CountDownLatch preSetup; From 18ade4bee01912cd54776dbfc42f87769d765961 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 30 Sep 2016 16:20:22 +0200 Subject: [PATCH 043/342] JMH v1.15 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index cdb2722ff..82db1c5bf 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.15-SNAPSHOT + 1.15 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 523aef765..5f2d66f8a 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.15-SNAPSHOT + 1.15 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index aa88d1cfc..571ebfd4d 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.15-SNAPSHOT + 1.15 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 68aa9eb66..234ac8e06 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.15-SNAPSHOT + 1.15 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 3b462b59e..21f59749c 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index e68cd290c..d58d1697f 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index ff6149209..143630389 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 75df1d45b..08c781a86 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 1a0d5ae7a..38abe1263 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 6ebb37f08..73d897f00 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 5a4b3bfd6..8a2082d6a 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 7db6700d5..72bd67eaa 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 175e68a35..5f986f901 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 56f1ba406..49c45d0b7 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.15-SNAPSHOT + 1.15 JMH Samples diff --git a/pom.xml b/pom.xml index de6794eca..2a4dbbd7f 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.15-SNAPSHOT + 1.15 Java Microbenchmark Harness Parent From 9d739ebd0b1fa8c336e63272ab9c77023d30c5e7 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 30 Sep 2016 16:20:27 +0200 Subject: [PATCH 044/342] Added tag 1.15 for changeset 318b0c315634 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 03713986d..a39013b3b 100644 --- a/.hgtags +++ b/.hgtags @@ -78,3 +78,4 @@ eb41bdab96cf7579db48fc39a9fa423b54bf4786 1.12 7ff584954008f5dc877c590df5d902a0022f7456 1.13 b9ea316668ae3e6510bf6ebe21625218f966c15a 1.14 eaf181b4eac282ae20f9cb43ad221cf404a951c0 1.14.1 +318b0c31563430446b42e63095d90bc922fc62ee 1.15 From 4cb0c9ff0e6a01c588c19e799ef83bda12b1b18c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 30 Sep 2016 16:20:46 +0200 Subject: [PATCH 045/342] Continue in 1.16-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 82db1c5bf..5697894c9 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.15 + 1.16-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 5f2d66f8a..ebceb689d 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.15 + 1.16-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 571ebfd4d..8b8a4146a 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.15 + 1.16-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 234ac8e06..ee484f2b5 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.15 + 1.16-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 21f59749c..5b907a1ab 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index d58d1697f..7f90c734f 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 143630389..75619321a 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 08c781a86..4e341d22d 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 38abe1263..d58e10900 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 73d897f00..5541cee5c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 8a2082d6a..cbe5b81d8 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 72bd67eaa..0474e84e8 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 5f986f901..a43844e22 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 49c45d0b7..9ce74b6a6 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.15 + 1.16-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 2a4dbbd7f..050c1bf1e 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.15 + 1.16-SNAPSHOT Java Microbenchmark Harness Parent From ded987512240a97e8f8764a2f0586515aae779c6 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 5 Oct 2016 19:21:18 +0200 Subject: [PATCH 046/342] 7901813: @AuxCounters method constraints conflict with @State ones Relax the requirement for "void" return type, implicitly allowing @Setup/@TearDown-s. --- .../other/auxcounters/HelperConflictTest.java | 65 +++++++++++++++++++ .../counterTypes/publicMethods/VoidTest.java | 2 +- .../openjdk/jmh/annotations/AuxCounters.java | 7 +- .../generators/core/StateObjectHandler.java | 2 +- 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/HelperConflictTest.java diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/HelperConflictTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/HelperConflictTest.java new file mode 100644 index 000000000..89259673e --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/HelperConflictTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2016, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.other.auxcounters; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.ct.CompileTest; + +public class HelperConflictTest { + + @AuxCounters + @State(Scope.Thread) + public static class S { + @Setup(Level.Trial) + public void setupTrial() {} + + @Setup(Level.Iteration) + public void setupIteration() {} + + @Setup(Level.Invocation) + public void setupInvocation() {} + + @TearDown(Level.Invocation) + public void tearDownInvocation() {} + + @TearDown(Level.Iteration) + public void tearDownIteration() {} + + @TearDown(Level.Trial) + public void tearDownTrial() {} + } + + @Benchmark + public void benchmark(S s) { + // intentionally left blank + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/VoidTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/VoidTest.java index a601e5769..25e8adba6 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/VoidTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/other/auxcounters/counterTypes/publicMethods/VoidTest.java @@ -46,7 +46,7 @@ public void benchmark(S s) { @Test public void compileTest() { - CompileTest.assertFail(this.getClass(), "Illegal type for the return type of public method"); + CompileTest.assertOK(this.getClass()); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/AuxCounters.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/AuxCounters.java index 2c74de491..3572ed9d2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/AuxCounters.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/AuxCounters.java @@ -51,7 +51,12 @@ * *
  • Only numeric fields and numeric-returning methods are considered as * metrics. These include all primitives and their corresponding boxed counterTypes, - * except {@code boolean}/{@link Boolean} and {@code char}/{@link Character}
  • + * except {@code boolean}/{@link Boolean} and {@code char}/{@link Character}. + * It is a compile-time error to use the public field/method with incompatible type. + * + *
  • Methods with {@code void} return type are exempted from type checking. + * This means helper {@link Setup} and {@link TearDown} methods are fine in + * {@link AuxCounters}.
  • * *
  • Public fields in {@link AuxCounters} instances would be reset before * starting the iteration, and read back at the end of iteration. This allows diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index f4fbf4348..46d7ae5d7 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -310,7 +310,7 @@ private void bindState(MethodInfo execMethod, StateObject so, ClassInfo ci) { } for (MethodInfo sub : ci.getMethods()) { - if (sub.isPublic()) { + if (sub.isPublic() && !sub.getReturnType().equals("void")) { if (!isAuxCompatible(sub.getReturnType())) { throw new GenerationException("Illegal type for the return type of public method in @" + AuxCounters.class.getSimpleName() + ".", sub); } From 2a084e4121222d23f61bc207ac4447dfab5613c0 Mon Sep 17 00:00:00 2001 From: Jeremy Whiting Date: Fri, 21 Oct 2016 20:28:34 +0200 Subject: [PATCH 047/342] Minor typo in JMHSample_32_BulkWarmup.java --- .../java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java index d6559b20d..aa2666840 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java @@ -129,7 +129,7 @@ public int measure_c2() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_32 -f 1 -wi 5 -i 5 -bm BULK + * $ java -jar target/benchmarks.jar JMHSample_32 -f 1 -wi 5 -i 5 -wm BULK * (we requested a single fork, 5 warmup/measurement iterations, and bulk warmup mode) * * b) Via the Java API: From 3ebd1b916099f43dc016a8489564552abeb9825e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 25 Oct 2016 17:55:17 +0200 Subject: [PATCH 048/342] Minor performance optimization in BenchmarkGenerator.buildAnnotatedSet() --- .../org/openjdk/jmh/generators/core/BenchmarkGenerator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 44cb561ff..fd8c3c205 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -229,10 +229,11 @@ private Multimap buildAnnotatedSet(GeneratorSource source Multimap result = new HashMultimap(); for (ClassInfo currentClass : source.getClasses()) { + if (currentClass.getQualifiedName().contains("generated")) continue; + if (currentClass.isAbstract()) continue; + ClassInfo walk = currentClass; do { - if (currentClass.getQualifiedName().contains("generated")) continue; - if (currentClass.isAbstract()) continue; for (MethodInfo mi : walk.getMethods()) { Benchmark ann = mi.getAnnotation(Benchmark.class); if (ann != null) { From ff3090943223413a6926f2ff6149f4c345fe2b4b Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 9 Nov 2016 09:58:47 +0100 Subject: [PATCH 049/342] JMH v1.16 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 5697894c9..36e8d18d2 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.16-SNAPSHOT + 1.16 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index ebceb689d..f1be80ce8 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.16-SNAPSHOT + 1.16 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 8b8a4146a..6445d81a3 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.16-SNAPSHOT + 1.16 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index ee484f2b5..5c38c7b77 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.16-SNAPSHOT + 1.16 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 5b907a1ab..f9d06553b 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 7f90c734f..dc61f88cb 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 75619321a..fec1f1f99 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 4e341d22d..078af2a75 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index d58e10900..643132a9e 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 5541cee5c..6c1c8523b 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index cbe5b81d8..24473ff3c 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 0474e84e8..ec40e8780 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index a43844e22..50338b80c 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 9ce74b6a6..300537bd6 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.16-SNAPSHOT + 1.16 JMH Samples diff --git a/pom.xml b/pom.xml index 050c1bf1e..2940186e0 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.16-SNAPSHOT + 1.16 Java Microbenchmark Harness Parent From a9312350e6ac7047d207001ed1aa54e49ef2aaf3 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 9 Nov 2016 09:58:55 +0100 Subject: [PATCH 050/342] Added tag 1.16 for changeset 90e9bafa6cd0 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index a39013b3b..28986a30b 100644 --- a/.hgtags +++ b/.hgtags @@ -79,3 +79,4 @@ eb41bdab96cf7579db48fc39a9fa423b54bf4786 1.12 b9ea316668ae3e6510bf6ebe21625218f966c15a 1.14 eaf181b4eac282ae20f9cb43ad221cf404a951c0 1.14.1 318b0c31563430446b42e63095d90bc922fc62ee 1.15 +90e9bafa6cd05172901b336416856561c40d1247 1.16 From 93d9025430f8da1071a9a977180e0e6f3cec8450 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 9 Nov 2016 09:59:11 +0100 Subject: [PATCH 051/342] Continue in 1.17-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 36e8d18d2..edf5d4920 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.16 + 1.17-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index f1be80ce8..9e3adcde2 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.16 + 1.17-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 6445d81a3..0180fa581 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.16 + 1.17-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 5c38c7b77..795b85fad 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.16 + 1.17-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index f9d06553b..4e5239bb2 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index dc61f88cb..03de09f53 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index fec1f1f99..4c1446975 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 078af2a75..fe024cff3 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 643132a9e..e2e8444a7 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 6c1c8523b..b38b27ec6 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 24473ff3c..ef7418921 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index ec40e8780..21891bf17 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 50338b80c..be81dcadd 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 300537bd6..aba762aa2 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.16 + 1.17-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 2940186e0..5e3c17fc0 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.16 + 1.17-SNAPSHOT Java Microbenchmark Harness Parent From aac2794d77c7dd4c1b7f8dc5bd0a0d75666c07fc Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Nov 2016 11:27:48 +0100 Subject: [PATCH 052/342] Drop support for Java 6, set source/target = 1.7 --- jmh-core-benchmarks/pom.xml | 6 +++--- jmh-core-ct/pom.xml | 6 +++--- jmh-core-it/pom.xml | 18 +++++++++--------- jmh-core/pom.xml | 6 +++--- jmh-generator-annprocess/pom.xml | 6 +++--- jmh-generator-asm/pom.xml | 6 +++--- jmh-generator-bytecode/pom.xml | 6 +++--- jmh-generator-reflection/pom.xml | 6 +++--- jmh-samples/pom.xml | 6 +++--- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 03de09f53..68a36452c 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -72,9 +72,9 @@ questions. maven-compiler-plugin 3.0 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 4c1446975..8e6e22079 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -109,9 +109,9 @@ questions. maven-compiler-plugin 3.0 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 -proc:none diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index fe024cff3..a788ff103 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -128,9 +128,9 @@ questions. maven-compiler-plugin 3.0 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 @@ -156,9 +156,9 @@ questions. maven-compiler-plugin 3.0 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 -proc:none @@ -246,9 +246,9 @@ questions. maven-compiler-plugin 3.0 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 -proc:none diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index e2e8444a7..6e9f0d088 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -86,9 +86,9 @@ questions. maven-compiler-plugin 3.1 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 -proc:none diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index b38b27ec6..39d631a4f 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -65,9 +65,9 @@ questions. maven-compiler-plugin 3.1 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 -proc:none diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index ef7418921..7b463390c 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -74,9 +74,9 @@ questions. maven-compiler-plugin 3.1 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 -proc:none diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 21891bf17..28170abd6 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -74,9 +74,9 @@ questions. maven-compiler-plugin 3.1 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 -proc:none diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index be81dcadd..23fa819c1 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -64,9 +64,9 @@ questions. maven-compiler-plugin 3.1 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 -proc:none diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index aba762aa2..6fd291900 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -79,9 +79,9 @@ THE POSSIBILITY OF SUCH DAMAGE. maven-compiler-plugin 3.0 - 1.6 - 1.6 - 1.6 + 1.7 + 1.7 + 1.7 From 09f4ecfa1e731a8f3ba7dd7891862d3835cc7e43 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Nov 2016 11:40:00 +0100 Subject: [PATCH 053/342] Automatic migration to JDK 7 language features --- .../jmh/benchmarks/BlackholeBench.java | 2 +- .../validation/tests/ThreadScalingTest.java | 2 +- .../java/org/openjdk/jmh/ct/CompileTest.java | 8 +-- .../jmh/ct/InMemoryGeneratorDestination.java | 14 +++--- .../jmh/it/bulkwarmup/NonForkedModesTest.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode0_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode1_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode2_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode3_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode4_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode5_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode6_Test.java | 2 +- .../jmh/it/ccontrol/LogConsumeProfiler.java | 2 +- .../params/EmptyLeadingStringParamTest.java | 4 +- .../it/params/EmptyMiddleStringParamTest.java | 4 +- .../params/EmptyTrailingStringParamTest.java | 4 +- .../org/openjdk/jmh/it/params/Shared.java | 2 +- .../jmh/it/profilers/ChangeJVMOptsTest.java | 2 +- .../org/openjdk/jmh/annotations/Mode.java | 2 +- .../generators/core/BenchmarkGenerator.java | 14 +++--- .../core/BenchmarkGeneratorSession.java | 2 +- .../core/BenchmarkGeneratorUtils.java | 16 +++--- .../core/CompilerControlPlugin.java | 6 +-- .../core/FileSystemDestination.java | 4 +- .../jmh/generators/core/Identifiers.java | 6 +-- .../jmh/generators/core/MethodGroup.java | 12 ++--- .../openjdk/jmh/generators/core/Paddings.java | 2 +- .../jmh/generators/core/StateObject.java | 8 +-- .../generators/core/StateObjectHandler.java | 49 ++++++++++--------- .../jmh/profile/AbstractHotspotProfiler.java | 16 ++---- .../jmh/profile/AbstractPerfAsmProfiler.java | 48 +++++++++--------- .../jmh/profile/ClassloaderProfiler.java | 2 +- .../org/openjdk/jmh/profile/GCProfiler.java | 14 ++---- .../jmh/profile/LinuxPerfAsmProfiler.java | 12 ++--- .../jmh/profile/LinuxPerfNormProfiler.java | 8 +-- .../openjdk/jmh/profile/ProfilerFactory.java | 8 +-- .../openjdk/jmh/profile/StackProfiler.java | 10 ++-- .../jmh/profile/WinPerfAsmProfiler.java | 12 ++--- .../openjdk/jmh/results/BenchmarkResult.java | 14 +++--- .../jmh/results/BenchmarkTaskResult.java | 2 +- .../openjdk/jmh/results/IterationResult.java | 12 ++--- .../java/org/openjdk/jmh/results/Result.java | 2 +- .../org/openjdk/jmh/results/RunResult.java | 2 +- .../jmh/results/format/JSONResultFormat.java | 12 ++--- .../jmh/results/format/LaTeXResultFormat.java | 6 +-- .../jmh/results/format/TextResultFormat.java | 6 +-- .../jmh/results/format/XSVResultFormat.java | 2 +- .../jmh/runner/AbstractResourceReader.java | 2 +- .../org/openjdk/jmh/runner/ActionPlan.java | 4 +- .../org/openjdk/jmh/runner/BaseRunner.java | 8 +-- .../openjdk/jmh/runner/BenchmarkHandler.java | 18 +++---- .../org/openjdk/jmh/runner/BenchmarkList.java | 8 +-- .../org/openjdk/jmh/runner/CompilerHints.java | 15 +++--- .../org/openjdk/jmh/runner/ForkedMain.java | 2 +- .../java/org/openjdk/jmh/runner/Runner.java | 34 ++++++------- .../openjdk/jmh/runner/WorkloadParams.java | 2 +- .../jmh/runner/format/TextReportFormat.java | 2 +- .../jmh/runner/link/BinaryLinkClient.java | 5 +- .../jmh/runner/link/BinaryLinkServer.java | 18 +++---- .../jmh/runner/link/ClassConventions.java | 2 +- .../runner/options/CommandLineOptions.java | 18 +++---- .../jmh/runner/options/OptionsBuilder.java | 16 +++--- .../jmh/util/BoundedPriorityQueue.java | 2 +- .../java/org/openjdk/jmh/util/ClassUtils.java | 4 +- .../org/openjdk/jmh/util/Deduplicator.java | 2 +- .../openjdk/jmh/util/DelegatingMultimap.java | 2 +- .../java/org/openjdk/jmh/util/FileUtils.java | 12 ++--- .../org/openjdk/jmh/util/HashsetMultimap.java | 2 +- .../openjdk/jmh/util/InputStreamDrainer.java | 2 +- .../org/openjdk/jmh/util/IntervalMap.java | 2 +- .../org/openjdk/jmh/util/ListStatistics.java | 2 +- .../openjdk/jmh/util/MultisetStatistics.java | 4 +- .../java/org/openjdk/jmh/util/Multisets.java | 6 +-- .../java/org/openjdk/jmh/util/Optional.java | 4 +- .../org/openjdk/jmh/util/SampleBuffer.java | 3 +- .../openjdk/jmh/util/SingletonStatistics.java | 2 +- .../main/java/org/openjdk/jmh/util/Utils.java | 16 +++--- .../jmh/util/lines/TestLineReader.java | 4 +- .../jmh/results/format/ResultFormatTest.java | 6 +-- .../openjdk/jmh/runner/CompilerHintsTest.java | 8 +-- .../jmh/util/BoundedPriorityQueueTest.java | 4 +- .../org/openjdk/jmh/util/MultisetsTest.java | 6 +-- .../org/openjdk/jmh/util/TestLineTest.java | 2 +- .../generators/annotations/APClassInfo.java | 8 +-- .../annotations/APGeneratorSource.java | 6 +-- .../generators/annotations/APMethodInfo.java | 2 +- .../jmh/generators/asm/ASMClassInfo.java | 10 ++-- .../jmh/generators/asm/ASMFieldInfo.java | 2 +- .../jmh/generators/asm/ASMMethodInfo.java | 4 +- .../asm/AnnotationInvocationHandler.java | 17 ++++--- .../jmh/generators/asm/ClassInfoRepo.java | 2 +- .../generators/reflection/RFClassInfo.java | 8 +-- .../reflection/RFConstructorInfo.java | 2 +- .../reflection/RFGeneratorSource.java | 4 +- .../generators/reflection/RFMethodInfo.java | 2 +- .../jmh/samples/JMHSample_25_API_GA.java | 2 +- .../jmh/samples/JMHSample_26_BatchSize.java | 2 +- .../jmh/samples/JMHSample_29_StatesDAG.java | 4 +- .../jmh/samples/JMHSample_30_Interrupts.java | 2 +- .../jmh/samples/JMHSample_31_InfraParams.java | 6 +-- .../jmh/samples/JMHSample_35_Profilers.java | 15 +++--- 101 files changed, 346 insertions(+), 370 deletions(-) diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeBench.java index f34a8d06e..6e266906c 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeBench.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeBench.java @@ -41,7 +41,7 @@ public class BlackholeBench { @Setup(Level.Iteration) public void makeGarbage() { // make some garbage to evict blackhole from the TLAB/eden - strs = new ArrayList(); + strs = new ArrayList<>(); for (int i = 0; i < 100000; i++) { strs.add("str" + i); } diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThreadScalingTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThreadScalingTest.java index f68377f2b..0d25472d5 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThreadScalingTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThreadScalingTest.java @@ -61,7 +61,7 @@ public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println(" Threads are scaled from 1 to the number of hardware threads."); pw.println(); - SortedSet threads = new TreeSet(); + SortedSet threads = new TreeSet<>(); int max = Utils.figureOutHotCPUs(); for (int t = max; t > 0; t /= 2) { threads.add(t); diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java index 814368bdd..55d3accdf 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java @@ -61,7 +61,7 @@ public static void assertFail(Class klass, String error) { Assert.fail("Should have failed."); } - List testErrors = new ArrayList(); + List testErrors = new ArrayList<>(); boolean contains = false; for (String e : destination.getErrors()) { if (!e.startsWith(SRC_PREFIX)) { @@ -119,13 +119,13 @@ public static boolean doTestOther(GeneratorSource source, InMemoryGeneratorDesti return false; } - DiagnosticCollector diagnostics = new DiagnosticCollector(); + DiagnosticCollector diagnostics = new DiagnosticCollector<>(); JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); setupClassOutput(fm); - Collection sources = new ArrayList(); + Collection sources = new ArrayList<>(); for (Map.Entry e : destination.getClasses().entrySet()) { sources.add(new JavaSourceFromString(e.getKey(), e.getValue())); } @@ -146,7 +146,7 @@ public static boolean doTestOther(GeneratorSource source, InMemoryGeneratorDesti } private static boolean doTestAnnprocess(Class klass, InMemoryGeneratorDestination destination) { - DiagnosticCollector diagnostics = new DiagnosticCollector(); + DiagnosticCollector diagnostics = new DiagnosticCollector<>(); JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null); diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java index 0bc4cd0fb..247fbde3d 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java @@ -40,12 +40,12 @@ public class InMemoryGeneratorDestination implements GeneratorDestination { - private List errors = new ArrayList(); - private List warnings = new ArrayList(); - private List infos = new ArrayList(); + private List errors = new ArrayList<>(); + private List warnings = new ArrayList<>(); + private List infos = new ArrayList<>(); - private Map classBodies = new HashMap(); - private Map resourceBodies = new HashMap(); + private Map classBodies = new HashMap<>(); + private Map resourceBodies = new HashMap<>(); @Override public Writer newResource(String resourcePath) throws IOException { @@ -117,7 +117,7 @@ public List getWarnings() { } public Map getClasses() { - Map result = new HashMap(); + Map result = new HashMap<>(); for (Map.Entry e : classBodies.entrySet()) { result.put(e.getKey(), e.getValue().toString()); } @@ -125,7 +125,7 @@ public Map getClasses() { } public Map getResources() { - Map result = new HashMap(); + Map result = new HashMap<>(); for (Map.Entry e : resourceBodies.entrySet()) { result.put(e.getKey(), e.getValue().toString()); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java index 902c36392..af46051ec 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java @@ -48,7 +48,7 @@ @State(Scope.Thread) public class NonForkedModesTest { - private static Queue testSequence = new ConcurrentLinkedQueue(); + private static Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java index 6ac9bfc3d..615020277 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode0_Test { - private static Queue testSequence = new ConcurrentLinkedQueue(); + private static Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java index 0305c9cfc..c5e070a55 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode1_Test { - private static Queue testSequence = new ConcurrentLinkedQueue(); + private static Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java index f185f8778..991330497 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode2_Test { - private static Queue testSequence = new ConcurrentLinkedQueue(); + private static Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java index d9e6fde12..4929c2139 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode3_Test { - private static Queue testSequence = new ConcurrentLinkedQueue(); + private static Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java index fc4c2ebb7..9b0018a49 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode4_Test { - private static Queue testSequence = new ConcurrentLinkedQueue(); + private static Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java index 7d2667212..8fa092043 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java @@ -55,7 +55,7 @@ @State(Scope.Thread) public class WarmupMode5_Test { - private static Queue testSequence = new ConcurrentLinkedQueue(); + private static Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java index 78ebc9ace..ff9741806 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java @@ -55,7 +55,7 @@ @State(Scope.Thread) public class WarmupMode6_Test { - private static Queue testSequence = new ConcurrentLinkedQueue(); + private static Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/LogConsumeProfiler.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/LogConsumeProfiler.java index 9e7965c1c..08e9b7f9d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/LogConsumeProfiler.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/LogConsumeProfiler.java @@ -107,7 +107,7 @@ public static class LogAggregator implements Aggregator { @Override public LogConsumeResult aggregate(Collection results) { String label = null; - Collection allLines = new ArrayList(); + Collection allLines = new ArrayList<>(); for (LogConsumeResult r : results) { label = r.label; allLines.addAll(r.getLines()); diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java index 66d4880ca..83e34acba 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java @@ -62,7 +62,7 @@ public void test_ann() throws RunnerException { Collection res = new Runner(opts).run(); - Set actualP = new HashSet(); + Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } @@ -83,7 +83,7 @@ public void test_api() throws RunnerException { Collection res = new Runner(opts).run(); - Set actualP = new HashSet(); + Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java index 1d5f59d60..82fe6dc97 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java @@ -62,7 +62,7 @@ public void test_ann() throws RunnerException { Collection res = new Runner(opts).run(); - Set actualP = new HashSet(); + Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } @@ -84,7 +84,7 @@ public void test_api() throws RunnerException { Collection res = new Runner(opts).run(); - Set actualP = new HashSet(); + Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java index 6f3fba0e4..7e3bd073e 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java @@ -62,7 +62,7 @@ public void test_ann() throws RunnerException { Collection res = new Runner(opts).run(); - Set actualP = new HashSet(); + Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } @@ -83,7 +83,7 @@ public void test_api() throws RunnerException { Collection res = new Runner(opts).run(); - Set actualP = new HashSet(); + Set actualP = new HashSet<>(); for (RunResult r : res) { actualP.add(r.getParams().getParam("x")); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java index 2965b5bce..81dfd7035 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java @@ -35,7 +35,7 @@ public class Shared { public static void compare(Collection res, int[] xs, String[] ys) { - Set actualPairs = new HashSet(); + Set actualPairs = new HashSet<>(); for (RunResult r : res) { BenchmarkParams params = r.getParams(); actualPairs.add(params.getParam("x") + params.getParam("y")); diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java index aed134347..a6cff8ac4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java @@ -94,7 +94,7 @@ private void prepare() { } private void check() throws IOException { - Set lines = new HashSet(); + Set lines = new HashSet<>(); for (String line : FileUtils.readAllLines(TMP_FILE)) { if (!lines.add(line)) { Assert.fail("Duplicate line: " + line); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java index c4d87b667..6c7c763cc 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java @@ -128,7 +128,7 @@ public static Mode deepValueOf(String name) { } public static List getKnown() { - List res = new ArrayList(); + List res = new ArrayList<>(); for (Mode type : Mode.values()) { res.add(type.name() + "/" + type.shortLabel()); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index fd8c3c205..f1b8254f2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -59,8 +59,8 @@ public class BenchmarkGenerator { private final BenchmarkGeneratorSession session; public BenchmarkGenerator() { - benchmarkInfos = new HashSet(); - processedBenchmarks = new HashSet(); + benchmarkInfos = new HashSet<>(); + processedBenchmarks = new HashSet<>(); compilerControl = new CompilerControlPlugin(); session = new BenchmarkGeneratorSession(); } @@ -123,14 +123,14 @@ public void complete(GeneratorSource source, GeneratorDestination destination) { // Processing completed, final round. // Collect all benchmark entries here - Set entries = new HashSet(); + Set entries = new HashSet<>(); // Try to read the benchmark entries from the previous generator sessions. // Incremental compilation may add or remove @Benchmark entries. New entries // are discovered and added from the current compilation session. It is harder // to detect removed @Benchmark entries. To do so, we are overwriting all benchmark // records that belong to a current compilation unit. - Multimap entriesByQName = new HashMultimap(); + Multimap entriesByQName = new HashMultimap<>(); try { for (String line : readBenchmarkList(destination)) { BenchmarkListEntry br = new BenchmarkListEntry(line); @@ -227,7 +227,7 @@ private Multimap buildAnnotatedSet(GeneratorSource source // We skip the generated classes, which we had probably generated during the previous rounds // of processing. Abstract classes are of no interest for us either. - Multimap result = new HashMultimap(); + Multimap result = new HashMultimap<>(); for (ClassInfo currentClass : source.getClasses()) { if (currentClass.getQualifiedName().contains("generated")) continue; if (currentClass.isAbstract()) continue; @@ -402,7 +402,7 @@ private void validateBenchmarkInfo(BenchmarkInfo info) { * @return BenchmarkInfo */ private Collection makeBenchmarkInfo(ClassInfo clazz, Collection methods) { - Map result = new TreeMap(); + Map result = new TreeMap<>(); for (MethodInfo method : methods) { Group groupAnn = method.getAnnotation(Group.class); @@ -445,7 +445,7 @@ private Collection makeBenchmarkInfo(ClassInfo clazz, Collection< } } - Collection benchmarks = new ArrayList(); + Collection benchmarks = new ArrayList<>(); for (MethodGroup group : result.values()) { String sourcePackage = clazz.getPackageName(); String generatedPackageName = sourcePackage + ".generated"; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorSession.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorSession.java index ecda7726a..b7ebd17b6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorSession.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorSession.java @@ -28,5 +28,5 @@ import java.util.Set; public class BenchmarkGeneratorSession { - public final Set generatedStateOverrides = new HashSet(); + public final Set generatedStateOverrides = new HashSet<>(); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java index f59910a41..3a4e6bc09 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java @@ -65,7 +65,7 @@ class BenchmarkGeneratorUtils { State.class, TearDown.class, Threads.class, Warmup.class ); - JMH_ANNOTATION_TARGETS = new HashMultimap, ElementType>(); + JMH_ANNOTATION_TARGETS = new HashMultimap<>(); for (Class ann : JMH_ANNOTATIONS) { Target target = ann.getAnnotation(Target.class); @@ -89,7 +89,7 @@ public static boolean checkJavaIdentifier(String id) { } public static Collection getMethodsAnnotatedWith(GeneratorSource source, Class annClass) { - List mis = new ArrayList(); + List mis = new ArrayList<>(); for (ClassInfo ci : source.getClasses()) { for (MethodInfo mi : ci.getMethods()) { if (mi.getAnnotation(annClass) != null) { @@ -101,7 +101,7 @@ public static Collection getMethodsAnnotatedW } public static Collection getClassesAnnotatedWith(GeneratorSource source, Class annClass) { - List cis = new ArrayList(); + List cis = new ArrayList<>(); for (ClassInfo ci : source.getClasses()) { if (ci.getAnnotation(annClass) != null) { cis.add(ci); @@ -111,7 +111,7 @@ public static Collection getClassesAnnotatedWi } public static Collection getFieldsAnnotatedWith(GeneratorSource source, Class annClass) { - List mis = new ArrayList(); + List mis = new ArrayList<>(); for (ClassInfo ci : source.getClasses()) { for (FieldInfo mi : ci.getFields()) { if (mi.getAnnotation(annClass) != null) { @@ -123,7 +123,7 @@ public static Collection getFieldsAnnotatedWit } public static Collection getAllFields(ClassInfo ci) { - List ls = new ArrayList(); + List ls = new ArrayList<>(); do { ls.addAll(ci.getFields()); } while ((ci = ci.getSuperClass()) != null); @@ -131,7 +131,7 @@ public static Collection getAllFields(ClassInfo ci) { } public static Collection getAllMethods(ClassInfo ci) { - List ls = new ArrayList(); + List ls = new ArrayList<>(); do { ls.addAll(ci.getMethods()); } while ((ci = ci.getSuperClass()) != null); @@ -139,7 +139,7 @@ public static Collection getAllMethods(ClassInfo ci) { } public static Collection getMethods(ClassInfo ci) { - List ls = new ArrayList(); + List ls = new ArrayList<>(); do { ls.addAll(ci.getMethods()); } while ((ci = ci.getSuperClass()) != null); @@ -200,7 +200,7 @@ public static T getAnnSuper(MethodInfo mi, ClassInfo star } public static Collection getAnnSuperAll(MethodInfo mi, ClassInfo startCi, Class annClass) { - Collection results = new ArrayList(); + Collection results = new ArrayList<>(); { T ann = mi.getAnnotation(annClass); if (ann != null) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java index a2146086c..ede3a23bf 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java @@ -36,16 +36,16 @@ class CompilerControlPlugin { - private final SortedSet lines = new TreeSet(); + private final SortedSet lines = new TreeSet<>(); - private final Set defaultForceInlineMethods = new TreeSet(new Comparator() { + private final Set defaultForceInlineMethods = new TreeSet<>(new Comparator() { @Override public int compare(MethodInfo o1, MethodInfo o2) { return o1.getQualifiedName().compareTo(o2.getQualifiedName()); } }); - private final Set alwaysDontInlineMethods = new TreeSet(); + private final Set alwaysDontInlineMethods = new TreeSet<>(); public void defaultForceInline(MethodInfo methodInfo) { defaultForceInlineMethods.add(methodInfo); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java index 3b5e6735a..7333a6b59 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java @@ -44,8 +44,8 @@ public class FileSystemDestination implements GeneratorDestination { public FileSystemDestination(File resourceDir, File sourceDir) { this.resourceDir = resourceDir; this.sourceDir = sourceDir; - this.sourceErrors = new ArrayList(); - this.sourceWarnings = new ArrayList(); + this.sourceErrors = new ArrayList<>(); + this.sourceWarnings = new ArrayList<>(); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Identifiers.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Identifiers.java index e0e6d54a6..d4d2f5ad2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Identifiers.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Identifiers.java @@ -33,11 +33,11 @@ class Identifiers { - private final Map collapsedTypes = new HashMap(); + private final Map collapsedTypes = new HashMap<>(); private int collapsedIndex = 0; - private final Set claimedJmhTypes = new HashSet(); - private final Map jmhTypes = new HashMap(); + private final Set claimedJmhTypes = new HashSet<>(); + private final Map jmhTypes = new HashMap<>(); public String getJMHtype(ClassInfo type) { String id = BenchmarkGeneratorUtils.getGeneratedName(type); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java index 7d3ca3c09..2111f12ba 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java @@ -43,9 +43,9 @@ class MethodGroup implements Comparable { public MethodGroup(ClassInfo ci, String name) { this.ci = ci; this.name = name; - this.methods = new TreeMap(); + this.methods = new TreeMap<>(); this.modes = EnumSet.noneOf(Mode.class); - this.params = new TreeMap(); + this.params = new TreeMap<>(); } @Override @@ -84,7 +84,7 @@ public void addMethod(MethodInfo method, int threads) { } public Collection methods() { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); for (MethodInvocation m : methods.keySet()) { result.add(m.method); } @@ -139,7 +139,7 @@ public int[] getGroupThreads() { public Optional> getGroupLabels() { if (methods.size() > 1) { - Collection labels = new ArrayList(); + Collection labels = new ArrayList<>(); for (MethodInvocation mi : methods.keySet()) { labels.add(mi.method.getName()); } @@ -282,7 +282,7 @@ public Optional getTimeout() { } private Collection getAll(Class annClass) { - Collection results = new ArrayList(); + Collection results = new ArrayList<>(); for (MethodInvocation mi : methods.keySet()) { Collection anns = BenchmarkGeneratorUtils.getAnnSuperAll(mi.method, ci, annClass); if (!(results.isEmpty() || anns.isEmpty() || results.equals(anns))) { @@ -294,7 +294,7 @@ private Collection getAll(Class annClass) { } public Optional> getParams() { - Map map = new TreeMap(); + Map map = new TreeMap<>(); for (Map.Entry e : params.entrySet()) { String key = e.getKey(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Paddings.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Paddings.java index af1930b42..456f7b7d3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Paddings.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/Paddings.java @@ -33,7 +33,7 @@ public class Paddings { private static final List PADDING_CACHE; static { - PADDING_CACHE = new ArrayList(); + PADDING_CACHE = new ArrayList<>(); for (int p = 0; p < 16; p++) { StringBuilder sb = new StringBuilder(); sb.append(" "); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java index b330b8ba1..a2da23782 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java @@ -61,10 +61,10 @@ public StateObject(Identifiers identifiers, ClassInfo info, Scope scope) { this.localIdentifier = "l_" + id; this.fieldIdentifier = "f_" + id; - this.params = new TreeMultimap(); - this.helpers = new TreeSet(); - this.helperArgs = new HashMultimap(); - this.depends = new ArrayList(); + this.params = new TreeMultimap<>(); + this.helpers = new TreeSet<>(); + this.helperArgs = new HashMultimap<>(); + this.depends = new ArrayList<>(); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 46d7ae5d7..35d987c57 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -52,18 +52,18 @@ class StateObjectHandler { private final Multimap benchmarkArgs; - private final Multimap auxNames = new HashMultimap(); - private final Map auxType = new HashMap(); - private final Map auxAccessors = new HashMap(); - private final Map auxResettable = new HashMap(); + private final Multimap auxNames = new HashMultimap<>(); + private final Map auxType = new HashMap<>(); + private final Map auxAccessors = new HashMap<>(); + private final Map auxResettable = new HashMap<>(); public StateObjectHandler(CompilerControlPlugin compileControl) { this.compileControl = compileControl; - this.roots = new HashMultimap(); - this.benchmarkArgs = new HashMultimap(); - this.implicits = new HashMap(); - this.specials = new HashMultimap(); - this.stateObjects = new HashSet(); + this.roots = new HashMultimap<>(); + this.benchmarkArgs = new HashMultimap<>(); + this.implicits = new HashMap<>(); + this.specials = new HashMultimap<>(); + this.stateObjects = new HashSet<>(); this.identifiers = new Identifiers(); } @@ -225,7 +225,7 @@ public static void validateNoCycles(MethodInfo method) { } private static void validateNoCyclesStep(List states, MethodInfo method, boolean includeHolder) { - List stratum = new ArrayList(); + List stratum = new ArrayList<>(); if (includeHolder) { stratum.add(method.getDeclaringClass()); } @@ -233,7 +233,7 @@ private static void validateNoCyclesStep(List states, MethodInfo method, stratum.add(ppi.getType()); } - List newStates = new ArrayList(); + List newStates = new ArrayList<>(); newStates.addAll(states); for (ClassInfo ci : stratum) { newStates.add(ci.getQualifiedName()); @@ -551,8 +551,9 @@ public String getTypeArgList(Collection sos) { return sb.toString(); } + @SafeVarargs public static Collection cons(Collection... colls) { - SortedSet r = new TreeSet(StateObject.ID_COMPARATOR); + SortedSet r = new TreeSet<>(StateObject.ID_COMPARATOR); for (Collection coll : colls) { r.addAll(coll); } @@ -563,7 +564,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H // Look for the offending methods. // This will be used to skip the irrelevant blocks for state objects down the stream. - List statesForward = new ArrayList(); + List statesForward = new ArrayList<>(); for (StateObject so : stateOrder(method, true)) { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel == helperLevel) { @@ -573,7 +574,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H } } - List statesReverse = new ArrayList(); + List statesReverse = new ArrayList<>(); for (StateObject so : stateOrder(method, false)) { for (HelperMethodInvocation hmi : so.getHelpers()) { if (hmi.helperLevel == helperLevel) { @@ -583,7 +584,7 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H } } - List result = new ArrayList(); + List result = new ArrayList<>(); // Handle Thread object helpers for (StateObject so : statesForward) { @@ -723,7 +724,7 @@ public Collection getRunTearDowns(MethodInfo method) { public List getStateInitializers() { Collection sos = cons(stateObjects); - List result = new ArrayList(); + List result = new ArrayList<>(); for (StateObject so : sos) { if (so.scope != Scope.Benchmark) continue; @@ -865,7 +866,7 @@ private String soDependency_Args(StateObject so) { public Collection getStateDestructors(MethodInfo method) { Collection sos = stateOrder(method, false); - List result = new ArrayList(); + List result = new ArrayList<>(); for (StateObject so : sos) { if (so.scope != Scope.Benchmark) continue; result.add("synchronized(this.getClass()) {"); @@ -888,7 +889,7 @@ public Collection getStateDestructors(MethodInfo method) { } public List getStateGetters(MethodInfo method) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (StateObject so : stateOrder(method, true)) { result.add(so.type + " " + so.localIdentifier + " = _jmh_tryInit_" + so.fieldIdentifier + "(control" + soDependency_Args(so) + ");"); } @@ -897,9 +898,9 @@ public List getStateGetters(MethodInfo method) { private LinkedHashSet stateOrder(MethodInfo method, boolean reverse) { // Linearize @State dependency DAG - List linearOrder = new ArrayList(); + List linearOrder = new ArrayList<>(); - List stratum = new ArrayList(); + List stratum = new ArrayList<>(); // These are roots stratum.addAll(roots.get(method.getName())); @@ -908,7 +909,7 @@ private LinkedHashSet stateOrder(MethodInfo method, boolean reverse // Recursively walk the DAG while (!stratum.isEmpty()) { linearOrder.addAll(stratum); - List newStratum = new ArrayList(); + List newStratum = new ArrayList<>(); for (StateObject so : stratum) { newStratum.addAll(so.depends); } @@ -919,7 +920,7 @@ private LinkedHashSet stateOrder(MethodInfo method, boolean reverse Collections.reverse(linearOrder); } - return new LinkedHashSet(linearOrder); + return new LinkedHashSet<>(linearOrder); } public void writeStateOverrides(BenchmarkGeneratorSession sess, GeneratorDestination dst) throws IOException { @@ -1019,7 +1020,7 @@ public void addImports(PrintWriter writer) { } public Collection getAuxResets(MethodInfo method) { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); for (String name : auxNames.get(method.getName())) { if (auxResettable.get(name)) { result.add(auxAccessors.get(method.getName() + name) + " = 0;"); @@ -1029,7 +1030,7 @@ public Collection getAuxResets(MethodInfo method) { } public Collection getAuxResults(MethodInfo method, String opResName) { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); for (String ops : auxNames.get(method.getName())) { AuxCounters.Type type = auxType.get(ops); switch (type) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java index b9db80651..de38f7483 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java @@ -53,7 +53,7 @@ public AbstractHotspotProfiler() throws ProfilerException { @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { HotspotInternalResult res = counters(); - Collection results = new ArrayList(); + Collection results = new ArrayList<>(); for (Map.Entry e : res.getDiff().entrySet()) { results.add(new ScalarResult(Defaults.PREFIX + e.getKey(), e.getValue(), "?", AggregationPolicy.AVG)); } @@ -62,7 +62,7 @@ public Collection afterIteration(BenchmarkParams benchmarkPara @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { - prevs = new HashMap(); + prevs = new HashMap<>(); for (Counter counter : getCounters()) { prevs.put(counter.getName(), convert(counter.getValue())); } @@ -77,8 +77,8 @@ public static Long convert(Object o) { } protected HotspotInternalResult counters() { - Map difference = new TreeMap(); - Map current = new TreeMap(); + Map difference = new TreeMap<>(); + Map current = new TreeMap<>(); for (Counter counter : getCounters()) { Long prev = prevs.get(counter.getName()); if (prev != null) { @@ -95,13 +95,7 @@ public static T getInstance(String name) { try { Object o = Class.forName("sun.management.ManagementFactoryHelper").getMethod("get" + name).invoke(null); return (T) o; - } catch (ClassNotFoundException e) { - throw new IllegalStateException("Should not be here"); - } catch (InvocationTargetException e) { - throw new IllegalStateException("Should not be here"); - } catch (NoSuchMethodException e) { - throw new IllegalStateException("Should not be here"); - } catch (IllegalAccessException e) { + } catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new IllegalStateException("Should not be here"); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index fc031f0f3..98ecc85d3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -228,7 +228,7 @@ protected AbstractPerfAsmProfiler(String initLine, String... events) throws Prof @Override public Collection addJVMOptions(BenchmarkParams params) { if (!skipAssembly) { - Collection opts = new ArrayList(); + Collection opts = new ArrayList<>(); opts.addAll(Arrays.asList( "-XX:+UnlockDiagnosticVMOptions", "-XX:+LogCompilation", @@ -429,8 +429,8 @@ public int compare(Region o1, Region o2) { * 6. Print out the hottest regions */ { - Multiset total = new HashMultiset(); - Multiset other = new HashMultiset(); + Multiset total = new HashMultiset<>(); + Multiset other = new HashMultiset<>(); printDottedLine(pw, "Hottest Regions"); int shown = 0; @@ -465,8 +465,8 @@ public int compare(Region o1, Region o2) { pw.println(); } - final Map> methodsByType = new HashMap>(); - final Map> methods = new HashMap>(); + final Map> methodsByType = new HashMap<>(); + final Map> methods = new HashMap<>(); for (String event : this.events) { methodsByType.put(event, new HashMultiset()); @@ -487,8 +487,8 @@ public int compare(Region o1, Region o2) { { printDottedLine(pw, "Hottest Methods (after inlining)"); - Multiset total = new HashMultiset(); - Multiset other = new HashMultiset(); + Multiset total = new HashMultiset<>(); + Multiset other = new HashMultiset<>(); int shownMethods = 0; List top = Multisets.sortedDesc(methods.get(mainEvent)); @@ -552,7 +552,7 @@ public int compare(Region o1, Region o2) { */ { - Set addrHistory = new HashSet(); + Set addrHistory = new HashSet<>(); for (Long addr : assembly.addressMap.keySet()) { if (!addrHistory.add(addr)) { pw.println("WARNING: Duplicate instruction addresses detected. This is probably due to compiler reusing\n " + @@ -668,7 +668,7 @@ void printDottedLine(PrintWriter pw, String header) { } List makeRegions(Assembly asms, PerfEvents events) { - List regions = new ArrayList(); + List regions = new ArrayList<>(); SortedSet allAddrs = events.getAllAddresses(); for (Interval intv : figureHotIntervals(allAddrs, allAddrs.first(), allAddrs.last())) { @@ -705,7 +705,7 @@ List makeRegions(Assembly asms, PerfEvents events) { private List figureHotIntervals(SortedSet allAddrs, long from, long to) { - List intervals = new ArrayList(); + List intervals = new ArrayList<>(); SortedSet addrs = allAddrs.subSet(from, to); long begAddr = addrs.first(); @@ -728,7 +728,7 @@ private List figureHotIntervals(SortedSet allAddrs, long from, l Collection> splitAssembly(File stdOut) { FileReader in = null; try { - Multimap writerToLines = new HashMultimap(); + Multimap writerToLines = new HashMultimap<>(); Long writerId = -1L; Pattern pWriterThread = Pattern.compile("(.*)(.*)"); @@ -753,7 +753,7 @@ Collection> splitAssembly(File stdOut) { writerToLines.put(writerId, line); } - Collection> r = new ArrayList>(); + Collection> r = new ArrayList<>(); for (long id : writerToLines.keys()) { r.add(writerToLines.get(id)); } @@ -766,13 +766,13 @@ Collection> splitAssembly(File stdOut) { } Assembly readAssembly(File stdOut) { - List lines = new ArrayList(); - SortedMap addressMap = new TreeMap(); + List lines = new ArrayList<>(); + SortedMap addressMap = new TreeMap<>(); - IntervalMap stubs = new IntervalMap(); - IntervalMap javaMethods = new IntervalMap(); + IntervalMap stubs = new IntervalMap<>(); + IntervalMap javaMethods = new IntervalMap<>(); - Set intervals = new HashSet(); + Set intervals = new HashSet<>(); for (Collection cs : splitAssembly(stdOut)) { String prevLine = ""; @@ -845,7 +845,7 @@ Assembly readAssembly(File stdOut) { body = body.replaceAll("='", "="); String[] kvs = body.split("' "); - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); for (String kv : kvs) { String[] pair = kv.split("="); map.put(pair[0], pair[1]); @@ -869,7 +869,7 @@ Assembly readAssembly(File stdOut) { } // Important to get the order right: all Java methods take precedence over interpreter/runtime stubs. - IntervalMap methodMap = new IntervalMap(); + IntervalMap methodMap = new IntervalMap<>(); methodMap.merge(stubs); methodMap.merge(javaMethods); @@ -930,7 +930,7 @@ protected static class PerfEvents { PerfEvents(Collection tracedEvents, Map> events, IntervalMap methods) { this.events = events; this.methods = methods; - this.totalCounts = new HashMap(); + this.totalCounts = new HashMap<>(); for (String event : tracedEvents) { totalCounts.put(event, events.get(event).size()); } @@ -949,7 +949,7 @@ public Multiset get(String event) { } public SortedSet getAllAddresses() { - SortedSet addrs = new TreeSet(); + SortedSet addrs = new TreeSet<>(); for (Multiset e : events.values()) { addrs.addAll(e.keys()); } @@ -1048,7 +1048,7 @@ static class Region { this.begin = begin; this.end = end; this.eventfulAddrs = eventfulAddrs; - this.eventCountCache = new HashMap(); + this.eventCountCache = new HashMap<>(); } long getEventCount(PerfEvents events, String event) { @@ -1107,8 +1107,8 @@ public void printCode(PrintWriter pw, PerfEvents events) { } } - Set interIvs = new TreeSet(); - Set intraIvs = new TreeSet(); + Set interIvs = new TreeSet<>(); + Set intraIvs = new TreeSet<>(); for (Interval it : asms.intervals) { boolean srcInline = (beginLine < it.src && it.src < endLine); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java index ed8a972de..14a6fe88d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java @@ -69,7 +69,7 @@ public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams ite public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { afterTime = System.nanoTime(); - List results = new ArrayList(); + List results = new ArrayList<>(); ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java index a96528b35..8d0cc4346 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java @@ -84,7 +84,7 @@ public Collection afterIteration(BenchmarkParams benchmarkPara gcTime += bean.getCollectionTime(); } - List results = new ArrayList(); + List results = new ArrayList<>(); if (beforeAllocated == HotspotAllocationSnapshot.EMPTY) { // When allocation profiling fails, make sure it is distinguishable in report @@ -171,7 +171,7 @@ private HotspotAllocationSnapshot(long[] threadIds, long[] allocatedBytes) { * @return estimated number of allocated bytes between profiler calls */ public long subtract(HotspotAllocationSnapshot other) { - HashMap prevIndex = new HashMap(); + HashMap prevIndex = new HashMap<>(); for (int i = 0; i < other.threadIds.length; i++) { long id = other.threadIds[i]; prevIndex.put(id, i); @@ -254,15 +254,13 @@ private static boolean tryInitChurn() { private static long[] getAllocatedBytes(long[] threadIds) { try { return (long[]) ALLOC_MX_BEAN_GETTER.invoke(ALLOC_MX_BEAN, (Object) threadIds); - } catch (InvocationTargetException e) { - throw new IllegalStateException(e); - } catch (IllegalAccessException e) { + } catch (InvocationTargetException | IllegalAccessException e) { throw new IllegalStateException(e); } } private static NotificationListener newListener() { - churn = new HashMultiset(); + churn = new HashMultiset<>(); try { final Class infoKlass = Class.forName("com.sun.management.GarbageCollectionNotificationInfo"); final Field notifNameField = infoKlass.getField("GARBAGE_COLLECTION_NOTIFICATION"); @@ -290,9 +288,7 @@ public void handleNotification(Notification n, Object o) { } } } - } catch (IllegalAccessException e) { - // Do nothing, counters would not get populated - } catch (InvocationTargetException e) { + } catch (IllegalAccessException | InvocationTargetException e) { // Do nothing, counters would not get populated } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index ede0b707e..4b97c4cb4 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -96,9 +96,7 @@ protected void parseEvents() { outDrainer.join(); FileUtils.safelyClose(fos); - } catch (IOException ex) { - throw new IllegalStateException(ex); - } catch (InterruptedException ex) { + } catch (IOException | InterruptedException ex) { throw new IllegalStateException(ex); } } @@ -107,13 +105,13 @@ protected void parseEvents() { protected PerfEvents readEvents(double skipSec) { FileReader fr = null; try { - Deduplicator dedup = new Deduplicator(); + Deduplicator dedup = new Deduplicator<>(); fr = new FileReader(perfParsedData); BufferedReader reader = new BufferedReader(fr); - Multimap methods = new HashMultimap(); - Map> events = new LinkedHashMap>(); + Multimap methods = new HashMultimap<>(); + Map> events = new LinkedHashMap<>(); for (String evName : this.events) { events.put(evName, new TreeMultiset()); } @@ -181,7 +179,7 @@ protected PerfEvents readEvents(double skipSec) { methods.put(dedup.dedup(MethodDesc.nativeMethod(symbol, lib)), addr); } - IntervalMap methodMap = new IntervalMap(); + IntervalMap methodMap = new IntervalMap<>(); for (MethodDesc md : methods.keys()) { Collection addrs = methods.get(md); methodMap.add(md, Utils.min(addrs), Utils.max(addrs)); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index f5528a754..60ee25728 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -67,7 +67,7 @@ public class LinuxPerfNormProfiler implements ExternalProfiler { private final int incrementInterval; private final boolean isIncrementable; - private final Collection supportedEvents = new ArrayList(); + private final Collection supportedEvents = new ArrayList<>(); public LinuxPerfNormProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); @@ -135,7 +135,7 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { - List cmd = new ArrayList(); + List cmd = new ArrayList<>(); if (useDefaultStats) { cmd.addAll(Arrays.asList("perf", "stat", "--log-fd", "2", "--field-separator", ",", "--detailed", "--detailed", "--detailed")); } else { @@ -195,7 +195,7 @@ public long getDelay(BenchmarkResult br) { } private Collection process(BenchmarkResult br, File stdOut, File stdErr) { - Multiset events = new HashMultiset(); + Multiset events = new HashMultiset<>(); FileReader fr = null; try { @@ -293,7 +293,7 @@ private Collection process(BenchmarkResult br, File stdOut, Fi } else { totalOpts = md.getWarmupOps() + md.getMeasurementOps(); } - Collection results = new ArrayList(); + Collection results = new ArrayList<>(); for (String key : events.keys()) { results.add(new PerfResult(key, events.count(key) * 1.0 / totalOpts)); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java index 036185c85..a9ba7becc 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java @@ -90,7 +90,7 @@ private static Profiler instantiate(ProfilerConfig cfg, Class getSupportedExternal(Collection cfg) { - List profilers = new ArrayList(); + List profilers = new ArrayList<>(); for (ProfilerConfig p : cfg) { Profiler prof = ProfilerFactory.getProfilerOrNull(p); if (prof instanceof ExternalProfiler) { @@ -101,7 +101,7 @@ public static List getSupportedExternal(Collection getSupportedInternal(Collection cfg) { - List profilers = new ArrayList(); + List profilers = new ArrayList<>(); for (ProfilerConfig p : cfg) { Profiler prof = ProfilerFactory.getProfilerOrNull(p); if (prof instanceof InternalProfiler) { @@ -173,7 +173,7 @@ public static void listProfilers(PrintStream out) { private static final Map> BUILT_IN; static { - BUILT_IN = new TreeMap>(); + BUILT_IN = new TreeMap<>(); BUILT_IN.put("cl", ClassloaderProfiler.class); BUILT_IN.put("comp", CompilerProfiler.class); BUILT_IN.put("gc", GCProfiler.class); @@ -191,7 +191,7 @@ public static void listProfilers(PrintStream out) { } private static List> getDiscoveredProfilers() { - List> profs = new ArrayList>(); + List> profs = new ArrayList<>(); for (Profiler s : ServiceLoader.load(Profiler.class)) { profs.add(s.getClass()); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java index dbcc012fd..7c1f0e231 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java @@ -107,7 +107,7 @@ public StackProfiler(String initLine) throws ProfilerException { boolean excludePackages = set.valueOf(optExclude); excludePackageNames = excludePackages ? - new HashSet(set.valuesOf(optExcludeClasses)) : + new HashSet<>(set.valuesOf(optExcludeClasses)) : Collections.emptySet(); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); @@ -139,7 +139,7 @@ public class SamplingTask implements Runnable { private final Map> stacks; public SamplingTask() { - stacks = new EnumMap>(Thread.State.class); + stacks = new EnumMap<>(Thread.State.class); for (Thread.State s : Thread.State.values()) { stacks.put(s, new HashMultiset()); } @@ -167,7 +167,7 @@ public void run() { // - Get the remaining number of stack lines and build the stack record StackTraceElement[] stack = info.getStackTrace(); - List lines = new ArrayList(); + List lines = new ArrayList<>(); for (StackTraceElement l : stack) { String className = l.getClassName(); @@ -278,7 +278,7 @@ public String extendedInfo() { } public String getStack(final Map> stacks) { - List sortedStates = new ArrayList(stacks.keySet()); + List sortedStates = new ArrayList<>(stacks.keySet()); Collections.sort(sortedStates, new Comparator() { private long stateSize(Thread.State state) { @@ -379,7 +379,7 @@ public static class StackResultAggregator implements Aggregator { @Override public StackResult aggregate(Collection results) { int topStacks = 0; - Map> sum = new EnumMap>(Thread.State.class); + Map> sum = new EnumMap<>(Thread.State.class); for (StackResult r : results) { for (Map.Entry> entry : r.stacks.entrySet()) { if (!sum.containsKey(entry.getKey())) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index e175dec00..04035e4c1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -172,9 +172,7 @@ protected void parseEvents() { errDrainer.join(); outDrainer.join(); - } catch (IOException ex) { - throw new IllegalStateException(ex); - } catch (InterruptedException ex) { + } catch (IOException | InterruptedException ex) { throw new IllegalStateException(ex); } } @@ -183,13 +181,13 @@ protected void parseEvents() { protected PerfEvents readEvents(double skipSec) { FileReader fr = null; try { - Deduplicator dedup = new Deduplicator(); + Deduplicator dedup = new Deduplicator<>(); fr = new FileReader(perfParsedData); BufferedReader reader = new BufferedReader(fr); - Multimap methods = new HashMultimap(); - Map> events = new LinkedHashMap>(); + Multimap methods = new HashMultimap<>(); + Map> events = new LinkedHashMap<>(); for (String evName : this.events) { events.put(evName, new TreeMultiset()); } @@ -252,7 +250,7 @@ protected PerfEvents readEvents(double skipSec) { } } - IntervalMap methodMap = new IntervalMap(); + IntervalMap methodMap = new IntervalMap<>(); for (MethodDesc md : methods.keys()) { Collection longs = methods.get(md); methodMap.add(md, Utils.min(longs), Utils.max(longs)); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResult.java index ab54dc3b2..7cdbf0b74 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResult.java @@ -50,7 +50,7 @@ public BenchmarkResult(BenchmarkParams params, Collection data) public BenchmarkResult(BenchmarkParams params, Collection data, BenchmarkResultMetaData md) { this.metadata = md; - this.benchmarkResults = new HashMultimap(); + this.benchmarkResults = new HashMultimap<>(); this.iterationResults = data; this.params = params; } @@ -76,7 +76,7 @@ public Multimap getBenchmarkResults() { public Result getPrimaryResult() { Aggregator aggregator = null; - Collection aggrs = new ArrayList(); + Collection aggrs = new ArrayList<>(); for (IterationResult r : iterationResults) { Result e = r.getPrimaryResult(); aggrs.add(e); @@ -97,7 +97,7 @@ public Result getPrimaryResult() { public Map getSecondaryResults() { // label -> collection of results - Multimap allSecondary = new HashMultimap(); + Multimap allSecondary = new HashMultimap<>(); // Build multiset of all results to capture if some labels are missing in some of the iterations for (IterationResult ir : iterationResults) { @@ -110,7 +110,7 @@ public Map getSecondaryResults() { } } - Map answers = new TreeMap(); + Map answers = new TreeMap<>(); int totalIterations = iterationResults.size(); // Create "0" entries in case certain labels did not appear in some of the iterations @@ -140,7 +140,7 @@ public Map getSecondaryResults() { for (String label : benchmarkResults.keys()) { Aggregator aggregator = null; - Collection results = new ArrayList(); + Collection results = new ArrayList<>(); for (Result r : benchmarkResults.get(label)) { if (r.getRole().isSecondary() && !r.getRole().isDerivative()) { results.add(r); @@ -156,7 +156,7 @@ public Map getSecondaryResults() { answers.putAll(produceDerivative(getPrimaryResult())); // add all derivative results on top: from secondaries - Map adds = new HashMap(); + Map adds = new HashMap<>(); for (Result r : answers.values()) { adds.putAll(produceDerivative(r)); } @@ -166,7 +166,7 @@ public Map getSecondaryResults() { } private Map produceDerivative(Result r) { - Map map = new HashMap(); + Map map = new HashMap<>(); for (Object rr : r.getDerivativeResults()) { map.put(((Result) rr).getLabel(), (Result) rr); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkTaskResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkTaskResult.java index a9fd3d45f..f8273d9b4 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkTaskResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkTaskResult.java @@ -44,7 +44,7 @@ public class BenchmarkTaskResult { public BenchmarkTaskResult(long allOperations, long measuredOperations) { this.allOperations = allOperations; this.measuredOperations = measuredOperations; - this.results = new ArrayList(); + this.results = new ArrayList<>(); } public void add(Result result) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResult.java index 18be0376e..2f866fc7c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/IterationResult.java @@ -38,7 +38,7 @@ public class IterationResult implements Serializable { private static final long serialVersionUID = 960397066774710819L; - private static final Multimap EMPTY_MAP = new TreeMultimap(); + private static final Multimap EMPTY_MAP = new TreeMultimap<>(); private static final List EMPTY_LIST = Collections.emptyList(); private final BenchmarkParams benchmarkParams; @@ -70,7 +70,7 @@ public void addResult(Result result) { if (primaryResults == EMPTY_LIST) { primaryResults = Collections.singleton(result); } else if (primaryResults.size() == 1) { - List newResults = new ArrayList(2); + List newResults = new ArrayList<>(2); newResults.addAll(primaryResults); newResults.add(result); primaryResults = newResults; @@ -81,7 +81,7 @@ public void addResult(Result result) { if (result.getRole().isSecondary()) { if (secondaryResults == EMPTY_MAP) { - secondaryResults = new TreeMultimap(); + secondaryResults = new TreeMultimap<>(); } secondaryResults.put(result.getLabel(), result); } @@ -96,7 +96,7 @@ public Multimap getRawSecondaryResults() { } public Map getSecondaryResults() { - Map answer = new TreeMap(); + Map answer = new TreeMap<>(); for (String label : secondaryResults.keys()) { Collection results = secondaryResults.get(label); @@ -112,7 +112,7 @@ public Map getSecondaryResults() { answer.putAll(produceDerivative(getPrimaryResult())); // add all secondary derivative results on top: from secondaries - Map adds = new HashMap(); + Map adds = new HashMap<>(); for (Result r : answer.values()) { adds.putAll(produceDerivative(r)); } @@ -122,7 +122,7 @@ public Map getSecondaryResults() { } private Map produceDerivative(Result r) { - Map map = new HashMap(); + Map map = new HashMap<>(); for (Object rr : r.getDerivativeResults()) { map.put(((Result) rr).getLabel(), (Result) rr); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java index 795c52bfb..30b4e8bfa 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java @@ -40,7 +40,7 @@ */ public abstract class Result> implements Serializable { private static final long serialVersionUID = -7332879501317733312L; - private static final Deduplicator DEDUP = new Deduplicator(); + private static final Deduplicator DEDUP = new Deduplicator<>(); protected final ResultRole role; protected final String label; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/RunResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/RunResult.java index ca1a4b5f6..68bcb8c52 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/RunResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/RunResult.java @@ -71,7 +71,7 @@ public BenchmarkResult getAggregatedResult() { return null; } - Collection results = new ArrayList(); + Collection results = new ArrayList<>(); for (BenchmarkResult r : benchmarkResults) { for (IterationResult ir : r.getIterationResults()) { results.add(ir); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java index 8bf5c6edd..60a9338bb 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java @@ -106,7 +106,7 @@ public void writeOut(Collection results) { pw.println("},"); // primaryMetric end - Collection secondaries = new ArrayList(); + Collection secondaries = new ArrayList<>(); for (Map.Entry e : runResult.getSecondaryResults().entrySet()) { String secondaryName = e.getKey(); Result result = e.getValue(); @@ -120,9 +120,9 @@ public void writeOut(Collection results) { sb.append("\"scoreUnit\" : \"").append(result.getScoreUnit()).append("\","); sb.append("\"rawData\" : "); - Collection l2 = new ArrayList(); + Collection l2 = new ArrayList<>(); for (BenchmarkResult benchmarkResult : runResult.getBenchmarkResults()) { - Collection scores = new ArrayList(); + Collection scores = new ArrayList<>(); for (IterationResult r : benchmarkResult.getIterationResults()) { Result rr = r.getSecondaryResults().get(secondaryName); if (rr != null) { @@ -149,14 +149,14 @@ public void writeOut(Collection results) { private String getRawData(RunResult runResult, boolean histogram) { StringBuilder sb = new StringBuilder(); - Collection runs = new ArrayList(); + Collection runs = new ArrayList<>(); if (PRINT_RAW_DATA) { for (BenchmarkResult benchmarkResult : runResult.getBenchmarkResults()) { - Collection iterations = new ArrayList(); + Collection iterations = new ArrayList<>(); for (IterationResult r : benchmarkResult.getIterationResults()) { if (histogram) { - Collection singleIter = new ArrayList(); + Collection singleIter = new ArrayList<>(); for (Map.Entry item : Utils.adaptForLoop(r.getPrimaryResult().getStatistics().getRawData())) { singleIter.add("< " + emit(item.getKey()) + "; " + item.getValue() + " >"); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/format/LaTeXResultFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/results/format/LaTeXResultFormat.java index ac9e2e05e..2edd4966a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/LaTeXResultFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/LaTeXResultFormat.java @@ -48,10 +48,10 @@ public LaTeXResultFormat(PrintStream out) { @Override public void writeOut(Collection results) { - SortedSet params = new TreeSet(); - Set benchNames = new HashSet(); + SortedSet params = new TreeSet<>(); + Set benchNames = new HashSet<>(); - Set units = new HashSet(); + Set units = new HashSet<>(); for (RunResult rr : results) { String benchmark = rr.getParams().getBenchmark(); benchNames.add(benchmark); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java index d190d195d..a763cbbf1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/TextResultFormat.java @@ -49,7 +49,7 @@ public TextResultFormat(PrintStream out) { public void writeOut(Collection runResults) { final int COLUMN_PAD = 2; - Collection benchNames = new ArrayList(); + Collection benchNames = new ArrayList<>(); for (RunResult runResult : runResults) { benchNames.add(runResult.getParams().getBenchmark()); for (String label : runResult.getSecondaryResults().keySet()) { @@ -66,8 +66,8 @@ public void writeOut(Collection runResults) { } // determine param lengths - Map paramLengths = new HashMap(); - SortedSet params = new TreeSet(); + Map paramLengths = new HashMap<>(); + SortedSet params = new TreeSet<>(); for (RunResult runResult : runResults) { BenchmarkParams bp = runResult.getParams(); for (String k : bp.getParamsKeys()) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/format/XSVResultFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/results/format/XSVResultFormat.java index 8feccdd25..21f8cf1d6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/XSVResultFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/XSVResultFormat.java @@ -48,7 +48,7 @@ public XSVResultFormat(PrintStream out, String delimiter) { @Override public void writeOut(Collection results) { - SortedSet params = new TreeSet(); + SortedSet params = new TreeSet<>(); for (RunResult res : results) { params.addAll(res.getParams().getParamsKeys()); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java index 76daaf2e3..28db4420c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java @@ -74,7 +74,7 @@ protected List getReaders() { } if (urls.hasMoreElements()) { - List readers = new ArrayList(); + List readers = new ArrayList<>(); URL url = null; try { while (urls.hasMoreElements()) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/ActionPlan.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/ActionPlan.java index 8451b36a0..53eecbe6e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/ActionPlan.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/ActionPlan.java @@ -36,7 +36,7 @@ public class ActionPlan implements Serializable { public ActionPlan(ActionType type) { this.type = type; - actions = new ArrayList(); + this.actions = new ArrayList<>(); } public ActionType getType() { @@ -56,7 +56,7 @@ public List getActions() { } public List getMeasurementActions() { - List result = new ArrayList(); + List result = new ArrayList<>(); for (Action action : actions) { switch (action.getMode()) { case MEASUREMENT: diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java index 5f67acda9..e9c0f8a2f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java @@ -78,7 +78,7 @@ protected void runBenchmarksForked(ActionPlan actionPlan, IterationResultAccepto } protected Multimap runBenchmarksEmbedded(ActionPlan actionPlan) { - Multimap results = new TreeMultimap(); + Multimap results = new TreeMultimap<>(); for (Action action : actionPlan.getActions()) { BenchmarkParams params = action.getParams(); @@ -101,8 +101,8 @@ protected Multimap runBenchmarksEmbedded(Actio out.println("# *** WARNING: Non-forked runs may silently omit JVM options, mess up profilers, disable compiler hints, etc. ***"); out.println("# *** WARNING: Use non-forked runs only for debugging purposes, not for actual performance runs. ***"); - final List res = new ArrayList(); - final List mds = new ArrayList(); + final List res = new ArrayList<>(); + final List mds = new ArrayList<>(); IterationResultAcceptor acceptor = new IterationResultAcceptor() { @Override @@ -308,7 +308,7 @@ protected void runBenchmark(BenchmarkParams benchParams, BenchmarkHandler handle */ public boolean runSystemGC() { if (options.shouldDoGC().orElse(Defaults.DO_GC)) { - List enabledBeans = new ArrayList(); + List enabledBeans = new ArrayList<>(); long beforeGcCount = 0; for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index 810b7f9f4..dbcffa34d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -69,10 +69,10 @@ public BenchmarkHandler(OutputFormat out, Options options, BenchmarkParams execu this.method = BenchmarkHandler.findBenchmarkMethod(clazz, target.substring(lastDot + 1)); this.profilers = ProfilerFactory.getSupportedInternal(options.getProfilers()); - this.profilersRev = new ArrayList(profilers); + this.profilersRev = new ArrayList<>(profilers); Collections.reverse(profilersRev); - final BlockingQueue tps = new ArrayBlockingQueue(executionParams.getThreads()); + final BlockingQueue tps = new ArrayBlockingQueue<>(executionParams.getThreads()); tps.addAll(distributeThreads(executionParams.getThreads(), executionParams.getThreadGroups())); this.threadData = new ThreadLocal() { @@ -85,9 +85,7 @@ protected ThreadData initialValue() { throw new IllegalStateException("Cannot get another thread params"); } return new ThreadData(o, t); - } catch (InstantiationException e) { - throw new RuntimeException("Class " + clazz.getName() + " instantiation error ", e); - } catch (IllegalAccessException e) { + } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException("Class " + clazz.getName() + " instantiation error ", e); } } @@ -102,7 +100,7 @@ protected ThreadData initialValue() { } static List distributeThreads(int threads, int[] groups) { - List result = new ArrayList(); + List result = new ArrayList<>(); int totalGroupThreads = Utils.sum(groups); int totalGroups = (int) Math.ceil(1D * threads / totalGroupThreads); int totalSubgroups = groups.length; @@ -320,7 +318,7 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa CountDownLatch preTearDownBarrier = new CountDownLatch(numThreads); // result object to accumulate the results in - List iterationResults = new ArrayList(); + List iterationResults = new ArrayList<>(); InfraControl control = new InfraControl(benchmarkParams, params, preSetupBarrier, preTearDownBarrier, last, @@ -339,8 +337,8 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa startProfilers(benchmarkParams, params); // submit tasks to threadpool - List> completed = new ArrayList>(); - CompletionService srv = new ExecutorCompletionService(executor); + List> completed = new ArrayList<>(); + CompletionService srv = new ExecutorCompletionService<>(executor); for (BenchmarkTask runner : runners) { srv.submit(runner); } @@ -401,7 +399,7 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa long allOps = 0; long measuredOps = 0; - List errors = new ArrayList(); + List errors = new ArrayList<>(); for (Future fr : completed) { try { BenchmarkTaskResult btr = fr.get(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java index aad29438c..1edf699bd 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java @@ -82,23 +82,23 @@ public Set getAll(OutputFormat out, List excludes) { public SortedSet find(OutputFormat out, List includes, List excludes) { // assume we match all benchmarks when include is empty - List regexps = new ArrayList(includes); + List regexps = new ArrayList<>(includes); if (regexps.isEmpty()) { regexps.add(Defaults.INCLUDE_BENCHMARKS); } // compile all patterns - List includePatterns = new ArrayList(regexps.size()); + List includePatterns = new ArrayList<>(regexps.size()); for (String regexp : regexps) { includePatterns.add(Pattern.compile(regexp)); } - List excludePatterns = new ArrayList(excludes.size()); + List excludePatterns = new ArrayList<>(excludes.size()); for (String regexp : excludes) { excludePatterns.add(Pattern.compile(regexp)); } // find all benchmarks containing pattern - SortedSet result = new TreeSet(); + SortedSet result = new TreeSet<>(); try { for (Reader r : getReaders()) { BufferedReader reader = null; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java index 242987a2c..0dbb2dd26 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java @@ -60,7 +60,7 @@ public static String hintsFile() { if (hintsFile == null) { try { final Set defaultHints = defaultList().get(); - List hints = new ArrayList(defaultHints.size() + 2); + List hints = new ArrayList<>(defaultHints.size() + 2); hints.add("quiet"); if (Boolean.getBoolean("jmh.blackhole.forceInline")) { hints.add("inline,org/openjdk/jmh/infra/Blackhole.*"); @@ -111,10 +111,7 @@ private static boolean isHintCompatibleVM() { } else if (Integer.valueOf(versionDigits[0]) == 5 && Integer.valueOf(versionDigits[1]) >= 10) { return true; } - } catch (NumberFormatException e) { - // unknown Zing version format - System.err.println("ERROR: Zing version format does not match 1.*.0-zing_*.*.*.*"); - } catch (ArrayIndexOutOfBoundsException e) { + } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { // unknown Zing version format System.err.println("ERROR: Zing version format does not match 1.*.0-zing_*.*.*.*"); } @@ -127,7 +124,7 @@ public Set get() { } private Set read() { - Set result = new TreeSet(); + Set result = new TreeSet<>(); try { for (Reader r : getReaders()) { @@ -167,7 +164,7 @@ private Set read() { * @return the compiler hint files specified by the command */ public static List getCompileCommandFiles(List command){ - List compileCommandFiles = new ArrayList(); + List compileCommandFiles = new ArrayList<>(); for (String cmdLineWord : command) { if (cmdLineWord.startsWith(XX_COMPILE_COMMAND_FILE)) { compileCommandFiles.add(cmdLineWord.substring(XX_COMPILE_COMMAND_FILE.length())); @@ -196,7 +193,7 @@ public static void addCompilerHints(List command) { return; } - List hintFiles = new ArrayList(); + List hintFiles = new ArrayList<>(); hintFiles.add(hintsFile()); removeCompileCommandFiles(command, hintFiles); if (hintFiles.size() == 1) { @@ -228,7 +225,7 @@ private static String mergeHintFiles(List compileCommandFiles) { return compileCommandFiles.get(0); } try { - Set hints = new TreeSet(); + Set hints = new TreeSet<>(); for(String file : compileCommandFiles) { hints.addAll(fromFile(file).get()); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java index 7f5708059..a5c6f11a6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java @@ -40,7 +40,7 @@ class ForkedMain { private static final AtomicBoolean hangupFuse = new AtomicBoolean(); - private static final AtomicReference linkRef = new AtomicReference(); + private static final AtomicReference linkRef = new AtomicReference<>(); private static volatile boolean gracefullyFinished; private static volatile Throwable exception; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 86efa6f09..b9a17dde2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -264,7 +264,7 @@ private Collection internalRun() throws RunnerException { // override the benchmark types; // this may yield new benchmark records if (!options.getBenchModes().isEmpty()) { - List newBenchmarks = new ArrayList(); + List newBenchmarks = new ArrayList<>(); for (BenchmarkListEntry br : benchmarks) { for (Mode m : options.getBenchModes()) { newBenchmarks.add(br.cloneWith(m)); @@ -278,7 +278,7 @@ private Collection internalRun() throws RunnerException { // clone with all the modes { - List newBenchmarks = new ArrayList(); + List newBenchmarks = new ArrayList<>(); for (BenchmarkListEntry br : benchmarks) { if (br.getMode() == Mode.All) { for (Mode mode : Mode.values()) { @@ -296,7 +296,7 @@ private Collection internalRun() throws RunnerException { // clone with all parameters { - List newBenchmarks = new ArrayList(); + List newBenchmarks = new ArrayList<>(); for (BenchmarkListEntry br : benchmarks) { if (br.getParams().hasValue()) { for (WorkloadParams p : explodeAllParams(br)) { @@ -332,7 +332,7 @@ private Collection internalRun() throws RunnerException { private List getActionPlans(Set benchmarks) { ActionPlan base = new ActionPlan(ActionType.FORKED); - LinkedHashSet warmupBenches = new LinkedHashSet(); + LinkedHashSet warmupBenches = new LinkedHashSet<>(); List warmupMicrosRegexp = options.getWarmupIncludes(); if (warmupMicrosRegexp != null && !warmupMicrosRegexp.isEmpty()) { @@ -351,7 +351,7 @@ private List getActionPlans(Set benchmarks) { boolean addEmbedded = false; - List result = new ArrayList(); + List result = new ArrayList<>(); for (BenchmarkListEntry br : benchmarks) { BenchmarkParams params = newBenchmarkParams(br, ActionMode.UNDEF); @@ -465,7 +465,7 @@ private BenchmarkParams newBenchmarkParams(BenchmarkListEntry benchmark, ActionM String jvm = options.getJvm().orElse( benchmark.getJvm().orElse(Utils.getCurrentJvm())); - Collection jvmArgs = new ArrayList(); + Collection jvmArgs = new ArrayList<>(); jvmArgs.addAll(options.getJvmArgsPrepend().orElse( benchmark.getJvmArgsPrepend().orElse(Collections.emptyList()))); @@ -488,7 +488,7 @@ private BenchmarkParams newBenchmarkParams(BenchmarkListEntry benchmark, ActionM private List explodeAllParams(BenchmarkListEntry br) throws RunnerException { Map benchParams = br.getParams().orElse(Collections.emptyMap()); - List ps = new ArrayList(); + List ps = new ArrayList<>(); for (Map.Entry e : benchParams.entrySet()) { String k = e.getKey(); String[] vals = e.getValue(); @@ -507,7 +507,7 @@ private List explodeAllParams(BenchmarkListEntry br) throws Runn idx++; } } else { - List newPs = new ArrayList(); + List newPs = new ArrayList<>(); for (WorkloadParams p : ps) { int idx = 0; for (String v : values) { @@ -526,7 +526,7 @@ private List explodeAllParams(BenchmarkListEntry br) throws Runn private Collection runBenchmarks(SortedSet benchmarks) throws RunnerException { out.startRun(); - Multimap results = new TreeMultimap(); + Multimap results = new TreeMultimap<>(); List plan = getActionPlans(benchmarks); etaBeforeBenchmarks(plan); @@ -561,7 +561,7 @@ private Collection runBenchmarks(SortedSet benchm } private SortedSet mergeRunResults(Multimap results) { - SortedSet result = new TreeSet(RunResult.DEFAULT_SORT_COMPARATOR); + SortedSet result = new TreeSet<>(RunResult.DEFAULT_SORT_COMPARATOR); for (BenchmarkParams key : results.keys()) { result.add(new RunResult(key, results.get(key))); } @@ -569,7 +569,7 @@ private SortedSet mergeRunResults(Multimap runSeparate(ActionPlan actionPlan) { - Multimap results = new HashMultimap(); + Multimap results = new HashMultimap<>(); if (actionPlan.getMeasurementActions().size() != 1) { throw new IllegalStateException("Expect only single benchmark in the action plan, but was " + actionPlan.getMeasurementActions().size()); @@ -592,7 +592,7 @@ private Multimap runSeparate(ActionPlan action printErr &= prof.allowPrintErr(); } - List profilersRev = new ArrayList(profilers); + List profilersRev = new ArrayList<>(profilers); Collections.reverse(profilersRev); boolean forcePrint = options.verbosity().orElse(Defaults.VERBOSITY).equalsOrHigherThan(VerboseMode.EXTRA); @@ -651,7 +651,7 @@ private Multimap runSeparate(ActionPlan action } out.println(""); - List consumed = new ArrayList(); + List consumed = new ArrayList<>(); if (!printOut) consumed.add("stdout"); if (!printErr) consumed.add("stderr"); if (!consumed.isEmpty()) { @@ -787,14 +787,14 @@ private List doFork(BinaryLinkServer reader, List comma */ List getForkedMainCommand(BenchmarkParams benchmark, List profilers, String host, int port) { // Poll profilers for options - List javaInvokeOptions = new ArrayList(); - List javaOptions = new ArrayList(); + List javaInvokeOptions = new ArrayList<>(); + List javaOptions = new ArrayList<>(); for (ExternalProfiler prof : profilers) { javaInvokeOptions.addAll(prof.addJVMInvokeOptions(benchmark)); javaOptions.addAll(prof.addJVMOptions(benchmark)); } - List command = new ArrayList(); + List command = new ArrayList<>(); // prefix java invoke options, if any profiler wants it command.addAll(javaInvokeOptions); @@ -834,7 +834,7 @@ List getForkedMainCommand(BenchmarkParams benchmark, List getVersionMainCommand(BenchmarkParams benchmark) { - List command = new ArrayList(); + List command = new ArrayList<>(); // use supplied jvm, if given command.add(benchmark.getJvm()); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java index ed84bf15e..19f11df42 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java @@ -36,7 +36,7 @@ public class WorkloadParams implements Comparable, Serializable private final SortedMap params; public WorkloadParams() { - params = new TreeMap(); + params = new TreeMap<>(); } private WorkloadParams(SortedMap params) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index 0a830473d..876c017e3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -85,7 +85,7 @@ public void startBenchmark(BenchmarkParams params) { int[] tg = params.getThreadGroups(); // TODO: Make params.getThreadGroupLabels return List - List labels = new ArrayList(params.getThreadGroupLabels()); + List labels = new ArrayList<>(params.getThreadGroupLabels()); String[] ss = new String[tg.length]; for (int cnt = 0; cnt < tg.length; cnt++) { ss[cnt] = tg[cnt] + "x \"" + labels.get(cnt) + "\""; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkClient.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkClient.java index 8c36252b2..a88a04ac8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkClient.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkClient.java @@ -120,10 +120,7 @@ private void pushFrame(Serializable frame) throws IOException { private Object readFrame() throws IOException, ClassNotFoundException { try { return ois.readObject(); - } catch (ClassNotFoundException ex) { - failed = true; - throw ex; - } catch (IOException ex) { + } catch (ClassNotFoundException | IOException ex) { failed = true; throw ex; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkServer.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkServer.java index 8fc227fdc..b16f75bf6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkServer.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkServer.java @@ -81,8 +81,8 @@ public final class BinaryLinkServer { public BinaryLinkServer(Options opts, OutputFormat out) throws IOException { this.opts = opts; this.out = out; - this.methods = new HashMap(); - this.forbidden = new HashSet(); + this.methods = new HashMap<>(); + this.forbidden = new HashSet<>(); // enumerate methods for (Method m : OutputFormat.class.getMethods()) { @@ -101,11 +101,11 @@ public BinaryLinkServer(Options opts, OutputFormat out) throws IOException { acceptor = new Acceptor(); acceptor.start(); - handler = new AtomicReference(); - metadata = new AtomicReference(); + handler = new AtomicReference<>(); + metadata = new AtomicReference<>(); results = new AtomicReference>(new ArrayList()); - exception = new AtomicReference(); - plan = new AtomicReference(); + exception = new AtomicReference<>(); + plan = new AtomicReference<>(); } public void terminate() { @@ -174,11 +174,7 @@ private InetAddress getListenAddress() { try { Method m = InetAddress.class.getMethod("getLoopbackAddress"); return (InetAddress) m.invoke(null); - } catch (InvocationTargetException e) { - // shun - } catch (NoSuchMethodException e) { - // shun - } catch (IllegalAccessException e) { + } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { // shun } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/ClassConventions.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/ClassConventions.java index 8d855c388..26c117b19 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/ClassConventions.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/ClassConventions.java @@ -30,7 +30,7 @@ class ClassConventions { - private static final Map METHOD_NAMES = new HashMap(); + private static final Map METHOD_NAMES = new HashMap<>(); public static String getMethodName(Method m) { String result = METHOD_NAMES.get(m); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java index e01d263eb..285aeeda9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java @@ -51,17 +51,17 @@ public class CommandLineOptions implements Options { private final Optional warmupIterations; private final Optional warmupTime; private final Optional warmupBatchSize; - private final List benchMode = new ArrayList(); + private final List benchMode = new ArrayList<>(); private final Optional threads; - private final List threadGroups = new ArrayList(); + private final List threadGroups = new ArrayList<>(); private final Optional synchIterations; private final Optional gcEachIteration; private final Optional verbose; private final Optional failOnError; - private final List profilers = new ArrayList(); + private final List profilers = new ArrayList<>(); private final Optional timeUnit; private final Optional opsPerInvocation; - private final List regexps = new ArrayList(); + private final List regexps = new ArrayList<>(); private final Optional fork; private final Optional warmupFork; private final Optional output; @@ -71,10 +71,10 @@ public class CommandLineOptions implements Options { private final Optional> jvmArgs; private final Optional> jvmArgsAppend; private final Optional> jvmArgsPrepend; - private final List excludes = new ArrayList(); + private final List excludes = new ArrayList<>(); private final Optional warmupMode; - private final List warmupMicros = new ArrayList(); - private final Multimap params = new HashMultimap(); + private final List warmupMicros = new ArrayList<>(); + private final Multimap params = new HashMultimap<>(); private final boolean list; private final boolean listWithParams; private final boolean listResultFormats; @@ -333,7 +333,7 @@ public CommandLineOptions(String... argv) throws CommandLineOptionException { if (set.has(optBenchmarkMode)) { try { - List modes = new ArrayList(); + List modes = new ArrayList<>(); for (String m : optBenchmarkMode.values(set)) { modes.add(Mode.deepValueOf(m)); } @@ -653,7 +653,7 @@ public List getProfilers() { @Override public Collection getBenchModes() { - return new HashSet(benchMode); + return new HashSet<>(benchMode); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java index 1ee75021f..3e1b2a85e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java @@ -72,7 +72,7 @@ private static void checkGreaterOrEqual(int value, int minValue, String s) { // --------------------------------------------------------------------------- - private final List regexps = new ArrayList(); + private final List regexps = new ArrayList<>(); @Override public ChainedOptionsBuilder include(String regexp) { @@ -82,7 +82,7 @@ public ChainedOptionsBuilder include(String regexp) { @Override public List getIncludes() { - List result = new ArrayList(); + List result = new ArrayList<>(); result.addAll(regexps); if (otherOptions != null) { @@ -94,7 +94,7 @@ public List getIncludes() { // --------------------------------------------------------------------------- - private final List excludes = new ArrayList(); + private final List excludes = new ArrayList<>(); @Override public ChainedOptionsBuilder exclude(String regexp) { @@ -104,7 +104,7 @@ public ChainedOptionsBuilder exclude(String regexp) { @Override public List getExcludes() { - List result = new ArrayList(); + List result = new ArrayList<>(); result.addAll(excludes); if (otherOptions != null) { @@ -192,7 +192,7 @@ public Optional shouldDoGC() { // --------------------------------------------------------------------------- - private List profilers = new ArrayList(); + private List profilers = new ArrayList<>(); @Override public ChainedOptionsBuilder addProfiler(Class prof) { @@ -410,7 +410,7 @@ public Optional getWarmupMode() { // --------------------------------------------------------------------------- - private final List warmupMicros = new ArrayList(); + private final List warmupMicros = new ArrayList<>(); @Override public ChainedOptionsBuilder includeWarmup(String regexp) { @@ -420,7 +420,7 @@ public ChainedOptionsBuilder includeWarmup(String regexp) { @Override public List getWarmupIncludes() { - List result = new ArrayList(); + List result = new ArrayList<>(); result.addAll(warmupMicros); if (otherOptions != null) { result.addAll(otherOptions.getWarmupIncludes()); @@ -672,7 +672,7 @@ public ChainedOptionsBuilder detectJvmArgs() { // --------------------------------------------------------------------------- - private Multimap params = new HashMultimap(); + private Multimap params = new HashMultimap<>(); @Override public Optional> getParameter(String name) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/BoundedPriorityQueue.java b/jmh-core/src/main/java/org/openjdk/jmh/util/BoundedPriorityQueue.java index ed32d8aef..d5cd9bf85 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/BoundedPriorityQueue.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/BoundedPriorityQueue.java @@ -62,7 +62,7 @@ public BoundedPriorityQueue(int maxSize) { public BoundedPriorityQueue(int maxSize, Comparator comparator) { this.maxSize = maxSize; this.comparator = reverse(comparator); - this.queue = new PriorityQueue(10, this.comparator); + this.queue = new PriorityQueue<>(10, this.comparator); } /** diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java index 0e0082407..397a38150 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java @@ -57,7 +57,7 @@ private ClassUtils() { * @return list of methods. */ public static List enumerateMethods(Class clazz) { - List result = new ArrayList(); + List result = new ArrayList<>(); Class current = clazz; while (current != null) { result.addAll(Arrays.asList(current.getDeclaredMethods())); @@ -149,7 +149,7 @@ public static Map denseClassNames(Collection src) { prefix[c] = prefixCut ? String.valueOf(prefix[c].charAt(0)) : ""; } - Map result = new HashMap(); + Map result = new HashMap<>(); for (String s : src) { int prefixLen = prefix.length; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Deduplicator.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Deduplicator.java index 58ad59db8..ec0baceac 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Deduplicator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Deduplicator.java @@ -32,7 +32,7 @@ public class Deduplicator { final ConcurrentMap map; public Deduplicator() { - map = new ConcurrentHashMap(); + map = new ConcurrentHashMap<>(); } public T dedup(T t) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/DelegatingMultimap.java b/jmh-core/src/main/java/org/openjdk/jmh/util/DelegatingMultimap.java index 37bbdb71a..bfb66b198 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/DelegatingMultimap.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/DelegatingMultimap.java @@ -40,7 +40,7 @@ public DelegatingMultimap(Map> map) { } protected Collection createValueCollection() { - return new ArrayList(); + return new ArrayList<>(); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java index 66b058c43..6eb85b9c3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java @@ -100,7 +100,7 @@ public static Collection tail(File file, int num) throws IOException { try { fis = new FileInputStream(file); BufferedReader reader = new BufferedReader(new InputStreamReader(fis)); - LinkedList lines = new LinkedList(); + LinkedList lines = new LinkedList<>(); String line; while ((line = reader.readLine()) != null) { lines.add(line); @@ -116,7 +116,7 @@ public static Collection tail(File file, int num) throws IOException { public static Collection readAllLines(Reader src) throws IOException { BufferedReader reader = new BufferedReader(src); - List lines = new ArrayList(); + List lines = new ArrayList<>(); String line; while ((line = reader.readLine()) != null) { lines.add(line); @@ -158,7 +158,7 @@ public static void writeLines(File file, Collection lines) throws IOExce } public static void appendLines(File file, Collection lines) throws IOException { - Collection newLines = new ArrayList(); + Collection newLines = new ArrayList<>(); try { newLines.addAll(readAllLines(file)); } catch (IOException e) { @@ -169,12 +169,12 @@ public static void appendLines(File file, Collection lines) throws IOExc } public static Collection getClasses(File root) { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); - List newDirs = new ArrayList(); + List newDirs = new ArrayList<>(); newDirs.add(root); while (!newDirs.isEmpty()) { - List add = new ArrayList(); + List add = new ArrayList<>(); for (File dir : newDirs) { File[] files = dir.listFiles(); if (files != null) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/HashsetMultimap.java b/jmh-core/src/main/java/org/openjdk/jmh/util/HashsetMultimap.java index 205156e12..9fccc1241 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/HashsetMultimap.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/HashsetMultimap.java @@ -38,6 +38,6 @@ public HashsetMultimap() { @Override protected Collection createValueCollection() { - return new HashSet(); + return new HashSet<>(); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/InputStreamDrainer.java b/jmh-core/src/main/java/org/openjdk/jmh/util/InputStreamDrainer.java index 46a91881d..814ac2fed 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/InputStreamDrainer.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/InputStreamDrainer.java @@ -57,7 +57,7 @@ public InputStreamDrainer(InputStream in) { */ public InputStreamDrainer(InputStream in, OutputStream out) { this.in = in; - outs = new ArrayList(); + this.outs = new ArrayList<>(); addOutputStream(out); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/IntervalMap.java b/jmh-core/src/main/java/org/openjdk/jmh/util/IntervalMap.java index 27b7c7324..a97b89024 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/IntervalMap.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/IntervalMap.java @@ -32,7 +32,7 @@ public class IntervalMap { final SortedMap from; public IntervalMap() { - from = new TreeMap(); + from = new TreeMap<>(); } public void add(T val, long from, long to) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java index 19ad96914..d54af7525 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java @@ -181,7 +181,7 @@ public boolean hasNext() { @Override public Map.Entry next() { - return new AbstractMap.SimpleImmutableEntry(values[currentIndex++], 1L); + return new AbstractMap.SimpleImmutableEntry<>(values[currentIndex++], 1L); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java index 4192dcab5..792d33a2d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java @@ -32,7 +32,7 @@ public class MultisetStatistics extends AbstractStatistics { private final Multiset values; public MultisetStatistics() { - values = new TreeMultiset(); + values = new TreeMultiset<>(); } public void addValue(double d, long count) { @@ -118,7 +118,7 @@ public int[] getHistogram(double[] levels) { throw new IllegalArgumentException("Expected more than two levels"); } - List vs = new ArrayList(values.keys()); + List vs = new ArrayList<>(values.keys()); Collections.sort(vs); int[] result = new int[levels.length - 1]; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java index 4cb7cda79..60c4b91e9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java @@ -29,7 +29,7 @@ public class Multisets { public static List countHighest(Multiset set, int top) { - Queue> q = new BoundedPriorityQueue>(top, new Comparator>() { + Queue> q = new BoundedPriorityQueue<>(top, new Comparator>() { @Override public int compare(Map.Entry o1, Map.Entry o2) { return o2.getValue().compareTo(o1.getValue()); @@ -38,7 +38,7 @@ public int compare(Map.Entry o1, Map.Entry o2) { q.addAll(set.entrySet()); - List result = new ArrayList(q.size()); + List result = new ArrayList<>(q.size()); Map.Entry pair; while ((pair = q.poll()) != null) { @@ -52,7 +52,7 @@ public int compare(Map.Entry o1, Map.Entry o2) { } public static List sortedDesc(final Multiset set) { - List sorted = new ArrayList(); + List sorted = new ArrayList<>(); sorted.addAll(set.keys()); Collections.sort(sorted, new Comparator() { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java index 9a14fbff2..530571566 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java @@ -60,7 +60,7 @@ public Optional orAnother(Optional alternative) { * @return empty option */ public static Optional none() { - return new Optional(); + return new Optional<>(); } /** @@ -70,7 +70,7 @@ public static Optional none() { * @return option with value */ public static Optional of(T val) { - return new Optional(val); + return new Optional<>(val); } public static Optional eitherOf(T val) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/SampleBuffer.java b/jmh-core/src/main/java/org/openjdk/jmh/util/SampleBuffer.java index 72985cca2..7d925e4f3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/SampleBuffer.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/SampleBuffer.java @@ -42,8 +42,7 @@ public SampleBuffer() { } public void half() { - for (int i = 0; i < hdr.length; i++) { - int[] bucket = hdr[i]; + for (int[] bucket : hdr) { if (bucket != null) { for (int j = 0; j < bucket.length; j++) { int nV = bucket[j] / 2; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java index 527a9e8e6..dc23796a1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java @@ -99,7 +99,7 @@ public boolean hasNext() { @Override public Map.Entry next() { entryReturned = true; - return new AbstractMap.SimpleImmutableEntry(value, 1L); + return new AbstractMap.SimpleImmutableEntry<>(value, 1L); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 9c57f8cdd..443cf21ac 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -46,9 +46,7 @@ public class Utils { Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); unsafe.setAccessible(true); U = (Unsafe) unsafe.get(null); - } catch (NoSuchFieldException e) { - throw new IllegalStateException(e); - } catch (IllegalAccessException e) { + } catch (NoSuchFieldException | IllegalAccessException e) { throw new IllegalStateException(e); } } @@ -57,7 +55,7 @@ private Utils() { } - private static final ConcurrentMap PATTERNS = new ConcurrentHashMap(); + private static final ConcurrentMap PATTERNS = new ConcurrentHashMap<>(); public static Pattern lazyCompile(String pattern) { Pattern patt = PATTERNS.get(pattern); @@ -118,7 +116,7 @@ public static String join(String[] src, String delim) { } public static Collection splitQuotedEscape(String src) { - List results = new ArrayList(); + List results = new ArrayList<>(); StringBuilder sb = new StringBuilder(); boolean escaped = false; @@ -203,7 +201,7 @@ public static int figureOutHotCPUs() { int warmupTime = 1000; long lastChange = System.currentTimeMillis(); - List> futures = new ArrayList>(); + List> futures = new ArrayList<>(); futures.add(service.submit(new BurningTask())); int max = 0; @@ -312,7 +310,7 @@ private static void indent(PrintWriter pw, int indent) { } public static Collection rewrap(String lines) { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); String[] words = lines.split("[ \n]"); String line = ""; int cols = 0; @@ -421,7 +419,7 @@ public static long getPid() { } public static Collection tryWith(String... cmd) { - Collection messages = new ArrayList(); + Collection messages = new ArrayList<>(); try { Process p = new ProcessBuilder(cmd).start(); @@ -451,7 +449,7 @@ public static Collection tryWith(String... cmd) { } public static Collection runWith(List cmd) { - Collection messages = new ArrayList(); + Collection messages = new ArrayList<>(); try { Process p = new ProcessBuilder(cmd).start(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java index efca235b1..c6d0a8104 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java @@ -139,7 +139,7 @@ public Optional> nextOptionalStringCollection() { return Optional.none(); } else if (tag == TAG_STRING_COLLECTION) { int len = readLen(); - Collection list = new ArrayList(); + Collection list = new ArrayList<>(); for (int c = 0; c < len; c++) { list.add(readString()); } @@ -168,7 +168,7 @@ public Optional> nextOptionalParamCollection() { if (tag == Constants.TAG_EMPTY_OPTIONAL) { return Optional.none(); } else if (tag == TAG_PARAM_MAP) { - Map result = new HashMap(); + Map result = new HashMap<>(); int kvs = readLen(); for (int kv = 0; kv < kvs; kv++) { diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java index c37091144..97ee63fa1 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java @@ -47,7 +47,7 @@ public class ResultFormatTest { private Collection getStub() { - Collection results = new TreeSet(RunResult.DEFAULT_SORT_COMPARATOR); + Collection results = new TreeSet<>(RunResult.DEFAULT_SORT_COMPARATOR); Random r = new Random(12345); Random ar = new Random(12345); @@ -74,9 +74,9 @@ private Collection getStub() { Collections.emptyList(), TimeValue.days(1)); - Collection benchmarkResults = new ArrayList(); + Collection benchmarkResults = new ArrayList<>(); for (int f = 0; f < r.nextInt(10); f++) { - Collection iterResults = new ArrayList(); + Collection iterResults = new ArrayList<>(); for (int c = 0; c < r.nextInt(10); c++) { IterationResult res = new IterationResult(params, params.getMeasurement(), null); res.addResult(new ThroughputResult(ResultRole.PRIMARY, "test", r.nextInt(1000), 1000 * 1000, TimeUnit.MILLISECONDS)); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/CompilerHintsTest.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/CompilerHintsTest.java index 7d9f4a99a..8f5d571c6 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/CompilerHintsTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/CompilerHintsTest.java @@ -47,7 +47,7 @@ public void storeCurrentVM() { public void testListNotEmptyForCompliantJvms() { for (String name : CompilerHints.HINT_COMPATIBLE_JVMS) { System.setProperty("java.vm.name", name); - List args = new ArrayList(); + List args = new ArrayList<>(); CompilerHints.addCompilerHints(args); assertFalse(args.isEmpty()); } @@ -58,7 +58,7 @@ public void testListEmptyForOldZingJvms() { System.setProperty("java.vm.name", "Zing"); System.setProperty("java.version", "1.7.0-zing_5.9.2.0"); // load up some default hints - List args = new ArrayList(); + List args = new ArrayList<>(); CompilerHints.addCompilerHints(args); assertTrue(args.isEmpty()); } @@ -68,7 +68,7 @@ public void testListNotEmptyForNewerZingJvms() { System.setProperty("java.vm.name", "Zing"); System.setProperty("java.version", "1.7.0-zing_5.10.2.0"); // load up some default hints - List args = new ArrayList(); + List args = new ArrayList<>(); CompilerHints.addCompilerHints(args); assertFalse(args.isEmpty()); } @@ -76,7 +76,7 @@ public void testListNotEmptyForNewerZingJvms() { @Test public void testListEmptyForNonCompliantJvms() { System.setProperty("java.vm.name", "StupidVmCantTakeAHint"); - List args = new ArrayList(); + List args = new ArrayList<>(); CompilerHints.addCompilerHints(args); assertTrue(args.isEmpty()); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/BoundedPriorityQueueTest.java b/jmh-core/src/test/java/org/openjdk/jmh/util/BoundedPriorityQueueTest.java index 472d03f45..6d72545e8 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/BoundedPriorityQueueTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/BoundedPriorityQueueTest.java @@ -33,7 +33,7 @@ public class BoundedPriorityQueueTest { @Test public void top3Smallest() { - Queue queue = new BoundedPriorityQueue(3); + Queue queue = new BoundedPriorityQueue<>(3); queue.add(50); queue.add(40); queue.add(10); @@ -50,7 +50,7 @@ public void top3Smallest() { @Test public void top3Largest() { - Queue queue = new BoundedPriorityQueue(3, Collections.reverseOrder()); + Queue queue = new BoundedPriorityQueue<>(3, Collections.reverseOrder()); queue.add(50); queue.add(40); queue.add(10); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetsTest.java b/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetsTest.java index 448ada74d..8b6cd613a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetsTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetsTest.java @@ -32,7 +32,7 @@ public class MultisetsTest { @Test public void testCountHighest() { - Multiset set = new HashMultiset(); + Multiset set = new HashMultiset<>(); set.add(10); set.add(10); set.add(10); @@ -50,7 +50,7 @@ public void testCountHighest() { public void testCountHighest_2() { // Regression test for CODETOOLS-7901411 - Multiset set = new HashMultiset(); + Multiset set = new HashMultiset<>(); set.add("Meh", 85); set.add("Blah", 17); set.add("Choo", 1); @@ -65,7 +65,7 @@ public void testCountHighest_2() { @Test public void testSortedDesc() { - Multiset set = new HashMultiset(); + Multiset set = new HashMultiset<>(); set.add(10); set.add(10); set.add(10); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestLineTest.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestLineTest.java index 7949b4b8b..22fff1b7e 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestLineTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestLineTest.java @@ -61,7 +61,7 @@ public void test() { writer.putOptionalStringCollection(Optional.>eitherOf(Arrays.asList("foo", "bar", "baz"))); writer.putOptionalStringCollection(Optional.>none()); - HashMap expectedMap = new HashMap(); + HashMap expectedMap = new HashMap<>(); expectedMap.put("key1", new String[] {"val1", "val2"}); expectedMap.put("key2", new String[] {"val3", "val4"}); writer.putOptionalParamCollection(Optional.>eitherOf(expectedMap)); diff --git a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java index a69fb0c8a..a8c8cad0c 100644 --- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java +++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APClassInfo.java @@ -81,7 +81,7 @@ public T getAnnotation(Class annClass) { @Override public Collection getConstructors() { if (isSpecial) return Collections.emptyList(); - Collection mis = new ArrayList(); + Collection mis = new ArrayList<>(); for (ExecutableElement e : ElementFilter.constructorsIn(el.getEnclosedElements())) { mis.add(new APMethodInfo(processEnv, this, e)); } @@ -103,7 +103,7 @@ public String getQualifiedName() { @Override public Collection getFields() { if (isSpecial) return Collections.emptyList(); - List ls = new ArrayList(); + List ls = new ArrayList<>(); for (VariableElement e : ElementFilter.fieldsIn(el.getEnclosedElements())) { ls.add(new APFieldInfo(processEnv, e)); } @@ -113,7 +113,7 @@ public Collection getFields() { @Override public Collection getMethods() { if (isSpecial) return Collections.emptyList(); - Collection mis = new ArrayList(); + Collection mis = new ArrayList<>(); for (ExecutableElement e : ElementFilter.methodsIn(el.getEnclosedElements())) { mis.add(new APMethodInfo(processEnv, this, e)); } @@ -191,7 +191,7 @@ public boolean isEnum() { @Override public Collection getEnumConstants() { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); for (Element e : el.getEnclosedElements()) { if (e.getKind() == ElementKind.ENUM_CONSTANT) { result.add(e.getSimpleName().toString()); diff --git a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorSource.java b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorSource.java index 2e3b2bca7..1d4ad999e 100644 --- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorSource.java +++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorSource.java @@ -57,7 +57,7 @@ public Collection getClasses() { return classInfos; } - Collection discoveredClasses = new TreeSet(new Comparator() { + Collection discoveredClasses = new TreeSet<>(new Comparator() { @Override public int compare(TypeElement o1, TypeElement o2) { return o1.getQualifiedName().toString().compareTo(o2.getQualifiedName().toString()); @@ -78,7 +78,7 @@ public int compare(TypeElement o1, TypeElement o2) { int lastSize = 0; while (discoveredClasses.size() > lastSize) { lastSize = discoveredClasses.size(); - List newClasses = new ArrayList(); + List newClasses = new ArrayList<>(); for (Element e : discoveredClasses) { try { TypeElement walk = (TypeElement) e; @@ -110,7 +110,7 @@ public int compare(TypeElement o1, TypeElement o2) { } protected Collection convert(Collection els) { - List list = new ArrayList(); + List list = new ArrayList<>(); for (TypeElement el : els) { list.add(new APClassInfo(processingEnv, el)); } diff --git a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APMethodInfo.java b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APMethodInfo.java index 8eeedc260..25f2abc17 100644 --- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APMethodInfo.java +++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APMethodInfo.java @@ -70,7 +70,7 @@ public String getReturnType() { @Override public Collection getParameters() { - Collection pis = new ArrayList(); + Collection pis = new ArrayList<>(); for (VariableElement v : el.getParameters()) { pis.add(new APParameterInfo(processEnv, v)); } diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java index 11f6d6793..8badf9b2f 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java @@ -54,7 +54,7 @@ class ASMClassInfo extends ClassVisitor implements ClassInfo { private final List methods; private final List constructors; private final List fields; - private final Map annotations = new HashMap(); + private final Map annotations = new HashMap<>(); private final ClassInfoRepo classInfos; private String superName; private String declaringClass; @@ -64,9 +64,9 @@ class ASMClassInfo extends ClassVisitor implements ClassInfo { public ASMClassInfo(ClassInfoRepo classInfos) { super(Opcodes.ASM4); this.classInfos = classInfos; - methods = new ArrayList(); - constructors = new ArrayList(); - fields = new ArrayList(); + this.methods = new ArrayList<>(); + this.constructors = new ArrayList<>(); + this.fields = new ArrayList<>(); } public String getIdName() { @@ -219,7 +219,7 @@ public boolean isEnum() { public Collection getEnumConstants() { if (isEnum()) { try { - Collection res = new ArrayList(); + Collection res = new ArrayList<>(); for (Object cnst : Class.forName(origQualifiedName, false, Thread.currentThread().getContextClassLoader()).getEnumConstants()) { res.add(cnst.toString()); } diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMFieldInfo.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMFieldInfo.java index 385b37f90..5ca984a8e 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMFieldInfo.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMFieldInfo.java @@ -50,7 +50,7 @@ public ASMFieldInfo(FieldVisitor fieldVisitor, ASMClassInfo declaringClass, int this.access = access; this.name = name; this.type = type; - this.annotations = new HashMap(); + this.annotations = new HashMap<>(); } @Override diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMMethodInfo.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMMethodInfo.java index 44b54bebf..148c0f9e4 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMMethodInfo.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMMethodInfo.java @@ -56,7 +56,7 @@ public ASMMethodInfo(MethodVisitor methodVisitor, ClassInfoRepo repo, ASMClassIn this.access = access; this.name = name; this.returnType = Type.getReturnType(desc).getClassName(); - this.annotations = new HashMap(); + this.annotations = new HashMap<>(); this.argumentTypes = Type.getArgumentTypes(desc); } @@ -103,7 +103,7 @@ public String getReturnType() { @Override public Collection getParameters() { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); for (Type t : argumentTypes) { ClassInfo ci = repo.get(t.getClassName()); result.add(new ASMParameterInfo(ci)); diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/AnnotationInvocationHandler.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/AnnotationInvocationHandler.java index e45bb2587..4fc262784 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/AnnotationInvocationHandler.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/AnnotationInvocationHandler.java @@ -44,7 +44,7 @@ class AnnotationInvocationHandler extends AnnotationVisitor implements Invocatio public AnnotationInvocationHandler(String className, AnnotationVisitor annotationVisitor) { super(Opcodes.ASM4, annotationVisitor); this.className = className; - this.values = new HashMultimap(); + this.values = new HashMultimap<>(); } @Override @@ -58,12 +58,13 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl return equalsImpl(args[0]); if (paramTypes.length != 0) throw new AssertionError("Too many parameters for an annotation method"); - if (member.equals("toString")) { - return toStringImpl(); - } else if (member.equals("hashCode")) { - return hashcodeImpl(); - } else if (member.equals("annotationType")) { - throw new IllegalStateException("annotationType is not implemented"); + switch (member) { + case "toString": + return toStringImpl(); + case "hashCode": + return hashcodeImpl(); + case "annotationType": + throw new IllegalStateException("annotationType is not implemented"); } /* @@ -162,7 +163,7 @@ private boolean equalsImpl(Object arg) { return false; } - Set keys = new HashSet(); + Set keys = new HashSet<>(); keys.addAll(values.keys()); keys.addAll(other.values.keys()); diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ClassInfoRepo.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ClassInfoRepo.java index d259aba75..abc89b60c 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ClassInfoRepo.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ClassInfoRepo.java @@ -33,7 +33,7 @@ class ClassInfoRepo { - private final Map map = new HashMap(); + private final Map map = new HashMap<>(); public ClassInfo get(String desc) { desc = desc.replace('/', '.'); diff --git a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java index edf90667e..327da999e 100644 --- a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java +++ b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java @@ -77,7 +77,7 @@ public String getQualifiedName() { @Override public Collection getFields() { - Collection fis = new ArrayList(); + Collection fis = new ArrayList<>(); for (Field f : klass.getDeclaredFields()) { fis.add(new RFFieldInfo(this, f)); } @@ -86,7 +86,7 @@ public Collection getFields() { @Override public Collection getConstructors() { - Collection mis = new ArrayList(); + Collection mis = new ArrayList<>(); for (Constructor m : klass.getDeclaredConstructors()) { mis.add(new RFConstructorInfo(this, m)); } @@ -95,7 +95,7 @@ public Collection getConstructors() { @Override public Collection getMethods() { - Collection mis = new ArrayList(); + Collection mis = new ArrayList<>(); for (Method m : klass.getDeclaredMethods()) { mis.add(new RFMethodInfo(this, m)); } @@ -160,7 +160,7 @@ public boolean isEnum() { @Override public Collection getEnumConstants() { - Collection res = new ArrayList(); + Collection res = new ArrayList<>(); for (Object cnst : klass.getEnumConstants()) { res.add(cnst.toString()); } diff --git a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFConstructorInfo.java b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFConstructorInfo.java index 00f1e5a04..a66e28c2e 100644 --- a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFConstructorInfo.java +++ b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFConstructorInfo.java @@ -66,7 +66,7 @@ public String getReturnType() { @Override public Collection getParameters() { - Collection pis = new ArrayList(); + Collection pis = new ArrayList<>(); for (Class cl : m.getParameterTypes()) { pis.add(new RFParameterInfo(cl)); } diff --git a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFGeneratorSource.java b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFGeneratorSource.java index 79e560ff8..a212c4b11 100644 --- a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFGeneratorSource.java +++ b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFGeneratorSource.java @@ -36,12 +36,12 @@ public class RFGeneratorSource implements GeneratorSource { private final Collection classes; public RFGeneratorSource() { - this.classes = new ArrayList(); + this.classes = new ArrayList<>(); } @Override public Collection getClasses() { - Collection cis = new ArrayList(); + Collection cis = new ArrayList<>(); for (Class c : classes) { cis.add(new RFClassInfo(c)); } diff --git a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFMethodInfo.java b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFMethodInfo.java index 1e9b30638..e498f6580 100644 --- a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFMethodInfo.java +++ b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFMethodInfo.java @@ -66,7 +66,7 @@ public String getReturnType() { @Override public Collection getParameters() { - Collection pis = new ArrayList(); + Collection pis = new ArrayList<>(); for (Class cl : m.getParameterTypes()) { pis.add(new RFParameterInfo(cl)); } diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java index 78de0eb2c..75b18204a 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java @@ -162,7 +162,7 @@ public static void main(String[] args) throws RunnerException { * Population. */ public static class Population { - private final List list = new ArrayList(); + private final List list = new ArrayList<>(); public void addChromosome(Chromosome c) { list.add(c); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_26_BatchSize.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_26_BatchSize.java index 5c42f2096..8335dbe2d 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_26_BatchSize.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_26_BatchSize.java @@ -69,7 +69,7 @@ public class JMHSample_26_BatchSize { * Suppose we want to measure insertion in the middle of the list. */ - List list = new LinkedList(); + List list = new LinkedList<>(); @Benchmark @Warmup(iterations = 5, time = 1) diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_29_StatesDAG.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_29_StatesDAG.java index c910357fc..554d4ebaf 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_29_StatesDAG.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_29_StatesDAG.java @@ -109,12 +109,12 @@ public static class Shared { @Setup public synchronized void setup() { - all = new ArrayList(); + all = new ArrayList<>(); for (int c = 0; c < 10; c++) { all.add(new Counter()); } - available = new LinkedList(); + available = new LinkedList<>(); available.addAll(all); } diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java index cf06a8a53..53043e4de 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java @@ -79,7 +79,7 @@ public class JMHSample_30_Interrupts { @Setup public void setup() { - q = new ArrayBlockingQueue(1); + q = new ArrayBlockingQueue<>(1); } @Group("Q") diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java index 5bea82f5c..312e8b5b2 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java @@ -76,8 +76,8 @@ public class JMHSample_31_InfraParams { @Setup public void setup(BenchmarkParams params) { int capacity = 16 * THREAD_SLICE * params.getThreads(); - mapSingle = new ConcurrentHashMap(capacity, 0.75f, 1); - mapFollowThreads = new ConcurrentHashMap(capacity, 0.75f, params.getThreads()); + mapSingle = new ConcurrentHashMap<>(capacity, 0.75f, 1); + mapFollowThreads = new ConcurrentHashMap<>(capacity, 0.75f, params.getThreads()); } /* @@ -90,7 +90,7 @@ public static class Ids { @Setup public void setup(ThreadParams threads) { - ids = new ArrayList(); + ids = new ArrayList<>(); for (int c = 0; c < THREAD_SLICE; c++) { ids.add("ID" + (THREAD_SLICE * threads.getThreadIndex() + c)); } diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java index 9bd7eabb3..12dc2125f 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java @@ -89,12 +89,15 @@ public static class Maps { @Setup public void setup() { - if (type.equals("hashmap")) { - map = new HashMap(); - } else if (type.equals("treemap")) { - map = new TreeMap(); - } else { - throw new IllegalStateException("Unknown type: " + type); + switch (type) { + case "hashmap": + map = new HashMap<>(); + break; + case "treemap": + map = new TreeMap<>(); + break; + default: + throw new IllegalStateException("Unknown type: " + type); } begin = 1; From e79a303292b8ec5c5fae03f7652d62e7e553e2fe Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Nov 2016 14:51:34 +0100 Subject: [PATCH 054/342] Manual migration to JDK 7 language features: try-with-resources and suppressed exceptions --- .../generators/core/BenchmarkGenerator.java | 16 ++----- .../jmh/profile/AbstractPerfAsmProfiler.java | 17 ++----- .../jmh/profile/LinuxPerfAsmProfiler.java | 15 ++---- .../jmh/profile/LinuxPerfNormProfiler.java | 8 +--- .../jmh/profile/LinuxPerfProfiler.java | 8 +--- .../jmh/profile/WinPerfAsmProfiler.java | 9 +--- .../org/openjdk/jmh/runner/BaseRunner.java | 4 +- .../jmh/runner/BenchmarkException.java | 17 +++++-- .../openjdk/jmh/runner/BenchmarkHandler.java | 15 ++---- .../java/org/openjdk/jmh/runner/Runner.java | 13 ++--- .../java/org/openjdk/jmh/util/FileUtils.java | 48 +++++-------------- .../generators/asm/ASMGeneratorSource.java | 7 +-- 12 files changed, 53 insertions(+), 124 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index f1b8254f2..11b7f906c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -138,7 +138,7 @@ public void complete(GeneratorSource source, GeneratorDestination destination) { entriesByQName.put(br.getUserClassQName(), br); } } catch (UnsupportedOperationException e) { - destination.printWarning("Unable to read the existing benchmark list, because of UnsupportedOperationException. Run on JDK 7 or higher."); + destination.printError("Unable to read the existing benchmark list.", e); } // Generate new benchmark entries @@ -189,30 +189,24 @@ public void complete(GeneratorSource source, GeneratorDestination destination) { } private Collection readBenchmarkList(GeneratorDestination destination) { - Reader reader = null; - try { - reader = destination.getResource(BenchmarkList.BENCHMARK_LIST.substring(1)); + String list = BenchmarkList.BENCHMARK_LIST.substring(1); + try (Reader reader = destination.getResource(list)) { return FileUtils.readAllLines(reader); } catch (IOException e) { // okay, move on - } finally { - FileUtils.safelyClose(reader); } return Collections.emptyList(); } private void writeBenchmarkList(GeneratorDestination destination, Collection entries) { - PrintWriter writer = null; - try { + String list = BenchmarkList.BENCHMARK_LIST.substring(1); + try (PrintWriter writer = new PrintWriter(destination.newResource(list))) { // Write out the complete benchmark list - writer = new PrintWriter(destination.newResource(BenchmarkList.BENCHMARK_LIST.substring(1))); for (BenchmarkListEntry entry : entries) { writer.println(entry.toLine()); } } catch (IOException ex) { destination.printError("Error writing benchmark list", ex); - } finally { - FileUtils.safelyClose(writer); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 98ecc85d3..ce2e3e428 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -612,10 +612,8 @@ public int compare(Region o1, Region o2) { String target = (saveLogToFile == null) ? saveLogTo + "/" + br.getParams().id() + ".log" : saveLogToFile; - FileOutputStream asm; - try { - asm = new FileOutputStream(target); - PrintWriter pwAsm = new PrintWriter(asm); + try (FileOutputStream asm = new FileOutputStream(target); + PrintWriter pwAsm = new PrintWriter(asm)) { for (ASMLine line : assembly.lines) { for (String event : this.events) { long count = (line.addr != null) ? events.get(event).count(line.addr) : 0; @@ -623,9 +621,6 @@ public int compare(Region o1, Region o2) { } pwAsm.println(line.code); } - pwAsm.flush(); - FileUtils.safelyClose(asm); - pw.println("Perf-annotated Hotspot log is saved to " + target); } catch (IOException e) { pw.println("Unable to save Hotspot log to " + target); @@ -726,16 +721,14 @@ private List figureHotIntervals(SortedSet allAddrs, long from, l } Collection> splitAssembly(File stdOut) { - FileReader in = null; - try { + try (FileReader in = new FileReader(stdOut); + BufferedReader br = new BufferedReader(in)) { Multimap writerToLines = new HashMultimap<>(); Long writerId = -1L; Pattern pWriterThread = Pattern.compile("(.*)(.*)"); String line; - in = new FileReader(stdOut); - BufferedReader br = new BufferedReader(in); while ((line = br.readLine()) != null) { // Parse the writer threads IDs: // @@ -760,8 +753,6 @@ Collection> splitAssembly(File stdOut) { return r; } catch (IOException e) { return Collections.emptyList(); - } finally { - FileUtils.safelyClose(in); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index 4b97c4cb4..1441ecce7 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -77,13 +77,11 @@ public String getDescription() { @Override protected void parseEvents() { - try { + try (FileOutputStream fos = new FileOutputStream(perfParsedData)) { ProcessBuilder pb = new ProcessBuilder("perf", "script", "--fields", "time,event,ip,sym,dso", "--input", perfBinData); Process p = pb.start(); // drain streams, else we might lock up - FileOutputStream fos = new FileOutputStream(perfParsedData); - InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), fos); InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), fos); @@ -94,8 +92,6 @@ protected void parseEvents() { errDrainer.join(); outDrainer.join(); - - FileUtils.safelyClose(fos); } catch (IOException | InterruptedException ex) { throw new IllegalStateException(ex); } @@ -103,13 +99,10 @@ protected void parseEvents() { @Override protected PerfEvents readEvents(double skipSec) { - FileReader fr = null; - try { + try (FileReader fr = new FileReader(perfParsedData); + BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); - fr = new FileReader(perfParsedData); - BufferedReader reader = new BufferedReader(fr); - Multimap methods = new HashMultimap<>(); Map> events = new LinkedHashMap<>(); for (String evName : this.events) { @@ -188,8 +181,6 @@ protected PerfEvents readEvents(double skipSec) { return new PerfEvents(this.events, events, methodMap); } catch (IOException e) { return new PerfEvents(events); - } finally { - FileUtils.safelyClose(fr); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index 60ee25728..811467065 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -197,10 +197,8 @@ public long getDelay(BenchmarkResult br) { private Collection process(BenchmarkResult br, File stdOut, File stdErr) { Multiset events = new HashMultiset<>(); - FileReader fr = null; - try { - fr = new FileReader(stdErr); - BufferedReader reader = new BufferedReader(fr); + try (FileReader fr = new FileReader(stdErr); + BufferedReader reader = new BufferedReader(fr)) { long delayNs = getDelay(br); @@ -314,8 +312,6 @@ private Collection process(BenchmarkResult br, File stdOut, Fi } catch (IOException e) { throw new IllegalStateException(e); - } finally { - FileUtils.safelyClose(fr); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java index 2f5ee02fd..1e3495959 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java @@ -127,10 +127,8 @@ private PerfResult process(File stdOut, File stdErr) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); - FileReader fr = null; - try { - fr = new FileReader(stdErr); - BufferedReader reader = new BufferedReader(fr); + try (FileReader fr = new FileReader(stdErr); + BufferedReader reader = new BufferedReader(fr)) { long cycles = 0; long insns = 0; @@ -181,8 +179,6 @@ private PerfResult process(File stdOut, File stdErr) { ); } catch (IOException e) { throw new IllegalStateException(e); - } finally { - FileUtils.safelyClose(fr); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index 04035e4c1..d50e1815e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -179,13 +179,10 @@ protected void parseEvents() { @Override protected PerfEvents readEvents(double skipSec) { - FileReader fr = null; - try { + try (FileReader fr = new FileReader(perfParsedData); + BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); - fr = new FileReader(perfParsedData); - BufferedReader reader = new BufferedReader(fr); - Multimap methods = new HashMultimap<>(); Map> events = new LinkedHashMap<>(); for (String evName : this.events) { @@ -259,8 +256,6 @@ protected PerfEvents readEvents(double skipSec) { return new PerfEvents(this.events, events, methodMap); } catch (IOException e) { return new PerfEvents(events); - } finally { - FileUtils.safelyClose(fr); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java index e9c0f8a2f..8339df089 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java @@ -149,7 +149,9 @@ private void doSingle(BenchmarkParams params, ActionMode mode, IterationResultAc } catch (BenchmarkException be) { out.println(""); out.println(""); - out.println(Utils.throwableToString(be.getCause())); + for (Throwable cause : be.getSuppressed()) { + out.println(Utils.throwableToString(cause)); + } out.println(""); if (options.shouldFailOnError().orElse(Defaults.FAIL_ON_ERROR)) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java index 35ae0b8c7..da95de41c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java @@ -24,6 +24,9 @@ */ package org.openjdk.jmh.runner; +import java.util.Collection; +import java.util.Collections; + /** * Internal exception in JMH. Always wraps the real cause. */ @@ -31,10 +34,18 @@ public class BenchmarkException extends RuntimeException { private static final long serialVersionUID = 4064666042830679837L; public BenchmarkException(Throwable ex) { - super(ex); + this("Benchmark error", Collections.singleton(ex)); + } + + public BenchmarkException(String msg, Collection errors) { + super(msg); + for (Throwable err : errors) { + addSuppressed(err); + } } - public BenchmarkException(String msg, Throwable ex) { - super(msg, ex); + @Override + public Throwable getCause() { + throw new UnsupportedOperationException("BenchmarkException only has suppressed causes"); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index dbcffa34d..0ac7c32ad 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -207,15 +207,12 @@ ExecutorService createExecutor(int maxThreads, String prefix) { }, /** - * Use new ForkJoinPool (JDK 7+) + * Use ForkJoinPool. */ FJP { @Override ExecutorService createExecutor(int maxThreads, String prefix) throws Exception { - // (Aleksey): - // requires some of the reflection magic to untie from JDK 7 compile-time dependencies - Constructor c = Class.forName("java.util.concurrent.ForkJoinPool").getConstructor(int.class); - return (ExecutorService) c.newInstance(maxThreads); + return new ForkJoinPool(maxThreads); } }, @@ -428,13 +425,7 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa stopProfilers(benchmarkParams, params, result); if (!errors.isEmpty()) { - Throwable first = errors.get(0); - if (errors.size() > 1) { - // TODO: Once we switch to JDK 7, make use of #addSupressed. - throw new BenchmarkException(errors.size() + " pending exceptions, reporting the first", first); - } else { - throw new BenchmarkException(first); - } + throw new BenchmarkException("Benchmark error during the run", errors); } return result; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index b9a17dde2..d14528016 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -556,7 +556,7 @@ private Collection runBenchmarks(SortedSet benchm out.endRun(runResults); return runResults; } catch (BenchmarkException be) { - throw new RunnerException("Benchmark caught the exception", be.getCause()); + throw new RunnerException("Benchmark caught the exception", be); } } @@ -706,15 +706,11 @@ private Multimap runSeparate(ActionPlan action private List doFork(BinaryLinkServer reader, List commandString, File stdOut, File stdErr, boolean printOut, boolean printErr) { - FileOutputStream fosErr = null; - FileOutputStream fosOut = null; - try { + try (FileOutputStream fosErr = new FileOutputStream(stdErr); + FileOutputStream fosOut = new FileOutputStream(stdOut)) { ProcessBuilder pb = new ProcessBuilder(commandString); Process p = pb.start(); - fosErr = new FileOutputStream(stdErr); - fosOut = new FileOutputStream(stdOut); - // drain streams, else we might lock up InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), fosErr); InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), fosOut); @@ -774,9 +770,6 @@ private List doFork(BinaryLinkServer reader, List comma out.println(""); out.println(""); throw new BenchmarkException(ex); - } finally { - FileUtils.safelyClose(fosErr); - FileUtils.safelyClose(fosOut); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java index 6eb85b9c3..b81c168a9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java @@ -53,12 +53,9 @@ public static File tempFile(String suffix) throws IOException { * @throws IOException if things go crazy */ public static File extractFromResource(String name) throws IOException { - InputStream fis = null; - OutputStream fos = null; - try { - File temp = FileUtils.tempFile("extracted"); - fis = FileUtils.class.getResourceAsStream(name); - fos = new FileOutputStream(temp); + File temp = FileUtils.tempFile("extracted"); + try (InputStream fis = FileUtils.class.getResourceAsStream(name); + OutputStream fos = new FileOutputStream(temp)) { byte[] buf = new byte[8192]; int read; @@ -69,9 +66,6 @@ public static File extractFromResource(String name) throws IOException { fos.close(); return temp; - } finally { - FileUtils.safelyClose(fis); - FileUtils.safelyClose(fos); } } @@ -96,10 +90,9 @@ public static String createTempFileWithLines(String suffix, Iterable lin } public static Collection tail(File file, int num) throws IOException { - FileInputStream fis = null; - try { - fis = new FileInputStream(file); - BufferedReader reader = new BufferedReader(new InputStreamReader(fis)); + try (FileInputStream fis = new FileInputStream(file); + InputStreamReader is = new InputStreamReader(fis); + BufferedReader reader = new BufferedReader(is)) { LinkedList lines = new LinkedList<>(); String line; while ((line = reader.readLine()) != null) { @@ -109,8 +102,6 @@ public static Collection tail(File file, int num) throws IOException { } } return lines; - } finally { - FileUtils.safelyClose(fis); } } @@ -125,35 +116,25 @@ public static Collection readAllLines(Reader src) throws IOException { } public static Collection readAllLines(File file) throws IOException { - FileReader fr = null; - try { - fr = new FileReader(file); + try (FileReader fr = new FileReader(file)) { return readAllLines(fr); - } finally { - FileUtils.safelyClose(fr); } } public static Collection readAllLines(InputStream stream) throws IOException { - InputStreamReader reader = new InputStreamReader(stream); - try { + try (InputStreamReader reader = new InputStreamReader(stream)) { return readAllLines(reader); } finally { - FileUtils.safelyClose(reader); FileUtils.safelyClose(stream); } } public static void writeLines(File file, Collection lines) throws IOException { - PrintWriter pw = null; - try { - pw = new PrintWriter(file); + try (PrintWriter pw = new PrintWriter(file)) { for (String line : lines) { pw.println(line); } pw.close(); - } finally { - FileUtils.safelyClose(pw); } } @@ -197,12 +178,8 @@ public static Collection getClasses(File root) { } public static void copy(String src, String dst) throws IOException { - FileInputStream fis = null; - FileOutputStream fos = null; - try { - fis = new FileInputStream(src); - fos = new FileOutputStream(dst); - + try (FileInputStream fis = new FileInputStream(src); + FileOutputStream fos = new FileOutputStream(dst)) { byte[] buf = new byte[8192]; int read; while ((read = fis.read(buf)) != -1) { @@ -210,9 +187,6 @@ public static void copy(String src, String dst) throws IOException { } fos.close(); - } finally { - FileUtils.safelyClose(fis); - FileUtils.safelyClose(fos); } } diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMGeneratorSource.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMGeneratorSource.java index 389058013..3084940b7 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMGeneratorSource.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMGeneratorSource.java @@ -27,7 +27,6 @@ import org.objectweb.asm.ClassReader; import org.openjdk.jmh.generators.core.ClassInfo; import org.openjdk.jmh.generators.core.GeneratorSource; -import org.openjdk.jmh.util.FileUtils; import java.io.File; import java.io.FileInputStream; @@ -50,12 +49,8 @@ public void processClasses(Collection classFiles) throws IOException { } public void processClass(File classFile) throws IOException { - FileInputStream fis = null; - try { - fis = new FileInputStream(classFile); + try (FileInputStream fis = new FileInputStream(classFile)){ processClass(fis); - } finally { - FileUtils.safelyClose(fis); } } From 4caad3558e02020338b389054b9cd15c3178d137 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Nov 2016 21:10:51 +0100 Subject: [PATCH 055/342] Fix code inspection problems: redundant modifiers, final fields, etc --- .../java/org/openjdk/jmh/validation/Main.java | 4 +-- .../validation/tests/ThermalRundownTest.java | 2 +- .../java/org/openjdk/jmh/ct/CompileTest.java | 5 --- .../jmh/ct/InMemoryGeneratorDestination.java | 10 +++--- .../jmh/it/StackTraceInThrowableTest.java | 5 --- .../openjdk/jmh/it/annsteal/CustomTest.java | 2 -- .../jmh/it/asymm/ExactThreadCountTest.java | 4 +-- .../jmh/it/asymm/Zero1ThreadCountTest.java | 4 +-- .../jmh/it/asymm/Zero2ThreadCountTest.java | 4 +-- .../jmh/it/bulkwarmup/NonForkedModesTest.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode0_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode1_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode2_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode3_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode4_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode5_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode6_Test.java | 2 +- .../openjdk/jmh/it/parameters/Parameters.java | 4 ++- .../EnumBenchParamImplicitSequenceTest.java | 8 ++--- .../jmh/it/params/EnumParamSequenceTest.java | 8 ++--- .../EnumStateParamImplicitSequenceTest.java | 8 ++--- .../nested/NestedSubclassDependencyTest.java | 1 - .../nested/NestedTearDownDependencyTest.java | 1 - .../it/sharing/BenchmarkBenchSharingTest.java | 2 +- .../it/sharing/BenchmarkStateSharingTest.java | 2 +- .../jmh/it/sharing/GroupBenchSharingTest.java | 2 +- .../sharing/GroupDefaultBenchSharingTest.java | 2 +- .../sharing/GroupDefaultStateSharingTest.java | 2 +- .../jmh/it/sharing/GroupStateSharingTest.java | 2 +- .../it/sharing/ThreadBenchSharingTest.java | 2 +- .../it/sharing/ThreadStateSharingTest.java | 2 +- .../threads/BenchmarkBenchSameThreadTest.java | 14 ++++---- .../threads/BenchmarkStateSameThreadTest.java | 14 ++++---- .../it/threads/GroupBenchSameThreadTest.java | 14 ++++---- .../it/threads/GroupStateSameThreadTest.java | 14 ++++---- .../it/threads/GroupThreadGroupOrderTest.java | 6 ++-- .../jmh/it/threads/MaxThreadCountTest.java | 2 +- .../jmh/it/threads/OneThreadCountTest.java | 2 +- .../jmh/it/threads/TwoThreadCountTest.java | 2 +- .../jmh/annotations/CompilerControl.java | 2 +- .../org/openjdk/jmh/annotations/Fork.java | 4 +-- .../openjdk/jmh/annotations/Measurement.java | 6 ++-- .../org/openjdk/jmh/annotations/Param.java | 2 +- .../org/openjdk/jmh/annotations/Threads.java | 2 +- .../org/openjdk/jmh/annotations/Warmup.java | 6 ++-- .../openjdk/jmh/infra/BenchmarkParams.java | 2 -- .../jmh/profile/LinuxPerfProfiler.java | 1 - .../openjdk/jmh/profile/PausesProfiler.java | 2 +- .../openjdk/jmh/profile/ProfilerFactory.java | 33 +++++++------------ .../jmh/profile/ProfilerOptionFormatter.java | 2 +- .../jmh/results/AggregationPolicy.java | 2 +- .../openjdk/jmh/runner/BenchmarkHandler.java | 6 ++-- .../org/openjdk/jmh/runner/BenchmarkList.java | 2 +- .../openjdk/jmh/runner/WorkloadParams.java | 4 +-- .../jmh/runner/format/OutputFormat.java | 12 +++---- .../openjdk/jmh/runner/link/OutputFrame.java | 2 +- .../jmh/runner/options/OptionsBuilder.java | 6 ++-- .../main/java/org/openjdk/jmh/util/Utils.java | 2 -- .../jmh/util/lines/TestLineWriter.java | 2 +- .../org/openjdk/jmh/runner/RunnerTest.java | 8 ++--- .../openjdk/jmh/runner/TestBenchmarkList.java | 26 +++++++-------- .../jmh/runner/options/TestParentOptions.java | 7 ++-- .../org/openjdk/jmh/util/TestClassUtils.java | 5 +-- .../jmh/generators/BenchmarkProcessor.java | 1 - .../annotations/APGeneratorDestinaton.java | 2 -- 65 files changed, 146 insertions(+), 173 deletions(-) diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java index d7821bb56..8f09058d7 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java @@ -216,7 +216,7 @@ public static void main(String[] args) throws RunnerException, CommandLineOption } } - public static enum Test { + public enum Test { timing, compiler_hints, thermal, @@ -229,7 +229,7 @@ public static enum Test { blackhole_consec, } - public static enum Mode { + public enum Mode { flash, quick, normal, diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java index bee7fe6c0..1f2b5f6d4 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java @@ -39,7 +39,7 @@ public class ThermalRundownTest implements ValidationTest { - private int iterations; + private final int iterations; public ThermalRundownTest(int iterations) { this.iterations = iterations; diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java index 55d3accdf..b304f6337 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java @@ -111,11 +111,6 @@ public static boolean doTestOther(GeneratorSource source, InMemoryGeneratorDesti gen.complete(source, destination); if (destination.hasErrors()) { - StringBuilder sb = new StringBuilder(); - sb.append("Failed with:\n"); - for (String e : destination.getErrors()) { - sb.append(e).append("\n"); - } return false; } diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java index 247fbde3d..c5d403272 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java @@ -40,12 +40,12 @@ public class InMemoryGeneratorDestination implements GeneratorDestination { - private List errors = new ArrayList<>(); - private List warnings = new ArrayList<>(); - private List infos = new ArrayList<>(); + private final List errors = new ArrayList<>(); + private final List warnings = new ArrayList<>(); + private final List infos = new ArrayList<>(); - private Map classBodies = new HashMap<>(); - private Map resourceBodies = new HashMap<>(); + private final Map classBodies = new HashMap<>(); + private final Map resourceBodies = new HashMap<>(); @Override public Writer newResource(String resourcePath) throws IOException { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/StackTraceInThrowableTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/StackTraceInThrowableTest.java index 015bb4f9f..a59bf01ec 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/StackTraceInThrowableTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/StackTraceInThrowableTest.java @@ -24,18 +24,14 @@ */ package org.openjdk.jmh.it; -import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; -import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; @@ -43,7 +39,6 @@ import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; @State(Scope.Thread) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java index 453ce241f..9b310bced 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/annsteal/CustomTest.java @@ -28,9 +28,7 @@ import org.junit.Assert; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.util.FileUtils; -import org.openjdk.jmh.util.Utils; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Collection; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/ExactThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/ExactThreadCountTest.java index ccd337c83..3695d1071 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/ExactThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/ExactThreadCountTest.java @@ -57,8 +57,8 @@ @Fork(1) public class ExactThreadCountTest { - private Set test1threads = Collections.synchronizedSet(new HashSet()); - private Set test2threads = Collections.synchronizedSet(new HashSet()); + private final Set test1threads = Collections.synchronizedSet(new HashSet()); + private final Set test2threads = Collections.synchronizedSet(new HashSet()); @Setup(Level.Iteration) public void setup() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java index d81de9928..8e5c28492 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java @@ -55,8 +55,8 @@ @Fork(1) public class Zero1ThreadCountTest { - private Set test1threads = Collections.synchronizedSet(new HashSet()); - private Set test2threads = Collections.synchronizedSet(new HashSet()); + private final Set test1threads = Collections.synchronizedSet(new HashSet()); + private final Set test2threads = Collections.synchronizedSet(new HashSet()); @TearDown public void check() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java index 3c99f73ff..c487c3f86 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java @@ -55,8 +55,8 @@ @Fork(1) public class Zero2ThreadCountTest { - private Set test1threads = Collections.synchronizedSet(new HashSet()); - private Set test2threads = Collections.synchronizedSet(new HashSet()); + private final Set test1threads = Collections.synchronizedSet(new HashSet()); + private final Set test2threads = Collections.synchronizedSet(new HashSet()); @TearDown public void check() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java index af46051ec..8203d5cd3 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java @@ -48,7 +48,7 @@ @State(Scope.Thread) public class NonForkedModesTest { - private static Queue testSequence = new ConcurrentLinkedQueue<>(); + private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java index 615020277..3397a7ecb 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode0_Test { - private static Queue testSequence = new ConcurrentLinkedQueue<>(); + private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java index c5e070a55..49fd73ed5 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode1_Test { - private static Queue testSequence = new ConcurrentLinkedQueue<>(); + private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java index 991330497..c90d8aca6 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode2_Test { - private static Queue testSequence = new ConcurrentLinkedQueue<>(); + private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java index 4929c2139..615d62833 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode3_Test { - private static Queue testSequence = new ConcurrentLinkedQueue<>(); + private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java index 9b0018a49..5d4ed378f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java @@ -54,7 +54,7 @@ @State(Scope.Thread) public class WarmupMode4_Test { - private static Queue testSequence = new ConcurrentLinkedQueue<>(); + private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java index 8fa092043..b69b9963a 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java @@ -55,7 +55,7 @@ @State(Scope.Thread) public class WarmupMode5_Test { - private static Queue testSequence = new ConcurrentLinkedQueue<>(); + private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java index ff9741806..62752f7e2 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java @@ -55,7 +55,7 @@ @State(Scope.Thread) public class WarmupMode6_Test { - private static Queue testSequence = new ConcurrentLinkedQueue<>(); + private static final Queue testSequence = new ConcurrentLinkedQueue<>(); boolean recorded; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/Parameters.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/Parameters.java index ac7eb4322..f3e00deaf 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/Parameters.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/Parameters.java @@ -38,7 +38,9 @@ public class Parameters { public static BenchmarkListEntry get(Class klass) { BenchmarkList list = BenchmarkList.fromFile("target/test-classes" + BenchmarkList.BENCHMARK_LIST); - Set set = list.find(OutputFormatFactory.createFormatInstance(System.out, VerboseMode.EXTRA), Arrays.asList(klass.getName().replaceAll("\\$",".")), Collections.emptyList()); + Set set = list.find(OutputFormatFactory.createFormatInstance(System.out, VerboseMode.EXTRA), + Collections.singletonList(klass.getName().replaceAll("\\$", ".")), + Collections.emptyList()); Assert.assertEquals("The single benchmark exists", 1, set.size()); return set.iterator().next(); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java index 42de624b6..73c6fde6f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java @@ -90,11 +90,11 @@ public void constrainedB() throws RunnerException { Assert.assertEquals(1*3, new Runner(opts).run().size()); } - public static enum SampleEnumA { - VALUE_A, VALUE_B, VALUE_C; + public enum SampleEnumA { + VALUE_A, VALUE_B, VALUE_C } - public static enum SampleEnumB { - VALUE_A, VALUE_B, VALUE_C; + public enum SampleEnumB { + VALUE_A, VALUE_B, VALUE_C } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java index 8d2cb7c55..4cde66ba1 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java @@ -90,11 +90,11 @@ public void constrainedB() throws RunnerException { Assert.assertEquals(1*3, new Runner(opts).run().size()); } - public static enum SampleEnumA { - VALUE_A, VALUE_B, VALUE_C; + public enum SampleEnumA { + VALUE_A, VALUE_B, VALUE_C } - public static enum SampleEnumB { - VALUE_A, VALUE_B, VALUE_C; + public enum SampleEnumB { + VALUE_A, VALUE_B, VALUE_C } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java index 208e7452b..81adc3625 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java @@ -92,11 +92,11 @@ public void constrainedB() throws RunnerException { Assert.assertEquals(1*3, new Runner(opts).run().size()); } - public static enum SampleEnumA { - VALUE_A, VALUE_B, VALUE_C; + public enum SampleEnumA { + VALUE_A, VALUE_B, VALUE_C } - public static enum SampleEnumB { - VALUE_A, VALUE_B, VALUE_C; + public enum SampleEnumB { + VALUE_A, VALUE_B, VALUE_C } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedSubclassDependencyTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedSubclassDependencyTest.java index e5558da37..17064a6de 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedSubclassDependencyTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedSubclassDependencyTest.java @@ -30,7 +30,6 @@ import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedTearDownDependencyTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedTearDownDependencyTest.java index 2cf5b732e..416c9647d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedTearDownDependencyTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedTearDownDependencyTest.java @@ -30,7 +30,6 @@ import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkBenchSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkBenchSharingTest.java index 0329ef9b3..c6f853b36 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkBenchSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkBenchSharingTest.java @@ -51,7 +51,7 @@ @State(Scope.Benchmark) public class BenchmarkBenchSharingTest { - Set visitors = Collections.synchronizedSet(new HashSet()); + final Set visitors = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Trial) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkStateSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkStateSharingTest.java index b40f1ce92..e4347f9bf 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkStateSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkStateSharingTest.java @@ -52,7 +52,7 @@ public class BenchmarkStateSharingTest { @State(Scope.Benchmark) public static class MyState { - Set visitors = Collections.synchronizedSet(new HashSet()); + final Set visitors = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Trial) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupBenchSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupBenchSharingTest.java index effed6b1e..a474a64db 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupBenchSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupBenchSharingTest.java @@ -52,7 +52,7 @@ @State(Scope.Group) public class GroupBenchSharingTest { - Set visitors = Collections.synchronizedSet(new HashSet()); + final Set visitors = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Trial) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java index 938bbc15e..ef88b7ec8 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java @@ -52,7 +52,7 @@ @State(Scope.Group) public class GroupDefaultBenchSharingTest { - Set visitors = Collections.synchronizedSet(new HashSet()); + final Set visitors = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Trial) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java index 9ad35060e..94851b18b 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java @@ -53,7 +53,7 @@ public class GroupDefaultStateSharingTest { @State(Scope.Group) public static class MyState { - Set visitors = Collections.synchronizedSet(new HashSet()); + final Set visitors = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Trial) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupStateSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupStateSharingTest.java index 5222f8961..b4cbc8ceb 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupStateSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupStateSharingTest.java @@ -53,7 +53,7 @@ public class GroupStateSharingTest { @State(Scope.Group) public static class MyState { - Set visitors = Collections.synchronizedSet(new HashSet()); + final Set visitors = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Trial) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadBenchSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadBenchSharingTest.java index bda93c49d..a911604b0 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadBenchSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadBenchSharingTest.java @@ -51,7 +51,7 @@ @State(Scope.Thread) public class ThreadBenchSharingTest { - Set visitors = Collections.synchronizedSet(new HashSet()); + final Set visitors = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Trial) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadStateSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadStateSharingTest.java index 1d52d7ffc..6dadf40d6 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadStateSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadStateSharingTest.java @@ -52,7 +52,7 @@ public class ThreadStateSharingTest { @State(Scope.Thread) public static class MyState { - Set visitors = Collections.synchronizedSet(new HashSet()); + final Set visitors = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Trial) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkBenchSameThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkBenchSameThreadTest.java index 6e5654372..95699d41d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkBenchSameThreadTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkBenchSameThreadTest.java @@ -55,13 +55,13 @@ @State(Scope.Benchmark) public class BenchmarkBenchSameThreadTest { - private Set setupRunThread = Collections.synchronizedSet(new HashSet()); - private Set setupIterationThread = Collections.synchronizedSet(new HashSet()); - private Set setupInvocationThread = Collections.synchronizedSet(new HashSet()); - private Set teardownRunThread = Collections.synchronizedSet(new HashSet()); - private Set teardownIterationThread = Collections.synchronizedSet(new HashSet()); - private Set teardownInvocationThread = Collections.synchronizedSet(new HashSet()); - private Set testInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set setupRunThread = Collections.synchronizedSet(new HashSet()); + private final Set setupIterationThread = Collections.synchronizedSet(new HashSet()); + private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownRunThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set testInvocationThread = Collections.synchronizedSet(new HashSet()); @Setup(Level.Trial) public void setupRun() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkStateSameThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkStateSameThreadTest.java index 3efc14846..a870b685c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkStateSameThreadTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/BenchmarkStateSameThreadTest.java @@ -57,13 +57,13 @@ public class BenchmarkStateSameThreadTest { @State(Scope.Benchmark) public static class MyState { - private Set setupRunThread = Collections.synchronizedSet(new HashSet()); - private Set setupIterationThread = Collections.synchronizedSet(new HashSet()); - private Set setupInvocationThread = Collections.synchronizedSet(new HashSet()); - private Set teardownRunThread = Collections.synchronizedSet(new HashSet()); - private Set teardownIterationThread = Collections.synchronizedSet(new HashSet()); - private Set teardownInvocationThread = Collections.synchronizedSet(new HashSet()); - private Set testInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set setupRunThread = Collections.synchronizedSet(new HashSet()); + private final Set setupIterationThread = Collections.synchronizedSet(new HashSet()); + private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownRunThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set testInvocationThread = Collections.synchronizedSet(new HashSet()); @Setup(Level.Trial) public void setupRun() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupBenchSameThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupBenchSameThreadTest.java index 0b050c416..a7d43a424 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupBenchSameThreadTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupBenchSameThreadTest.java @@ -56,13 +56,13 @@ @State(Scope.Group) public class GroupBenchSameThreadTest { - private Set setupRunThread = Collections.synchronizedSet(new HashSet()); - private Set setupIterationThread = Collections.synchronizedSet(new HashSet()); - private Set setupInvocationThread = Collections.synchronizedSet(new HashSet()); - private Set teardownRunThread = Collections.synchronizedSet(new HashSet()); - private Set teardownIterationThread = Collections.synchronizedSet(new HashSet()); - private Set teardownInvocationThread = Collections.synchronizedSet(new HashSet()); - private Set testInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set setupRunThread = Collections.synchronizedSet(new HashSet()); + private final Set setupIterationThread = Collections.synchronizedSet(new HashSet()); + private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownRunThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set testInvocationThread = Collections.synchronizedSet(new HashSet()); @Setup(Level.Trial) public void setupRun() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupStateSameThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupStateSameThreadTest.java index b45fb8cdb..a66436192 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupStateSameThreadTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupStateSameThreadTest.java @@ -58,13 +58,13 @@ public class GroupStateSameThreadTest { @State(Scope.Group) public static class MyState { - private Set setupRunThread = Collections.synchronizedSet(new HashSet()); - private Set setupIterationThread = Collections.synchronizedSet(new HashSet()); - private Set setupInvocationThread = Collections.synchronizedSet(new HashSet()); - private Set teardownRunThread = Collections.synchronizedSet(new HashSet()); - private Set teardownIterationThread = Collections.synchronizedSet(new HashSet()); - private Set teardownInvocationThread = Collections.synchronizedSet(new HashSet()); - private Set testInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set setupRunThread = Collections.synchronizedSet(new HashSet()); + private final Set setupIterationThread = Collections.synchronizedSet(new HashSet()); + private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownRunThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet()); + private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet()); + private final Set testInvocationThread = Collections.synchronizedSet(new HashSet()); @Setup(Level.Trial) public void setupRun() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupThreadGroupOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupThreadGroupOrderTest.java index 9e96c2ede..d0acdad7f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupThreadGroupOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/GroupThreadGroupOrderTest.java @@ -48,9 +48,9 @@ @State(Scope.Group) public class GroupThreadGroupOrderTest { - private Set abc = Collections.synchronizedSet(new HashSet()); - private Set def = Collections.synchronizedSet(new HashSet()); - private Set ghi = Collections.synchronizedSet(new HashSet()); + private final Set abc = Collections.synchronizedSet(new HashSet()); + private final Set def = Collections.synchronizedSet(new HashSet()); + private final Set ghi = Collections.synchronizedSet(new HashSet()); @Setup(Level.Iteration) public void prepare() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java index bb6e8118c..96a10475f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java @@ -52,7 +52,7 @@ @State(Scope.Benchmark) public class MaxThreadCountTest { - private Set threads = Collections.synchronizedSet(new HashSet()); + private final Set threads = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Iteration) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java index c8db38925..0761238a7 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java @@ -52,7 +52,7 @@ @State(Scope.Benchmark) public class OneThreadCountTest { - private Set threads = Collections.synchronizedSet(new HashSet()); + private final Set threads = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Iteration) public void tearDown() { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java index fa0c584de..59b2c7425 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java @@ -52,7 +52,7 @@ @State(Scope.Benchmark) public class TwoThreadCountTest { - private Set threads = Collections.synchronizedSet(new HashSet()); + private final Set threads = Collections.synchronizedSet(new HashSet()); @TearDown(Level.Iteration) public void tearDown() { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/CompilerControl.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/CompilerControl.java index 863daa7fa..290bc503d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/CompilerControl.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/CompilerControl.java @@ -58,7 +58,7 @@ /** * Compilation mode. */ - public enum Mode { + enum Mode { /** * Insert the breakpoint into the generated compiled code. diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Fork.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Fork.java index 1bba25baa..be65d6209 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Fork.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Fork.java @@ -43,9 +43,9 @@ @Retention(RetentionPolicy.RUNTIME) public @interface Fork { - static final int BLANK_FORKS = -1; + int BLANK_FORKS = -1; - static final String BLANK_ARGS = "blank_blank_blank_2014"; + String BLANK_ARGS = "blank_blank_blank_2014"; /** @return number of times harness should fork, zero means "no fork" */ int value() default BLANK_FORKS; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Measurement.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Measurement.java index 9e37ef7fa..5618c0066 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Measurement.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Measurement.java @@ -47,9 +47,9 @@ @Retention(RetentionPolicy.RUNTIME) public @interface Measurement { - static final int BLANK_ITERATIONS = -1; - static final int BLANK_TIME = -1; - static final int BLANK_BATCHSIZE = -1; + int BLANK_ITERATIONS = -1; + int BLANK_TIME = -1; + int BLANK_BATCHSIZE = -1; /** @return Number of measurement iterations */ int iterations() default BLANK_ITERATIONS; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java index 862b73d90..121b5b7c0 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java @@ -56,7 +56,7 @@ @Retention(RetentionPolicy.RUNTIME) public @interface Param { - static final String BLANK_ARGS = "blank_blank_blank_2014"; + String BLANK_ARGS = "blank_blank_blank_2014"; /** * Default values sequence for the parameter. By default, the parameter diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Threads.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Threads.java index c954a0029..fea1f493c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Threads.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Threads.java @@ -47,7 +47,7 @@ * The magic value for MAX threads. * This means Runtime.getRuntime().availableProcessors() threads. */ - public static int MAX = -1; + int MAX = -1; /** * @return Number of threads; use Threads.MAX to run with all available threads. diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Warmup.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Warmup.java index 2d08c001e..744d8d631 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Warmup.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Warmup.java @@ -45,9 +45,9 @@ @Inherited public @interface Warmup { - static final int BLANK_ITERATIONS = -1; - static final int BLANK_TIME = -1; - static final int BLANK_BATCHSIZE = -1; + int BLANK_ITERATIONS = -1; + int BLANK_TIME = -1; + int BLANK_BATCHSIZE = -1; /** @return Number of warmup iterations */ int iterations() default BLANK_ITERATIONS; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java index 6878a249f..d9df4a176 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java @@ -25,8 +25,6 @@ package org.openjdk.jmh.infra; import org.openjdk.jmh.annotations.Mode; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.WorkloadParams; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Utils; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java index 1e3495959..ed786489a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java @@ -30,7 +30,6 @@ import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.*; -import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.ScoreFormatter; import org.openjdk.jmh.util.Utils; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java index 70fbbfca6..cfffb9a4a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java @@ -150,7 +150,7 @@ public void run() { } static class PausesProfilerResult extends Result { - private SampleBuffer buffer; + private final SampleBuffer buffer; public PausesProfilerResult(SampleBuffer buffer) { super(ResultRole.SECONDARY, Defaults.PREFIX + "pauses", buffer.getStatistics(1D / 1000000), "ms", AggregationPolicy.SUM); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java index a9ba7becc..51e6920d5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java @@ -79,14 +79,19 @@ private static Profiler getProfiler(ProfilerConfig cfg) throws Exception { } private static Profiler instantiate(ProfilerConfig cfg, Class p) throws InstantiationException, IllegalAccessException, InvocationTargetException { - Profiler prof; try { - Constructor constructor = p.getConstructor(String.class); - prof = constructor.newInstance(cfg.getOpts()); + return p.getConstructor(String.class).newInstance(cfg.getOpts()); } catch (NoSuchMethodException e) { - prof = p.newInstance(); + // fallthrough } - return prof; + + try { + return p.getConstructor().newInstance(); + } catch (NoSuchMethodException e) { + // fallthrough + } + + throw new IllegalStateException("Cannot instantiate profiler"); } public static List getSupportedExternal(Collection cfg) { @@ -127,14 +132,7 @@ public static void listProfilers(PrintStream out) { for (String s : BUILT_IN.keySet()) { try { Profiler prof = getProfilerOrException(new ProfilerConfig(s, "")); - String descr = (prof != null) ? prof.getDescription() : "(unable to instantiate the profiler)"; - - if (prof != null) { - supported.append(String.format("%" + maxLen + "s: %s %s\n", s, descr, "")); - } else { - unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s, descr, "")); - unsupported.append("\n"); - } + supported.append(String.format("%" + maxLen + "s: %s %s\n", s, prof.getDescription(), "")); } catch (ProfilerException e) { unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s, "", "")); unsupported.append(e.getMessage()); @@ -145,14 +143,7 @@ public static void listProfilers(PrintStream out) { for (Class s : ProfilerFactory.getDiscoveredProfilers()) { try { Profiler prof = getProfilerOrException(new ProfilerConfig(s.getCanonicalName(), "")); - String descr = (prof != null) ? prof.getDescription() : "(unable to instantiate the profiler)"; - - if (prof != null) { - supported.append(String.format("%" + maxLen + "s: %s %s\n", s.getCanonicalName(), descr, "(discovered)")); - } else { - unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s.getCanonicalName(), descr, "(discovered)")); - unsupported.append("\n"); - } + supported.append(String.format("%" + maxLen + "s: %s %s\n", s.getCanonicalName(), prof.getDescription(), "(discovered)")); } catch (ProfilerException e) { unsupported.append(String.format("%" + maxLen + "s: %s %s\n", s, s.getCanonicalName(), "")); unsupported.append(e.getMessage()); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerOptionFormatter.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerOptionFormatter.java index 1cdbaa7df..d6f90cd22 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerOptionFormatter.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerOptionFormatter.java @@ -46,7 +46,7 @@ public String format(Map options) { sb.append("Usage: -prof :opt1=value1,value2;opt2=value3"); sb.append(LINE_SEPARATOR); sb.append(LINE_SEPARATOR); - sb.append("Options accepted by " + name + ":"); + sb.append("Options accepted by ").append(name).append(":"); for (OptionDescriptor each : options.values()) { sb.append(lineFor(each)); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/AggregationPolicy.java b/jmh-core/src/main/java/org/openjdk/jmh/results/AggregationPolicy.java index 53ee3c0b9..742b44355 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/AggregationPolicy.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/AggregationPolicy.java @@ -36,7 +36,7 @@ public enum AggregationPolicy { ; - private String label; + private final String label; AggregationPolicy(String label) { this.label = label; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index 0ac7c32ad..4280d4a2d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -37,7 +37,7 @@ import org.openjdk.jmh.util.ClassUtils; import org.openjdk.jmh.util.Utils; -import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.*; @@ -79,13 +79,13 @@ public BenchmarkHandler(OutputFormat out, Options options, BenchmarkParams execu @Override protected ThreadData initialValue() { try { - Object o = clazz.newInstance(); + Object o = clazz.getConstructor().newInstance(); ThreadParams t = tps.poll(); if (t == null) { throw new IllegalStateException("Cannot get another thread params"); } return new ThreadData(o, t); - } catch (InstantiationException | IllegalAccessException e) { + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new RuntimeException("Class " + clazz.getName() + " instantiation error ", e); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java index 1edf699bd..0fbff80ae 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java @@ -68,7 +68,7 @@ private BenchmarkList(String file, String resource, String strings) { * @return A list of all benchmarks, excluding matched */ public Set getAll(OutputFormat out, List excludes) { - return find(out, Arrays.asList(".*"), excludes); + return find(out, Collections.singletonList(".*"), excludes); } /** diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java index 19f11df42..72bff253f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java @@ -113,8 +113,8 @@ public Collection keys() { private static class Value implements Comparable, Serializable { private static final long serialVersionUID = 8846779314306880977L; - private String value; - private int order; + private final String value; + private final int order; public Value(String value, int order) { this.value = value; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/OutputFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/OutputFormat.java index a887a2498..f0ee534f8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/OutputFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/OutputFormat.java @@ -45,7 +45,7 @@ public interface OutputFormat { * @param params iteration params in use * @param iteration iteration-number */ - public void iteration(BenchmarkParams benchParams, IterationParams params, int iteration); + void iteration(BenchmarkParams benchParams, IterationParams params, int iteration); /** * Format for end-of-iteration. @@ -55,31 +55,31 @@ public interface OutputFormat { * @param iteration iteration-number * @param data result of iteration */ - public void iterationResult(BenchmarkParams benchParams, IterationParams params, int iteration, IterationResult data); + void iterationResult(BenchmarkParams benchParams, IterationParams params, int iteration, IterationResult data); /** * Format for start-of-benchmark output. * @param benchParams benchmark params */ - public void startBenchmark(BenchmarkParams benchParams); + void startBenchmark(BenchmarkParams benchParams); /** * Format for end-of-benchmark. * * @param result statistics of the run */ - public void endBenchmark(BenchmarkResult result); + void endBenchmark(BenchmarkResult result); /** * Format for start-of-benchmark output. */ - public void startRun(); + void startRun(); /** * Format for end-of-benchmark. * @param result benchmark results */ - public void endRun(Collection result); + void endRun(Collection result); /* ------------- RAW OUTPUT METHODS ------------------- */ diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/OutputFrame.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/OutputFrame.java index aa7df17b9..bef64d447 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/OutputFrame.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/OutputFrame.java @@ -45,7 +45,7 @@ public Type getType() { return type; } - public static enum Type { + public enum Type { OUT, ERR, } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java index 3e1b2a85e..470e371a5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java @@ -192,7 +192,7 @@ public Optional shouldDoGC() { // --------------------------------------------------------------------------- - private List profilers = new ArrayList<>(); + private final List profilers = new ArrayList<>(); @Override public ChainedOptionsBuilder addProfiler(Class prof) { @@ -490,7 +490,7 @@ public Optional getMeasurementBatchSize() { // --------------------------------------------------------------------------- - private EnumSet benchModes = EnumSet.noneOf(Mode.class); + private final EnumSet benchModes = EnumSet.noneOf(Mode.class); @Override public ChainedOptionsBuilder mode(Mode mode) { @@ -672,7 +672,7 @@ public ChainedOptionsBuilder detectJvmArgs() { // --------------------------------------------------------------------------- - private Multimap params = new HashMultimap<>(); + private final Multimap params = new HashMultimap<>(); @Override public Optional> getParameter(String name) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 443cf21ac..e25c1220b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -29,10 +29,8 @@ import java.io.*; import java.lang.management.ManagementFactory; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.charset.Charset; -import java.nio.charset.UnsupportedCharsetException; import java.util.*; import java.util.concurrent.*; import java.util.regex.Pattern; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineWriter.java b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineWriter.java index 56b42b064..67b5ab55e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineWriter.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineWriter.java @@ -35,7 +35,7 @@ public class TestLineWriter { - private StringBuilder line; + private final StringBuilder line; public TestLineWriter() { line = new StringBuilder(); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java index 5cc143c2a..0169ab9c2 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java @@ -86,7 +86,7 @@ public void testEmptyOptsHaveCompileCommandFile() { public void testOptsWithCompileCommandFileResultInMergedCompileCommandFile() throws IOException { // add a hints file String tempHints = FileUtils.createTempFileWithLines("fileWithLines", - Arrays.asList("inline,we/like/to/move/it.*")); + Collections.singletonList("inline,we/like/to/move/it.*")); Set extraHints = CompilerHints.fromFile(tempHints).get(); Runner blade = new Runner(new OptionsBuilder().build()); BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, @@ -95,7 +95,7 @@ public void testOptsWithCompileCommandFileResultInMergedCompileCommandFile() thr new IterationParams(IterationType.WARMUP, 1, TimeValue.seconds(1), 1), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, - Utils.getCurrentJvm(), Arrays.asList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints), + Utils.getCurrentJvm(), Collections.singletonList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); @@ -118,10 +118,10 @@ public void testOptsWithCompileCommandFileResultInMergedCompileCommandFile() thr public void testOptsWith2CompileCommandFilesResultInMergedCompileCommandFile() throws IOException { // add hints files String tempHints1 = FileUtils.createTempFileWithLines("fileWithLines", - Arrays.asList("inline,we/like/to/move/it/move/it.*")); + Collections.singletonList("inline,we/like/to/move/it/move/it.*")); Set extraHints1 = CompilerHints.fromFile(tempHints1).get(); String tempHints2 = FileUtils.createTempFileWithLines("fileWithLines", - Arrays.asList("inline,we/like/to/move/it.*")); + Collections.singletonList("inline,we/like/to/move/it.*")); Set extraHints2 = CompilerHints.fromFile(tempHints2).get(); Runner blade = new Runner(new OptionsBuilder().build()); BenchmarkParams bp = new BenchmarkParams("Foo", "bar", false, diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java index 0d7e68d1a..280c7a9a1 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java @@ -209,7 +209,7 @@ public static void setUpClass() throws Exception { @Test public void testListGetNothing() throws Exception { // make sure we get nothing - List excludes = Arrays.asList(".*"); + List excludes = Collections.singletonList(".*"); Set micros = list.getAll(out, excludes); assertEquals(0, micros.size()); } @@ -225,7 +225,7 @@ public void testListGetAll() throws Exception { @Test public void testListFindSingleByPattern() throws Exception { // check find without excludes - List includes = Arrays.asList(".*Hash.*"); + List includes = Collections.singletonList(".*Hash.*"); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(7, micros.size()); @@ -234,7 +234,7 @@ public void testListFindSingleByPattern() throws Exception { @Test public void testListFindSingleBySubstring() throws Exception { // check find without excludes - List includes = Arrays.asList("Hash"); + List includes = Collections.singletonList("Hash"); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(7, micros.size()); @@ -244,7 +244,7 @@ public void testListFindSingleBySubstring() throws Exception { public void testListFindSingleByTypical() throws Exception { // check find without excludes // this would be a typical partial pattern with . abuse case - List includes = Arrays.asList("jbb05.GeneratedSPECjbb2005HashMap"); + List includes = Collections.singletonList("jbb05.GeneratedSPECjbb2005HashMap"); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(5, micros.size()); @@ -254,7 +254,7 @@ public void testListFindSingleByTypical() throws Exception { public void testListFindAnchored() throws Exception { // check find without excludes // matches only: org.openjdk.jmh.runner.TestMicro.dummy - List includes = Arrays.asList("^org\\.openjdk.*\\.dummy$"); + List includes = Collections.singletonList("^org\\.openjdk.*\\.dummy$"); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); assertEquals(1, micros.size()); @@ -263,8 +263,8 @@ public void testListFindAnchored() throws Exception { @Test public void testListFindSingleWithExcludes() throws Exception { // check find with excludes - List includes = Arrays.asList(".*Hash.*"); - List excludes = Arrays.asList(".*Int.*"); + List includes = Collections.singletonList(".*Hash.*"); + List excludes = Collections.singletonList(".*Int.*"); Set micros = list.find(out, includes, excludes); assertEquals(2, micros.size()); } @@ -272,8 +272,8 @@ public void testListFindSingleWithExcludes() throws Exception { @Test public void testListFindAllWithSubstringExclude() throws Exception { // check find with excludes - List includes = Arrays.asList(""); - List excludes = Arrays.asList("oracle"); + List includes = Collections.singletonList(""); + List excludes = Collections.singletonList("oracle"); Set micros = list.find(out, includes, excludes); assertEquals(10, micros.size()); } @@ -297,8 +297,8 @@ public void testListFindIncludeList() throws Exception { @Test public void testListFindWithIncludesAndExcludes() throws Exception { - List includes = Arrays.asList(".*Concurrent.*"); - List excludes = Arrays.asList(".*Int.*"); + List includes = Collections.singletonList(".*Concurrent.*"); + List excludes = Collections.singletonList(".*Int.*"); Set micros = list.find(out, includes, excludes); assertEquals(2, micros.size()); } @@ -306,8 +306,8 @@ public void testListFindWithIncludesAndExcludes() throws Exception { @Test public void testListIsSorted() throws Exception { // micros should be sorted - List includes = Arrays.asList(".*Hash.*"); - List excludes = Arrays.asList(".*Int.*"); + List includes = Collections.singletonList(".*Hash.*"); + List excludes = Collections.singletonList(".*Int.*"); Set micros = list.find(out, includes, excludes); BenchmarkListEntry first = micros.iterator().next(); assertTrue("oracle.micro.benchmarks.api.java.util.concurrent.GeneratedMaps.testConcurrentHashMap".equals(first.getUsername())); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestParentOptions.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestParentOptions.java index 957da1501..c2ed6ad1a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestParentOptions.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestParentOptions.java @@ -31,6 +31,7 @@ import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.EnumSet; import java.util.concurrent.TimeUnit; @@ -47,7 +48,7 @@ public void testIncludes_Empty() throws Exception { public void testIncludes_Parent() throws Exception { Options parent = new OptionsBuilder().include(".*").build(); Options builder = new OptionsBuilder().parent(parent).build(); - Assert.assertEquals(Arrays.asList(".*"), builder.getIncludes()); + Assert.assertEquals(Collections.singletonList(".*"), builder.getIncludes()); } @Test @@ -68,7 +69,7 @@ public void testExcludes_Empty() throws Exception { public void testExcludes_Parent() throws Exception { Options parent = new OptionsBuilder().include(".*").build(); Options builder = new OptionsBuilder().parent(parent).build(); - Assert.assertEquals(Arrays.asList(".*"), builder.getIncludes()); + Assert.assertEquals(Collections.singletonList(".*"), builder.getIncludes()); } @Test @@ -575,7 +576,7 @@ public void testWarmupMicros_Empty() throws Exception { public void testWarmupMicros_Parent() throws Exception { Options parent = new OptionsBuilder().includeWarmup(".*").build(); Options builder = new OptionsBuilder().parent(parent).build(); - Assert.assertEquals(Arrays.asList(".*"), builder.getWarmupIncludes()); + Assert.assertEquals(Collections.singletonList(".*"), builder.getWarmupIncludes()); } @Test diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java index ecf6ecffa..d3495263a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java @@ -28,6 +28,7 @@ import org.junit.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -44,7 +45,7 @@ public void testDenseClasses1() { @Test public void testDenseClasses2() { - List src = Arrays.asList("org.openjdk.benches.ForkJoinTest.test1"); + List src = Collections.singletonList("org.openjdk.benches.ForkJoinTest.test1"); Map map = ClassUtils.denseClassNames(src); Assert.assertEquals("ForkJoinTest.test1", map.get("org.openjdk.benches.ForkJoinTest.test1")); @@ -52,7 +53,7 @@ public void testDenseClasses2() { @Test public void testDenseClasses3() { - List src = Arrays.asList("org.openjdk.benches.ForkJoinTest.test1:label1"); + List src = Collections.singletonList("org.openjdk.benches.ForkJoinTest.test1:label1"); Map map = ClassUtils.denseClassNames(src); Assert.assertEquals("ForkJoinTest.test1:label1", map.get("org.openjdk.benches.ForkJoinTest.test1:label1")); diff --git a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/BenchmarkProcessor.java b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/BenchmarkProcessor.java index 2f6200b21..81457122a 100644 --- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/BenchmarkProcessor.java +++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/BenchmarkProcessor.java @@ -33,7 +33,6 @@ import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; -import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; import javax.lang.model.element.TypeElement; import java.util.Set; diff --git a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java index 4af1880eb..1820f80d1 100644 --- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java +++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java @@ -38,11 +38,9 @@ public class APGeneratorDestinaton implements GeneratorDestination { - private final RoundEnvironment roundEnv; private final ProcessingEnvironment processingEnv; public APGeneratorDestinaton(RoundEnvironment roundEnv, ProcessingEnvironment processingEnv) { - this.roundEnv = roundEnv; this.processingEnv = processingEnv; } From c99d23efa29b5c091ed9df84eb0c3a6b1580cf1a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 17 Nov 2016 18:24:50 +0100 Subject: [PATCH 056/342] 7901838: Specifying profiler in the parent options makes it appear twice during runtime --- .../java/org/openjdk/jmh/runner/options/OptionsBuilder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java index 470e371a5..6b33067a4 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java @@ -220,10 +220,12 @@ public ChainedOptionsBuilder addProfiler(String prof, String initLine) { @Override public List getProfilers() { + List result = new ArrayList<>(); + result.addAll(profilers); if (otherOptions != null) { - profilers.addAll(otherOptions.getProfilers()); + result.addAll(otherOptions.getProfilers()); } - return profilers; + return result; } // --------------------------------------------------------------------------- From 97340f87a4d5cb1663af5751bfe672a3a29445f3 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 17 Nov 2016 20:32:19 +0100 Subject: [PATCH 057/342] 7901839: "safepoints" profiler --- .../openjdk/jmh/profile/ProfilerFactory.java | 1 + .../jmh/profile/SafepointsProfiler.java | 198 ++++++++++++++++++ .../jmh/profile/SafepointsProfilerTest.java | 42 ++++ 3 files changed, 241 insertions(+) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java create mode 100644 jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java index 51e6920d5..78db87e0e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java @@ -179,6 +179,7 @@ public static void listProfilers(PrintStream out) { BUILT_IN.put("perfasm", LinuxPerfAsmProfiler.class); BUILT_IN.put("xperfasm", WinPerfAsmProfiler.class); BUILT_IN.put("pauses", PausesProfiler.class); + BUILT_IN.put("safepoints", SafepointsProfiler.class); } private static List> getDiscoveredProfilers() { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java new file mode 100644 index 000000000..23fa8ec13 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2016, Red Hat Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.profile; + +import org.openjdk.jmh.infra.BenchmarkParams; +import org.openjdk.jmh.results.*; +import org.openjdk.jmh.util.SampleBuffer; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class SafepointsProfiler implements ExternalProfiler { + + @Override + public String getDescription() { + return "Safepoints profiler"; + } + + @Override + public Collection addJVMInvokeOptions(BenchmarkParams params) { + return Collections.emptyList(); + } + + @Override + public Collection addJVMOptions(BenchmarkParams params) { + return Collections.singletonList("-Xlog:safepoint=info"); + } + + @Override + public void beforeTrial(BenchmarkParams benchmarkParams) { + // do nothing + } + + @Override + public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { + long skip = br.getMetadata().getMeasurementTime() - br.getMetadata().getStartTime(); + + SampleBuffer pauseBuff = new SampleBuffer(); + SampleBuffer ttspBuff = new SampleBuffer(); + + try (BufferedReader reader = + Files.newBufferedReader(stdOut.toPath(), Charset.defaultCharset())) { + String line; + while ((line = reader.readLine()) != null) { + ParsedData data = parse(line); + if (data != null) { + if (data.timestamp < skip) continue; + pauseBuff.add(data.stopTime); + ttspBuff.add(data.ttspTime); + } + } + } catch (IOException e) { + throw new IllegalStateException(e); + } + + return Arrays.asList( + new SafepointProfilerResult("pause", pauseBuff), + new SafepointProfilerResult("ttsp", ttspBuff) + ); + } + + static long parseNs(String str) { + return (long) (Double.parseDouble(str) * TimeUnit.SECONDS.toNanos(1)); + } + + @Override + public boolean allowPrintOut() { + return false; + } + + @Override + public boolean allowPrintErr() { + return true; + } + + static class SafepointProfilerResult extends Result { + private final String suffix; + private final SampleBuffer buffer; + + public SafepointProfilerResult(String suffix, SampleBuffer buffer) { + super(ResultRole.SECONDARY, Defaults.PREFIX + "safepoints." + suffix, buffer.getStatistics(1D / 1000000), "ms", AggregationPolicy.SUM); + this.suffix = suffix; + this.buffer = buffer; + } + + @Override + protected Aggregator getThreadAggregator() { + return new JoiningAggregator(); + } + + @Override + protected Aggregator getIterationAggregator() { + return new JoiningAggregator(); + } + + @Override + protected Collection getDerivativeResults() { + return Arrays.asList( + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".avg", statistics.getMean(), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".count", statistics.getN(), "#", AggregationPolicy.SUM), + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.00", statistics.getMin(), "ms", AggregationPolicy.MIN), + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.50", statistics.getPercentile(50), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.90", statistics.getPercentile(90), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.95", statistics.getPercentile(95), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.99", statistics.getPercentile(99), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.999", statistics.getPercentile(99.9), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.9999", statistics.getPercentile(99.99),"ms", AggregationPolicy.AVG), + new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p1.00", statistics.getMax(), "ms", AggregationPolicy.MAX) + ); + } + + /** + * Always add up all the samples into final result. + * This will allow aggregate result to achieve better accuracy. + */ + private static class JoiningAggregator implements Aggregator { + + @Override + public SafepointProfilerResult aggregate(Collection results) { + SampleBuffer buffer = new SampleBuffer(); + String suffix = null; + for (SafepointProfilerResult r : results) { + buffer.addAll(r.buffer); + if (suffix == null) { + suffix = r.suffix; + } else if (!suffix.equals(r.suffix)) { + throw new IllegalStateException("Trying to aggregate results with different suffixes"); + } + } + return new SafepointProfilerResult(suffix, buffer); + } + } + } + + /** + * Parse the line into the triplet. This is tested with unit tests, make sure to + * update those if changing this code. + */ + static ParsedData parse(String line) { + Pattern p = Pattern.compile("\\[(.*?)s\\]\\[info\\]\\[safepoint\\] (.*) stopped: (.*) seconds, (.*) took: (.*) seconds"); + if (line.contains("[info][safepoint]")) { + Matcher m = p.matcher(line); + if (m.matches()) { + return new ParsedData( + parseNs(m.group(1)), + parseNs(m.group(3)), + parseNs(m.group(5)) + ); + } + } + + return null; + } + + static class ParsedData { + long timestamp; + long stopTime; + long ttspTime; + + public ParsedData(long timestamp, long stopTime, long ttspTime) { + this.timestamp = timestamp; + this.stopTime = stopTime; + this.ttspTime = ttspTime; + } + } + +} diff --git a/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java new file mode 100644 index 000000000..907092b3a --- /dev/null +++ b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016, Red Hat Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.profile; + +import junit.framework.Assert; +import org.junit.Test; + +public class SafepointsProfilerTest { + + @Test + public void parseJDK9b140() { + SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( + "[71.633s][info][safepoint] Total time for which application threads were stopped: 0.0359611 seconds, Stopping threads took: 0.0000516 seconds"); + Assert.assertNotNull(data); + Assert.assertEquals(71_633_000_000L, data.timestamp); + Assert.assertEquals( 35_961_100L, data.stopTime); + Assert.assertEquals( 51_600L, data.ttspTime); + } + +} From c30fa435293da17ebe50a66c968a52bceed41030 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 22 Nov 2016 21:12:18 +0100 Subject: [PATCH 058/342] Amend 7901839: Make "safepoints" profiler work on JDK 7 and 8 --- .../jmh/profile/SafepointsProfiler.java | 97 +++++++++++++++---- .../org/openjdk/jmh/util/SampleBuffer.java | 12 +++ .../jmh/profile/SafepointsProfilerTest.java | 20 ++++ 3 files changed, 112 insertions(+), 17 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java index 23fa8ec13..963a2f6d3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -33,15 +33,15 @@ import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SafepointsProfiler implements ExternalProfiler { + private static final long NO_LONG_VALUE = Long.MIN_VALUE; + @Override public String getDescription() { return "Safepoints profiler"; @@ -54,7 +54,16 @@ public Collection addJVMInvokeOptions(BenchmarkParams params) { @Override public Collection addJVMOptions(BenchmarkParams params) { - return Collections.singletonList("-Xlog:safepoint=info"); + return Arrays.asList( + // make sure old JVMs don't barf on Unified Logging + "-XX:+IgnoreUnrecognizedVMOptions", + + // JDK 9+: preferred, Unified Logging + "-Xlog:safepoint=info", + + // pre JDK-9: special options + "-XX:+PrintGCApplicationStoppedTime", "-XX:+PrintGCTimeStamps" + ); } @Override @@ -66,8 +75,7 @@ public void beforeTrial(BenchmarkParams benchmarkParams) { public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { long skip = br.getMetadata().getMeasurementTime() - br.getMetadata().getStartTime(); - SampleBuffer pauseBuff = new SampleBuffer(); - SampleBuffer ttspBuff = new SampleBuffer(); + List ds = new ArrayList<>(); try (BufferedReader reader = Files.newBufferedReader(stdOut.toPath(), Charset.defaultCharset())) { @@ -75,19 +83,39 @@ public Collection afterTrial(BenchmarkResult br, long pid, Fil while ((line = reader.readLine()) != null) { ParsedData data = parse(line); if (data != null) { - if (data.timestamp < skip) continue; - pauseBuff.add(data.stopTime); - ttspBuff.add(data.ttspTime); + ds.add(data); } } } catch (IOException e) { throw new IllegalStateException(e); } - return Arrays.asList( - new SafepointProfilerResult("pause", pauseBuff), - new SafepointProfilerResult("ttsp", ttspBuff) - ); + // Only accept the lines from the highest version. + long maxVer = Long.MIN_VALUE; + for (ParsedData d : ds) { + maxVer = Math.max(maxVer, d.ver); + } + + SampleBuffer pauseBuff = new SampleBuffer(); + SampleBuffer ttspBuff = new SampleBuffer(); + + for (ParsedData d : ds) { + if (d.ver == maxVer && d.timestamp > skip) { + pauseBuff.add(d.stopTime); + if (d.ttspTime != NO_LONG_VALUE) { + ttspBuff.add(d.ttspTime); + } + } + } + + Collection results = new ArrayList<>(); + results.add(new SafepointProfilerResult("pause", pauseBuff)); + + // JDK 7 does not have TTSP measurements, ignore the zero metric: + if (maxVer > 7) { + results.add(new SafepointProfilerResult("ttsp", ttspBuff)); + } + return results; } static long parseNs(String str) { @@ -163,16 +191,49 @@ public SafepointProfilerResult aggregate(Collection res } } + private static final Pattern JDK_7_LINE = + Pattern.compile("([0-9\\.,]*): (.*) stopped: ([0-9\\.,]*) seconds"); + + private static final Pattern JDK_8_LINE = + Pattern.compile("([0-9\\.,]*): (.*) stopped: ([0-9\\.,]*) seconds, (.*) took: ([0-9\\.,]*) seconds"); + + private static final Pattern JDK_9_LINE = + Pattern.compile("\\[([0-9\\.,]*)s\\]\\[info\\]\\[safepoint\\] (.*) stopped: ([0-9\\.,]*) seconds, (.*) took: ([0-9\\.,]*) seconds"); + /** * Parse the line into the triplet. This is tested with unit tests, make sure to * update those if changing this code. */ static ParsedData parse(String line) { - Pattern p = Pattern.compile("\\[(.*?)s\\]\\[info\\]\\[safepoint\\] (.*) stopped: (.*) seconds, (.*) took: (.*) seconds"); - if (line.contains("[info][safepoint]")) { - Matcher m = p.matcher(line); + { + Matcher m = JDK_7_LINE.matcher(line); + if (m.matches()) { + return new ParsedData( + 7, + parseNs(m.group(1)), + parseNs(m.group(3)), + NO_LONG_VALUE + ); + } + } + + { + Matcher m = JDK_8_LINE.matcher(line); + if (m.matches()) { + return new ParsedData( + 8, + parseNs(m.group(1)), + parseNs(m.group(3)), + parseNs(m.group(5)) + ); + } + } + + { + Matcher m = JDK_9_LINE.matcher(line); if (m.matches()) { return new ParsedData( + 9, parseNs(m.group(1)), parseNs(m.group(3)), parseNs(m.group(5)) @@ -184,11 +245,13 @@ static ParsedData parse(String line) { } static class ParsedData { + int ver; long timestamp; long stopTime; long ttspTime; - public ParsedData(long timestamp, long stopTime, long ttspTime) { + public ParsedData(int ver, long timestamp, long stopTime, long ttspTime) { + this.ver = ver; this.timestamp = timestamp; this.stopTime = stopTime; this.ttspTime = ttspTime; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/SampleBuffer.java b/jmh-core/src/main/java/org/openjdk/jmh/util/SampleBuffer.java index 7d925e4f3..6edfc49ae 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/SampleBuffer.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/SampleBuffer.java @@ -95,4 +95,16 @@ public void addAll(SampleBuffer other) { } } } + + public int count() { + int count = 0; + for (int[] bucket : hdr) { + if (bucket != null) { + for (int v : bucket) { + count += v; + } + } + } + return count; + } } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java index 907092b3a..b9efdffc8 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java @@ -29,6 +29,26 @@ public class SafepointsProfilerTest { + @Test + public void parseJDK7u77() { + SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( + "1.095: Total time for which application threads were stopped: 0.0014010 seconds"); + Assert.assertNotNull(data); + Assert.assertEquals(1_095_000_000L, data.timestamp); + Assert.assertEquals( 1_401_000L, data.stopTime); + Assert.assertEquals(Long.MIN_VALUE, data.ttspTime); + } + + @Test + public void parseJDK8u101() { + SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( + "5.042: Total time for which application threads were stopped: 0.0028944 seconds, Stopping threads took: 0.0028351 seconds"); + Assert.assertNotNull(data); + Assert.assertEquals(5_042_000_000L, data.timestamp); + Assert.assertEquals( 2_894_400L, data.stopTime); + Assert.assertEquals( 2_835_100L, data.ttspTime); + } + @Test public void parseJDK9b140() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( From a7ce99a5fc0208b8592439cf76cbc4fbc390c387 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 22 Nov 2016 21:17:07 +0100 Subject: [PATCH 059/342] JMH v1.17 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index edf5d4920..c1980accd 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17-SNAPSHOT + 1.17 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 9e3adcde2..9fb3f7f9a 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.17-SNAPSHOT + 1.17 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 0180fa581..d60d485d2 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17-SNAPSHOT + 1.17 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 795b85fad..2faab21f7 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17-SNAPSHOT + 1.17 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 4e5239bb2..1681e3bfc 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 68a36452c..dad8f11f4 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 8e6e22079..f6dc7fc53 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index a788ff103..d13404a3f 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 6e9f0d088..bd13b82de 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 39d631a4f..906635a07 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 7b463390c..9ddb097a1 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 28170abd6..6904273dc 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 23fa819c1..8cc9b733c 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 6fd291900..c82e5d201 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.17-SNAPSHOT + 1.17 JMH Samples diff --git a/pom.xml b/pom.xml index 5e3c17fc0..00120ef6a 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.17-SNAPSHOT + 1.17 Java Microbenchmark Harness Parent From 751628b08b448267e6003ec20ce434468d0d119d Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 22 Nov 2016 21:17:15 +0100 Subject: [PATCH 060/342] Added tag 1.17 for changeset 9df177c239d0 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 28986a30b..231f54d6a 100644 --- a/.hgtags +++ b/.hgtags @@ -80,3 +80,4 @@ b9ea316668ae3e6510bf6ebe21625218f966c15a 1.14 eaf181b4eac282ae20f9cb43ad221cf404a951c0 1.14.1 318b0c31563430446b42e63095d90bc922fc62ee 1.15 90e9bafa6cd05172901b336416856561c40d1247 1.16 +9df177c239d0962ecdaebebc00d650e52a2f32df 1.17 From 6a35e0790ed01ba34767ee7d7025d619a703e47e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 22 Nov 2016 21:17:27 +0100 Subject: [PATCH 061/342] Continue in 1.18-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index c1980accd..2b88ecbbc 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17 + 1.18-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 9fb3f7f9a..2b782ce02 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.17 + 1.18-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index d60d485d2..d4435596f 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17 + 1.18-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 2faab21f7..90714770e 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17 + 1.18-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 1681e3bfc..87f9a6b71 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index dad8f11f4..9b4d4eb89 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index f6dc7fc53..8bad703f3 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index d13404a3f..c7608af12 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index bd13b82de..9a6c45537 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 906635a07..1c13f284c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 9ddb097a1..a88da5151 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 6904273dc..6bab1921a 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 8cc9b733c..5623aa7e2 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index c82e5d201..6ce4656e2 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.17 + 1.18-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 00120ef6a..8a9b46fb1 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.17 + 1.18-SNAPSHOT Java Microbenchmark Harness Parent From ff58564ef701821558df24bc8a877e4cd691c589 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 29 Nov 2016 15:53:41 +0100 Subject: [PATCH 062/342] 7901847: safepoints profiler breaks when system locale has "," as decimal separator --- .../jmh/profile/SafepointsProfiler.java | 3 +- .../jmh/profile/SafepointsProfilerTest.java | 36 +++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java index 963a2f6d3..b855e0782 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -33,6 +33,7 @@ import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; +import java.text.NumberFormat; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; @@ -119,7 +120,7 @@ public Collection afterTrial(BenchmarkResult br, long pid, Fil } static long parseNs(String str) { - return (long) (Double.parseDouble(str) * TimeUnit.SECONDS.toNanos(1)); + return (long) (Double.parseDouble(str.replace(',', '.')) * TimeUnit.SECONDS.toNanos(1)); } @Override diff --git a/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java index b9efdffc8..4a7dc9251 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java @@ -30,7 +30,7 @@ public class SafepointsProfilerTest { @Test - public void parseJDK7u77() { + public void parseJDK7u77_Point() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "1.095: Total time for which application threads were stopped: 0.0014010 seconds"); Assert.assertNotNull(data); @@ -40,7 +40,17 @@ public void parseJDK7u77() { } @Test - public void parseJDK8u101() { + public void parseJDK7u77_Comma() { + SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( + "1,095: Total time for which application threads were stopped: 0,0014010 seconds"); + Assert.assertNotNull(data); + Assert.assertEquals(1_095_000_000L, data.timestamp); + Assert.assertEquals( 1_401_000L, data.stopTime); + Assert.assertEquals(Long.MIN_VALUE, data.ttspTime); + } + + @Test + public void parseJDK8u101_Dot() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "5.042: Total time for which application threads were stopped: 0.0028944 seconds, Stopping threads took: 0.0028351 seconds"); Assert.assertNotNull(data); @@ -50,7 +60,17 @@ public void parseJDK8u101() { } @Test - public void parseJDK9b140() { + public void parseJDK8u101_Comma() { + SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( + "5,042: Total time for which application threads were stopped: 0,0028944 seconds, Stopping threads took: 0,0028351 seconds"); + Assert.assertNotNull(data); + Assert.assertEquals(5_042_000_000L, data.timestamp); + Assert.assertEquals( 2_894_400L, data.stopTime); + Assert.assertEquals( 2_835_100L, data.ttspTime); + } + + @Test + public void parseJDK9b140_Dot() { SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( "[71.633s][info][safepoint] Total time for which application threads were stopped: 0.0359611 seconds, Stopping threads took: 0.0000516 seconds"); Assert.assertNotNull(data); @@ -59,4 +79,14 @@ public void parseJDK9b140() { Assert.assertEquals( 51_600L, data.ttspTime); } + @Test + public void parseJDK9b140_Comma() { + SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( + "[71,633s][info][safepoint] Total time for which application threads were stopped: 0,0359611 seconds, Stopping threads took: 0,0000516 seconds"); + Assert.assertNotNull(data); + Assert.assertEquals(71_633_000_000L, data.timestamp); + Assert.assertEquals( 35_961_100L, data.stopTime); + Assert.assertEquals( 51_600L, data.ttspTime); + } + } From c5ea7dd5468f8ea09a15ee951ba6c72bd5e07409 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 29 Nov 2016 16:06:36 +0100 Subject: [PATCH 063/342] 7901848: safepoints profiler breaks when benchmark metadata is not available --- .../jmh/profile/AbstractPerfAsmProfiler.java | 12 +----------- .../jmh/profile/LinuxPerfNormProfiler.java | 12 +----------- .../org/openjdk/jmh/profile/ProfilerUtils.java | 16 ++++++++++++++++ .../openjdk/jmh/profile/SafepointsProfiler.java | 3 +-- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index ce2e3e428..df8094c54 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -29,7 +29,6 @@ import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; -import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.util.*; @@ -334,16 +333,7 @@ private PerfResult processAssembly(BenchmarkResult br, File stdOut, File stdErr) long delayNs; if (delayMsec == -1) { // not set - BenchmarkResultMetaData md = br.getMetadata(); - if (md != null) { - // try to ask harness itself: - delayNs = TimeUnit.MILLISECONDS.toNanos(md.getMeasurementTime() - md.getStartTime()); - } else { - // metadata is not available, let's make a guess: - IterationParams wp = br.getParams().getWarmup(); - delayNs = wp.getCount() * wp.getTime().convertTo(TimeUnit.NANOSECONDS) - + TimeUnit.SECONDS.toNanos(1); // loosely account for the JVM lag - } + delayNs = TimeUnit.MILLISECONDS.toNanos(ProfilerUtils.warmupDelayMs(br)); } else { delayNs = TimeUnit.MILLISECONDS.toNanos(delayMsec); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index 811467065..5366ed94c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -29,7 +29,6 @@ import joptsimple.OptionSet; import joptsimple.OptionSpec; import org.openjdk.jmh.infra.BenchmarkParams; -import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; import org.openjdk.jmh.util.*; @@ -179,16 +178,7 @@ public String getDescription() { public long getDelay(BenchmarkResult br) { if (delayMs == -1) { // not set - BenchmarkResultMetaData md = br.getMetadata(); - if (md != null) { - // try to ask harness itself: - return TimeUnit.MILLISECONDS.toNanos(md.getMeasurementTime() - md.getStartTime()); - } else { - // metadata is not available, let's make a guess: - IterationParams wp = br.getParams().getWarmup(); - return wp.getCount() * wp.getTime().convertTo(TimeUnit.NANOSECONDS) - + TimeUnit.SECONDS.toNanos(1); // loosely account for the JVM lag - } + return TimeUnit.MILLISECONDS.toNanos(ProfilerUtils.warmupDelayMs(br)); } else { return TimeUnit.MILLISECONDS.toNanos(delayMs); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java index 0693dd3b3..0a9167125 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java @@ -28,9 +28,13 @@ import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; +import org.openjdk.jmh.infra.IterationParams; +import org.openjdk.jmh.results.BenchmarkResult; +import org.openjdk.jmh.results.BenchmarkResultMetaData; import java.io.IOException; import java.io.StringWriter; +import java.util.concurrent.TimeUnit; class ProfilerUtils { @@ -78,5 +82,17 @@ public static OptionSet parseInitLine(String initLine, OptionParser parser) thro return set; } + public static long warmupDelayMs(BenchmarkResult br) { + BenchmarkResultMetaData md = br.getMetadata(); + if (md != null) { + // try to ask harness itself: + return md.getMeasurementTime() - md.getStartTime(); + } else { + // metadata is not available, let's make a guess: + IterationParams wp = br.getParams().getWarmup(); + return wp.getCount() * wp.getTime().convertTo(TimeUnit.MILLISECONDS) + + TimeUnit.SECONDS.toMillis(1); // loosely account for the JVM lag + } + } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java index b855e0782..17df8ebe4 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -33,7 +33,6 @@ import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; -import java.text.NumberFormat; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; @@ -74,7 +73,7 @@ public void beforeTrial(BenchmarkParams benchmarkParams) { @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { - long skip = br.getMetadata().getMeasurementTime() - br.getMetadata().getStartTime(); + long skip = ProfilerUtils.warmupDelayMs(br); List ds = new ArrayList<>(); From 6d448671506f3c13022557a72a7e53e106d2288d Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 29 Nov 2016 16:14:11 +0100 Subject: [PATCH 064/342] 7901849: BenchmarkException.getCause is too strict and fails during normal printing --- .../main/java/org/openjdk/jmh/runner/BenchmarkException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java index da95de41c..e018f5e1e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java @@ -46,6 +46,6 @@ public BenchmarkException(String msg, Collection errors) { @Override public Throwable getCause() { - throw new UnsupportedOperationException("BenchmarkException only has suppressed causes"); + return null; } } From e0a2d23de9ef6de68e7b1db2594b8a1a3f635285 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 29 Nov 2016 18:46:01 +0100 Subject: [PATCH 065/342] JMH v1.17.1 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 2b88ecbbc..7678dd02f 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.1 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 2b782ce02..3660be83d 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.1 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index d4435596f..0567978d8 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.1 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 90714770e..ff35550dc 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.1 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 87f9a6b71..4d27b4e36 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 9b4d4eb89..901b0ba0f 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 8bad703f3..6b27299e1 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index c7608af12..188dae6cf 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 9a6c45537..1076fb8bf 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 1c13f284c..6b7f2cea8 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index a88da5151..30780ef36 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 6bab1921a..2e6512fd8 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 5623aa7e2..ff6781ee5 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 6ce4656e2..168760b54 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.1 JMH Samples diff --git a/pom.xml b/pom.xml index 8a9b46fb1..435737441 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.18-SNAPSHOT + 1.17.1 Java Microbenchmark Harness Parent From 27282cf59dd60a33d73265f579c379169d34607c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 29 Nov 2016 18:46:04 +0100 Subject: [PATCH 066/342] Added tag 1.17.1 for changeset bf7249ffbfd2 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 231f54d6a..f06ea4b00 100644 --- a/.hgtags +++ b/.hgtags @@ -81,3 +81,4 @@ eaf181b4eac282ae20f9cb43ad221cf404a951c0 1.14.1 318b0c31563430446b42e63095d90bc922fc62ee 1.15 90e9bafa6cd05172901b336416856561c40d1247 1.16 9df177c239d0962ecdaebebc00d650e52a2f32df 1.17 +bf7249ffbfd24a703f18ea90bff379de16182979 1.17.1 From e4c684f582e936f81a1dbd1aad3faab9517b5921 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 29 Nov 2016 18:46:20 +0100 Subject: [PATCH 067/342] Continue in 1.18-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 7678dd02f..2b88ecbbc 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.1 + 1.18-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 3660be83d..2b782ce02 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.17.1 + 1.18-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 0567978d8..d4435596f 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.1 + 1.18-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index ff35550dc..90714770e 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.1 + 1.18-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 4d27b4e36..87f9a6b71 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 901b0ba0f..9b4d4eb89 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 6b27299e1..8bad703f3 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 188dae6cf..c7608af12 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 1076fb8bf..9a6c45537 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 6b7f2cea8..1c13f284c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 30780ef36..a88da5151 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 2e6512fd8..6bab1921a 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index ff6781ee5..5623aa7e2 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 168760b54..6ce4656e2 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.17.1 + 1.18-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 435737441..8a9b46fb1 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.17.1 + 1.18-SNAPSHOT Java Microbenchmark Harness Parent From bbc938cdfbabeb6884147810dbb7bcc59c1e8218 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 1 Dec 2016 12:23:24 +0100 Subject: [PATCH 068/342] 7901851: perfasm profiler AIOOBEs on newer JDK 9 --- .../org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index df8094c54..130cb52a5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -829,7 +829,13 @@ Assembly readAssembly(File stdOut) { HashMap map = new HashMap<>(); for (String kv : kvs) { String[] pair = kv.split("="); - map.put(pair[0], pair[1]); + + // Guard against "key=''" + if (pair.length == 2) { + map.put(pair[0], pair[1]); + } else { + map.put(pair[0], null); + } } // Record the starting address for the method From f7e561f25156a2ba41ec30f869d7fbb27fd152a7 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 5 Dec 2016 12:49:50 +0100 Subject: [PATCH 069/342] 7901856: safepoints profiler should report application stopped time --- .../java/org/openjdk/jmh/profile/ProfilerUtils.java | 11 +++++++++++ .../org/openjdk/jmh/profile/SafepointsProfiler.java | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java index 0a9167125..a92ca554f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java @@ -95,4 +95,15 @@ public static long warmupDelayMs(BenchmarkResult br) { } } + public static long measuredTimeMs(BenchmarkResult br) { + BenchmarkResultMetaData md = br.getMetadata(); + if (md != null) { + // try to ask harness itself: + return md.getStopTime() - md.getMeasurementTime(); + } else { + // metadata is not available, let's make a guess: + IterationParams mp = br.getParams().getMeasurement(); + return mp.getCount() * mp.getTime().convertTo(TimeUnit.MILLISECONDS); + } + } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java index 17df8ebe4..e4dd5fbb3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -74,6 +74,7 @@ public void beforeTrial(BenchmarkParams benchmarkParams) { @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { long skip = ProfilerUtils.warmupDelayMs(br); + long measuredTime = ProfilerUtils.measuredTimeMs(br); List ds = new ArrayList<>(); @@ -108,7 +109,12 @@ public Collection afterTrial(BenchmarkResult br, long pid, Fil } } - Collection results = new ArrayList<>(); + Collection results = new ArrayList<>(); + + results.add(new ScalarResult(Defaults.PREFIX + "safepoints.app.stopped", + pauseBuff.getStatistics(100).getSum() / TimeUnit.MILLISECONDS.toNanos(measuredTime), + "%", AggregationPolicy.AVG)); + results.add(new SafepointProfilerResult("pause", pauseBuff)); // JDK 7 does not have TTSP measurements, ignore the zero metric: From 871131093985cc6f2b3b435d96a68947cf8dea85 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 5 Dec 2016 20:40:04 +0100 Subject: [PATCH 070/342] 7901860: safepoints profiler should filter the events correctly, and report the measurement interval --- .../openjdk/jmh/profile/SafepointsProfiler.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java index e4dd5fbb3..3b40d5a1a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -73,8 +73,11 @@ public void beforeTrial(BenchmarkParams benchmarkParams) { @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { - long skip = ProfilerUtils.warmupDelayMs(br); - long measuredTime = ProfilerUtils.measuredTimeMs(br); + long measuredTimeMs = ProfilerUtils.measuredTimeMs(br); + long measuredTimeNs = TimeUnit.MILLISECONDS.toNanos(measuredTimeMs); + + long measureFrom = TimeUnit.MILLISECONDS.toNanos(ProfilerUtils.warmupDelayMs(br)); + long measureTo = measureFrom + measuredTimeNs; List ds = new ArrayList<>(); @@ -101,7 +104,8 @@ public Collection afterTrial(BenchmarkResult br, long pid, Fil SampleBuffer ttspBuff = new SampleBuffer(); for (ParsedData d : ds) { - if (d.ver == maxVer && d.timestamp > skip) { + if (d.ver == maxVer && + (d.timestamp > measureFrom) && (d.timestamp < measureTo)) { pauseBuff.add(d.stopTime); if (d.ttspTime != NO_LONG_VALUE) { ttspBuff.add(d.ttspTime); @@ -111,9 +115,8 @@ public Collection afterTrial(BenchmarkResult br, long pid, Fil Collection results = new ArrayList<>(); - results.add(new ScalarResult(Defaults.PREFIX + "safepoints.app.stopped", - pauseBuff.getStatistics(100).getSum() / TimeUnit.MILLISECONDS.toNanos(measuredTime), - "%", AggregationPolicy.AVG)); + results.add(new ScalarResult(Defaults.PREFIX + "safepoints.interval", + measuredTimeMs, "ms", AggregationPolicy.SUM)); results.add(new SafepointProfilerResult("pause", pauseBuff)); From 3068ad93ae727028e648c0e5046b6bfb2dfb34b0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 5 Dec 2016 20:50:17 +0100 Subject: [PATCH 071/342] 7901842: JMH perf* profilers and ocperf.py pmu-tools: accept JMH_PERF --- .../jmh/profile/LinuxPerfAsmProfiler.java | 6 ++-- .../jmh/profile/LinuxPerfNormProfiler.java | 10 +++--- .../jmh/profile/LinuxPerfProfiler.java | 8 ++--- .../org/openjdk/jmh/profile/PerfSupport.java | 36 +++++++++++++++++++ 4 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/PerfSupport.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index 1441ecce7..0c0c63d60 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -46,7 +46,7 @@ public class LinuxPerfAsmProfiler extends AbstractPerfAsmProfiler { public LinuxPerfAsmProfiler(String initLine) throws ProfilerException { super(initLine, "cycles", "instructions"); - Collection failMsg = Utils.tryWith("perf", "stat", "--log-fd", "2", "echo", "1"); + Collection failMsg = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "echo", "1"); if (!failMsg.isEmpty()) { throw new ProfilerException(failMsg.toString()); } @@ -67,7 +67,7 @@ protected void addMyOptions(OptionParser parser) { @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { - return Arrays.asList("perf", "record", "--freq", String.valueOf(sampleFrequency), "--event", Utils.join(events, ","), "--output", perfBinData); + return Arrays.asList(PerfSupport.PERF_EXEC, "record", "--freq", String.valueOf(sampleFrequency), "--event", Utils.join(events, ","), "--output", perfBinData); } @Override @@ -78,7 +78,7 @@ public String getDescription() { @Override protected void parseEvents() { try (FileOutputStream fos = new FileOutputStream(perfParsedData)) { - ProcessBuilder pb = new ProcessBuilder("perf", "script", "--fields", "time,event,ip,sym,dso", "--input", perfBinData); + ProcessBuilder pb = new ProcessBuilder(PerfSupport.PERF_EXEC, "script", "--fields", "time,event,ip,sym,dso", "--input", perfBinData); Process p = pb.start(); // drain streams, else we might lock up diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index 5366ed94c..bd24d0303 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -107,12 +107,12 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { throw new ProfilerException(e.getMessage()); } - Collection msgs = Utils.tryWith("perf", "stat", "--log-fd", "2", "--field-separator", ",", "echo", "1"); + Collection msgs = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "echo", "1"); if (!msgs.isEmpty()) { throw new ProfilerException(msgs.toString()); } - Collection incremental = Utils.tryWith("perf", "stat", "--log-fd", "2", "--field-separator", ",", "--interval-print", String.valueOf(incrementInterval), "echo", "1"); + Collection incremental = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--interval-print", String.valueOf(incrementInterval), "echo", "1"); isIncrementable = incremental.isEmpty(); if (userEvents != null) { @@ -124,7 +124,7 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { if (supportedEvents.isEmpty()) { for (String ev : interestingEvents) { - Collection res = Utils.tryWith("perf", "stat", "--log-fd", "2", "--field-separator", ",", "--event", "cycles,instructions," + ev, "echo", "1"); + Collection res = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--event", "cycles,instructions," + ev, "echo", "1"); if (res.isEmpty()) { supportedEvents.add(ev); } @@ -136,9 +136,9 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { public Collection addJVMInvokeOptions(BenchmarkParams params) { List cmd = new ArrayList<>(); if (useDefaultStats) { - cmd.addAll(Arrays.asList("perf", "stat", "--log-fd", "2", "--field-separator", ",", "--detailed", "--detailed", "--detailed")); + cmd.addAll(Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--detailed", "--detailed", "--detailed")); } else { - cmd.addAll(Arrays.asList("perf", "stat", "--log-fd", "2", "--field-separator", ",", "--event", Utils.join(supportedEvents, ","))); + cmd.addAll(Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--event", Utils.join(supportedEvents, ","))); } if (isIncrementable) { cmd.addAll(Arrays.asList("-I", String.valueOf(incrementInterval))); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java index ed786489a..fc738114e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java @@ -64,12 +64,12 @@ public LinuxPerfProfiler(String initLine) throws ProfilerException { throw new ProfilerException(e.getMessage()); } - Collection msgs = Utils.tryWith("perf", "stat", "--log-fd", "2", "echo", "1"); + Collection msgs = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "echo", "1"); if (!msgs.isEmpty()) { throw new ProfilerException(msgs.toString()); } - Collection delay = Utils.tryWith("perf", "stat", "--log-fd", "2", "--delay", "1", "echo", "1"); + Collection delay = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--delay", "1", "echo", "1"); isDelayed = delay.isEmpty(); } @@ -85,9 +85,9 @@ public Collection addJVMInvokeOptions(BenchmarkParams params) { } if (isDelayed) { - return Arrays.asList("perf", "stat", "--log-fd", "2", "--detailed", "--detailed", "--detailed", "--delay", String.valueOf(delay)); + return Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--detailed", "--detailed", "--detailed", "--delay", String.valueOf(delay)); } else { - return Arrays.asList("perf", "stat", "--log-fd", "2", "--detailed", "--detailed", "--detailed"); + return Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--detailed", "--detailed", "--detailed"); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/PerfSupport.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/PerfSupport.java new file mode 100644 index 000000000..b286fde73 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/PerfSupport.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016, Red Hat Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.profile; + +class PerfSupport { + + static final String PERF_EXEC; + + static { + String perf = System.getenv("JMH_PERF"); + PERF_EXEC = (perf == null) ? "perf" : perf; + } + +} From f36e1311cfeca42ee5992b8a27d2cad0468a5770 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 6 Dec 2016 12:05:41 +0100 Subject: [PATCH 072/342] 7901861: perf* profilers should use measured time to filter events --- .../jmh/profile/AbstractPerfAsmProfiler.java | 29 +++++--- .../jmh/profile/LinuxPerfAsmProfiler.java | 10 ++- .../jmh/profile/LinuxPerfNormProfiler.java | 68 ++++++++++++++++--- .../jmh/profile/WinPerfAsmProfiler.java | 9 ++- 4 files changed, 92 insertions(+), 24 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 130cb52a5..7c2cda53b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -34,7 +34,6 @@ import java.io.*; import java.util.*; -import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -48,6 +47,7 @@ public abstract class AbstractPerfAsmProfiler implements ExternalProfiler { private final int printMargin; private final int mergeMargin; private final int delayMsec; + private final int lengthMsec; private final boolean skipAssembly; private final boolean skipInterpreter; @@ -117,6 +117,10 @@ protected AbstractPerfAsmProfiler(String initLine, String... events) throws Prof "Delay collection for a given time, in milliseconds; -1 to detect automatically.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); + OptionSpec optLength = parser.accepts("length", + "Do the collection for a given time, in milliseconds; -1 to detect automatically.") + .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); + OptionSpec optSkipAsm = parser.accepts("skipAsm", "Skip -XX:+PrintAssembly instrumentation.") .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); @@ -196,6 +200,7 @@ protected AbstractPerfAsmProfiler(String initLine, String... events) throws Prof printMargin = set.valueOf(optPrintMargin); mergeMargin = set.valueOf(optMergeMargin); delayMsec = set.valueOf(optDelay); + lengthMsec = set.valueOf(optLength); skipAssembly = set.valueOf(optSkipAsm); skipInterpreter = set.valueOf(optSkipInterpreter); @@ -288,10 +293,11 @@ public boolean allowPrintErr() { /** * Read parsed events. * - * @param skipSec Seconds to skip. + * @param skipMs Milliseconds to skip. + * @param lenMs Milliseconds to capture after skip * @return Events. */ - protected abstract PerfEvents readEvents(double skipSec); + protected abstract PerfEvents readEvents(double skipMs, double lenMs); /** * Get perf binary data extension (optional). @@ -331,19 +337,24 @@ private PerfResult processAssembly(BenchmarkResult br, File stdOut, File stdErr) * 3. Read out perf output */ - long delayNs; + long skipMs; if (delayMsec == -1) { // not set - delayNs = TimeUnit.MILLISECONDS.toNanos(ProfilerUtils.warmupDelayMs(br)); + skipMs = ProfilerUtils.warmupDelayMs(br); } else { - delayNs = TimeUnit.MILLISECONDS.toNanos(delayMsec); + skipMs = delayMsec; } - double skipSec = 1.0 * delayNs / TimeUnit.SECONDS.toNanos(1); + double lenMs; + if (lengthMsec == -1) { // not set + lenMs = ProfilerUtils.measuredTimeMs(br); + } else { + lenMs = lengthMsec; + } - final PerfEvents events = readEvents(skipSec); + final PerfEvents events = readEvents(skipMs, lenMs); if (!events.isEmpty()) { - pw.printf("Perf output processed (skipped %.3f seconds):%n", skipSec); + pw.printf("Perf output processed (skipped %.3f seconds):%n", skipMs / 1000D); int cnt = 1; for (String event : this.events) { pw.printf(" Column %d: %s (%d events)%n", cnt, event, events.get(event).size()); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index 0c0c63d60..e41798ebe 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -98,7 +98,10 @@ protected void parseEvents() { } @Override - protected PerfEvents readEvents(double skipSec) { + protected PerfEvents readEvents(double skipMs, double lenMs) { + double readFrom = skipMs / 1000D; + double readTo = (skipMs + lenMs) / 1000D; + try (FileReader fr = new FileReader(perfParsedData); BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); @@ -139,7 +142,10 @@ protected PerfEvents readEvents(double skipSec) { if (startTime == null) { startTime = time; } else { - if (time - startTime < skipSec) { + if (time - startTime < readFrom) { + continue; + } + if (time - startTime > readTo) { continue; } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index bd24d0303..5bb581609 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -61,6 +61,7 @@ public class LinuxPerfNormProfiler implements ExternalProfiler { }; private final int delayMs; + private final int lengthMs; private final boolean useDefaultStats; private final long highPassFilter; private final int incrementInterval; @@ -80,6 +81,10 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { "Delay collection for a given time, in milliseconds; -1 to detect automatically.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); + OptionSpec optLength = parser.accepts("length", + "Do the collection for a given time, in milliseconds; -1 to detect automatically.") + .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); + OptionSpec optIncrementInterval = parser.accepts("interval", "The interval between incremental updates from a concurrently running perf. " + "Lower values may improve accuracy, while increasing the profiling overhead.") @@ -99,6 +104,7 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { try { delayMs = set.valueOf(optDelay); + lengthMs = set.valueOf(optLength); incrementInterval = set.valueOf(optIncrementInterval); highPassFilter = set.valueOf(optHighPassFilter); useDefaultStats = set.valueOf(optDefaultStat); @@ -176,21 +182,29 @@ public String getDescription() { return "Linux perf statistics, normalized by operation count"; } - public long getDelay(BenchmarkResult br) { - if (delayMs == -1) { // not set - return TimeUnit.MILLISECONDS.toNanos(ProfilerUtils.warmupDelayMs(br)); - } else { - return TimeUnit.MILLISECONDS.toNanos(delayMs); - } - } - private Collection process(BenchmarkResult br, File stdOut, File stdErr) { Multiset events = new HashMultiset<>(); try (FileReader fr = new FileReader(stdErr); BufferedReader reader = new BufferedReader(fr)) { - long delayNs = getDelay(br); + long skipMs; + if (delayMs == -1) { // not set + skipMs = ProfilerUtils.warmupDelayMs(br); + } else { + skipMs = delayMs; + } + + double lenMs; + if (lengthMs == -1) { // not set + lenMs = ProfilerUtils.measuredTimeMs(br); + } else { + lenMs = lengthMs; + } + + double readFrom = skipMs / 1000D; + double softTo = (skipMs + lenMs) / 1000D; + double readTo = (skipMs + lenMs + incrementInterval) / 1000D; NumberFormat nf = NumberFormat.getInstance(); @@ -222,12 +236,44 @@ private Collection process(BenchmarkResult br, File stdOut, Fi continue nextline; } + double multiplier = 1D; try { double timeSec = nf.parse(time).doubleValue(); - if (timeSec * TimeUnit.SECONDS.toNanos(1) < delayNs) { + if (timeSec < readFrom) { // warmup, ignore continue nextline; } + if (timeSec > readTo) { + // post-run, ignore + continue nextline; + } + + // Handle partial events: + double intervalSec = incrementInterval / 1000D; + if (timeSec - intervalSec < readFrom) { + // Event _starts_ before the measurement window + // .............[============|============ + // readFrom timeSec + // [<----------------->| // event + // incrementInterval + // + // Only count the tail after readFrom: + + multiplier = (timeSec - readFrom) / intervalSec; + } + if (timeSec > softTo) { + // Event is past the measurement window + // =============].............|............ + // softTo timeSec + // [<----------------->| // event + // incrementInterval + // + // Only count the head before softTo: + multiplier = 1 - (timeSec - softTo) / intervalSec; + } + + // Defensive, keep multiplier in bounds: + multiplier = Math.max(1D, Math.min(0D, multiplier)); } catch (ParseException e) { // don't care then, continue continue nextline; @@ -239,7 +285,7 @@ private Collection process(BenchmarkResult br, File stdOut, Fi // anomalous value, pretend we did not see it continue nextline; } - events.add(event, lValue); + events.add(event, (long) (lValue * multiplier)); } catch (ParseException e) { // do nothing, continue continue nextline; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index d50e1815e..1aef0f9b1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -178,7 +178,10 @@ protected void parseEvents() { } @Override - protected PerfEvents readEvents(double skipSec) { + protected PerfEvents readEvents(double skipMs, double lenMs) { + double readFrom = skipMs / 1000D; + double readTo = (skipMs + lenMs) / 1000D; + try (FileReader fr = new FileReader(perfParsedData); BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); @@ -220,7 +223,9 @@ protected PerfEvents readEvents(double skipSec) { double time = Double.valueOf(timeStr) / 1000000; - if (time < skipSec) + if (time < readFrom) + continue; + if (time > readTo) continue; // Get address. From c82e16a89d8e0dfee0800c3a9dd9f053095a935c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 6 Dec 2016 12:40:04 +0100 Subject: [PATCH 073/342] JMH v1.17.2 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 2b88ecbbc..cf79c0ee1 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.2 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 2b782ce02..8f5e05ef1 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.2 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index d4435596f..b8d715fce 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.2 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 90714770e..82bc920df 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.2 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 87f9a6b71..568ccb50c 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 9b4d4eb89..781e33396 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 8bad703f3..72846862e 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index c7608af12..fbe2922a9 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 9a6c45537..bf4ff36fa 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 1c13f284c..b86d208d1 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index a88da5151..094e20078 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 6bab1921a..411568b02 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 5623aa7e2..c21bc2e77 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 6ce4656e2..b86b01e8b 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.2 JMH Samples diff --git a/pom.xml b/pom.xml index 8a9b46fb1..821aa03b9 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.18-SNAPSHOT + 1.17.2 Java Microbenchmark Harness Parent From 5d82f8546cc324cb17aa7899f45df027bd40990d Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 6 Dec 2016 12:40:07 +0100 Subject: [PATCH 074/342] Added tag 1.17.2 for changeset d548e3fb7337 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index f06ea4b00..326b78ce4 100644 --- a/.hgtags +++ b/.hgtags @@ -82,3 +82,4 @@ eaf181b4eac282ae20f9cb43ad221cf404a951c0 1.14.1 90e9bafa6cd05172901b336416856561c40d1247 1.16 9df177c239d0962ecdaebebc00d650e52a2f32df 1.17 bf7249ffbfd24a703f18ea90bff379de16182979 1.17.1 +d548e3fb7337d8116767e4f669f5a0c901de758b 1.17.2 From d467c7a2f27c11be40e556d1f67e4d6bb1e45509 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 6 Dec 2016 12:40:19 +0100 Subject: [PATCH 075/342] Continue in 1.18-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index cf79c0ee1..2b88ecbbc 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.2 + 1.18-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 8f5e05ef1..2b782ce02 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.17.2 + 1.18-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index b8d715fce..d4435596f 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.2 + 1.18-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 82bc920df..90714770e 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.2 + 1.18-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 568ccb50c..87f9a6b71 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 781e33396..9b4d4eb89 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 72846862e..8bad703f3 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index fbe2922a9..c7608af12 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index bf4ff36fa..9a6c45537 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index b86d208d1..1c13f284c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 094e20078..a88da5151 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 411568b02..6bab1921a 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index c21bc2e77..5623aa7e2 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index b86b01e8b..6ce4656e2 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.17.2 + 1.18-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 821aa03b9..8a9b46fb1 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.17.2 + 1.18-SNAPSHOT Java Microbenchmark Harness Parent From 386025126c57fc5cc6b326d50e55deb58829ba24 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 13 Dec 2016 19:45:00 +0100 Subject: [PATCH 076/342] 7901865: Blackhole.consume(Object) retains consumed objects --- .../openjdk/jmh/generators/core/BenchmarkGenerator.java | 6 ++++-- .../src/main/java/org/openjdk/jmh/infra/Blackhole.java | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 11b7f906c..31e57180d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -837,11 +837,13 @@ private void methodProlog(PrintWriter writer, MethodGroup methodGroup) { writer.println(ident(2) + "this.iterationParams = control.iterationParams;"); writer.println(ident(2) + "this.threadParams = threadParams;"); writer.println(ident(2) + "this.notifyControl = control.notifyControl;"); - writer.println(ident(2) + "this.blackhole = new Blackhole(\"Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.\");"); + writer.println(ident(2) + "if (this.blackhole == null) {"); + writer.println(ident(3) + "this.blackhole = new Blackhole(\"Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.\");"); + writer.println(ident(2) + "}"); } private void methodEpilog(PrintWriter writer, MethodGroup methodGroup) { - writer.println(ident(3) + "this.blackhole = null;"); + writer.println(ident(3) + "this.blackhole.purge();"); } private String prefix(String argList) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java index 5d6d693dd..9187331be 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java @@ -280,6 +280,14 @@ public Blackhole(String challengeResponse) { } } + /** + * Clear internal waste, if any. + */ + public void purge() { + obj1 = null; + objs1 = null; + } + /** * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. * From dee3fab7bfee3ee26742f6aa99fba5720646da94 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 13 Dec 2016 20:54:04 +0100 Subject: [PATCH 077/342] Amend 7901865: don't miss the chance to call the method appropriately and establish challenge-response --- .../jmh/generators/core/BenchmarkGenerator.java | 2 +- .../src/main/java/org/openjdk/jmh/infra/Blackhole.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 31e57180d..48e5600f9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -843,7 +843,7 @@ private void methodProlog(PrintWriter writer, MethodGroup methodGroup) { } private void methodEpilog(PrintWriter writer, MethodGroup methodGroup) { - writer.println(ident(3) + "this.blackhole.purge();"); + writer.println(ident(3) + "this.blackhole.evaporate(\"You'll see Stephen Hawking pole vaulting before this method becomes useful to you.\");"); } private String prefix(String argList) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java index 9187331be..0ec2bb577 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java @@ -281,9 +281,15 @@ public Blackhole(String challengeResponse) { } /** - * Clear internal waste, if any. + * Make any consumed data begone. + * + * WARNING: This method should only be called by the infrastructure code, in clearly understood cases. + * Even though it is public, it is not supposed to be called by users. */ - public void purge() { + public void evaporate(String challengeResponse) { + if (!challengeResponse.equals("You'll see Stephen Hawking pole vaulting before this method becomes useful to you.")) { + throw new IllegalStateException("Can't touch it."); + } obj1 = null; objs1 = null; } From c1994d702a50d91669a51b188c931ea43304f354 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Dec 2016 16:56:49 +0100 Subject: [PATCH 078/342] 7901867: Blackhole.consume(Object) should additionally protect from retaining objects forever --- .../java/org/openjdk/jmh/infra/Blackhole.java | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java index 0ec2bb577..28dfb7a09 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java @@ -26,6 +26,7 @@ import org.openjdk.jmh.util.Utils; +import java.lang.ref.WeakReference; import java.util.Random; /* @@ -73,7 +74,6 @@ abstract class BlackholeL2 extends BlackholeL1 { public float f2; public double d2; public volatile Object obj1; - public volatile Object[] objs1; public volatile BlackholeL2 nullBait = null; public int tlr; public volatile int tlrMask; @@ -83,7 +83,6 @@ public BlackholeL2() { tlr = r.nextInt(); tlrMask = 1; obj1 = new Object(); - objs1 = new Object[]{new Object()}; b1 = (byte) r.nextInt(); b2 = (byte) (b1 + 1); bool1 = r.nextBoolean(); bool2 = !bool1; @@ -221,7 +220,11 @@ public final class Blackhole extends BlackholeL4 { * with infinitesimal probability. Then again, smart compilers may skip from * generating the slow path, and apply the previous logic to constant-fold * the condition to "false". We are warming up the slow-path in the beginning - * to evade that effect. + * to evade that effect. Some caution needs to be exercised not to retain the + * captured objects forever: this is normally achieved by calling evaporate() + * regularly, but we also additionally protect with retaining the object on + * weak reference (contrary to phantom-ref, publishing object still has to + * happen, because reference users might need to discover the object). * * Observation (4) provides us with an opportunity to create a safety net in case * either (1), (2) or (3) fails. This is why Blackhole methods are prohibited from @@ -291,7 +294,6 @@ public void evaporate(String challengeResponse) { throw new IllegalStateException("Can't touch it."); } obj1 = null; - objs1 = null; } /** @@ -304,22 +306,7 @@ public final void consume(Object obj) { int tlr = (this.tlr = (this.tlr * 1664525 + 1013904223)); if ((tlr & tlrMask) == 0) { // SHOULD ALMOST NEVER HAPPEN IN MEASUREMENT - this.obj1 = obj; - this.tlrMask = (tlrMask << 1) + 1; - } - } - - /** - * Consume object. This call provides a side effect preventing JIT to eliminate dependent computations. - * - * @param objs objects to consume. - */ - public final void consume(Object[] objs) { - int tlrMask = this.tlrMask; // volatile read - int tlr = (this.tlr = (this.tlr * 1664525 + 1013904223)); - if ((tlr & tlrMask) == 0) { - // SHOULD ALMOST NEVER HAPPEN IN MEASUREMENT - this.objs1 = objs; + this.obj1 = new WeakReference<>(obj); this.tlrMask = (tlrMask << 1) + 1; } } From dcbc270a3e906b5c714756fda095a3345797dc3a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Dec 2016 17:29:18 +0100 Subject: [PATCH 079/342] Fix accidental regression for absent "objs1" field, and update the passphrase --- .../org/openjdk/jmh/generators/core/BenchmarkGenerator.java | 2 +- jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 48e5600f9..90b50558e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -843,7 +843,7 @@ private void methodProlog(PrintWriter writer, MethodGroup methodGroup) { } private void methodEpilog(PrintWriter writer, MethodGroup methodGroup) { - writer.println(ident(3) + "this.blackhole.evaporate(\"You'll see Stephen Hawking pole vaulting before this method becomes useful to you.\");"); + writer.println(ident(3) + "this.blackhole.evaporate(\"Yes, I am Stephen Hawking, and know a thing or two about black holes.\");"); } private String prefix(String argList) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java index 28dfb7a09..987e28c33 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java @@ -255,7 +255,7 @@ public final class Blackhole extends BlackholeL4 { Utils.check(Blackhole.class, "l1", "l2"); Utils.check(Blackhole.class, "f1", "f2"); Utils.check(Blackhole.class, "d1", "d2"); - Utils.check(Blackhole.class, "obj1", "objs1"); + Utils.check(Blackhole.class, "obj1"); } public Blackhole(String challengeResponse) { @@ -290,8 +290,8 @@ public Blackhole(String challengeResponse) { * Even though it is public, it is not supposed to be called by users. */ public void evaporate(String challengeResponse) { - if (!challengeResponse.equals("You'll see Stephen Hawking pole vaulting before this method becomes useful to you.")) { - throw new IllegalStateException("Can't touch it."); + if (!challengeResponse.equals("Yes, I am Stephen Hawking, and know a thing or two about black holes.")) { + throw new IllegalStateException("Who are you?"); } obj1 = null; } From 5f7aae259fb551dddc3b257740a416d20218a2b5 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Dec 2016 17:50:31 +0100 Subject: [PATCH 080/342] 7901868: "gc" profiler should account for asynchronicity in GC notifications --- .../src/main/java/org/openjdk/jmh/profile/GCProfiler.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java index 8d0cc4346..2ad3d787d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java @@ -325,6 +325,14 @@ public static synchronized void finishChurnProfile() { if (listener == null) { throw new IllegalStateException("Churn profile already stopped"); } + + // Notifications are asynchronous, need to wait a bit before deregistering the listener. + try { + Thread.sleep(500); + } catch (InterruptedException e) { + // do not care + } + for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { try { ((NotificationEmitter) bean).removeNotificationListener(listener); From ca424c143b89b40e7a87a30d1cb02d322eaea071 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Dec 2016 22:19:09 +0100 Subject: [PATCH 081/342] JMH v1.17.3 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 2b88ecbbc..44b3f23b7 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.3 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 2b782ce02..5fd9f405b 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.3 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index d4435596f..37e8f27a2 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.3 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 90714770e..98340c58e 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.3 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 87f9a6b71..3ceb7417e 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 9b4d4eb89..5ff4ff5c7 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 8bad703f3..704975330 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index c7608af12..1a505ecf6 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 9a6c45537..c9995c1cb 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 1c13f284c..d097b3242 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index a88da5151..67d86879e 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 6bab1921a..b2b8026cf 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 5623aa7e2..6ce199f1c 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 6ce4656e2..9a1f9e5ea 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.3 JMH Samples diff --git a/pom.xml b/pom.xml index 8a9b46fb1..02979a85a 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.18-SNAPSHOT + 1.17.3 Java Microbenchmark Harness Parent From 8bbc63cd76ecad37108b86202295dbb6725984e3 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Dec 2016 22:19:15 +0100 Subject: [PATCH 082/342] Added tag 1.17.3 for changeset d4a8ae32b906 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 326b78ce4..97b017394 100644 --- a/.hgtags +++ b/.hgtags @@ -83,3 +83,4 @@ eaf181b4eac282ae20f9cb43ad221cf404a951c0 1.14.1 9df177c239d0962ecdaebebc00d650e52a2f32df 1.17 bf7249ffbfd24a703f18ea90bff379de16182979 1.17.1 d548e3fb7337d8116767e4f669f5a0c901de758b 1.17.2 +d4a8ae32b9063cf17c699455ced1b0d718f4977a 1.17.3 From 45044cb9a19ebef75a707b4a5142f2fd6a2197d7 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 15 Dec 2016 22:19:51 +0100 Subject: [PATCH 083/342] Continue in 1.18-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 44b3f23b7..2b88ecbbc 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.3 + 1.18-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 5fd9f405b..2b782ce02 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.17.3 + 1.18-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 37e8f27a2..d4435596f 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.3 + 1.18-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 98340c58e..90714770e 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.3 + 1.18-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 3ceb7417e..87f9a6b71 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 5ff4ff5c7..9b4d4eb89 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 704975330..8bad703f3 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 1a505ecf6..c7608af12 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index c9995c1cb..9a6c45537 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index d097b3242..1c13f284c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 67d86879e..a88da5151 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index b2b8026cf..6bab1921a 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 6ce199f1c..5623aa7e2 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 9a1f9e5ea..6ce4656e2 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.17.3 + 1.18-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 02979a85a..8a9b46fb1 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.17.3 + 1.18-SNAPSHOT Java Microbenchmark Harness Parent From f56a086a9d121762a288f94490f3038a41fc51b0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 23 Dec 2016 16:41:00 +0100 Subject: [PATCH 084/342] 7901871: JMH runners/profilers leave huge open files until the host VM exits --- .../jmh/profile/AbstractPerfAsmProfiler.java | 25 ++++--- .../jmh/profile/LinuxPerfAsmProfiler.java | 8 +-- .../jmh/profile/WinPerfAsmProfiler.java | 8 +-- .../java/org/openjdk/jmh/runner/Runner.java | 23 ++++-- .../java/org/openjdk/jmh/util/FileUtils.java | 26 +++++++ .../java/org/openjdk/jmh/util/TempFile.java | 47 ++++++++++++ .../org/openjdk/jmh/util/TempFileManager.java | 72 +++++++++++++++++++ 7 files changed, 184 insertions(+), 25 deletions(-) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/util/TempFile.java create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/util/TempFileManager.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 7c2cda53b..651482780 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -68,18 +68,18 @@ public abstract class AbstractPerfAsmProfiler implements ExternalProfiler { private final boolean printCompilationInfo; private final boolean intelSyntax; - protected final String hsLog; - protected final String perfBinData; - protected final String perfParsedData; + protected final TempFile hsLog; + protected final TempFile perfBinData; + protected final TempFile perfParsedData; protected final OptionSet set; private final boolean drawIntraJumps; private final boolean drawInterJumps; protected AbstractPerfAsmProfiler(String initLine, String... events) throws ProfilerException { try { - hsLog = FileUtils.tempFile("hslog").getAbsolutePath(); - perfBinData = FileUtils.tempFile("perfbin").getAbsolutePath(); - perfParsedData = FileUtils.tempFile("perfparsed").getAbsolutePath(); + hsLog = FileUtils.weakTempFile("hslog"); + perfBinData = FileUtils.weakTempFile("perfbin"); + perfParsedData = FileUtils.weakTempFile("perfparsed"); } catch (IOException e) { throw new ProfilerException(e); } @@ -236,7 +236,7 @@ public Collection addJVMOptions(BenchmarkParams params) { opts.addAll(Arrays.asList( "-XX:+UnlockDiagnosticVMOptions", "-XX:+LogCompilation", - "-XX:LogFile=" + hsLog, + "-XX:LogFile=" + hsLog.getAbsolutePath(), "-XX:+PrintAssembly")); if (!skipInterpreter) { @@ -272,6 +272,11 @@ public void beforeTrial(BenchmarkParams params) { public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { PerfResult result = processAssembly(br, stdOut, stdErr); + // we know these are not needed anymore, proactively delete + hsLog.delete(); + perfBinData.delete(); + perfParsedData.delete(); + return Collections.singleton(result); } @@ -320,7 +325,7 @@ private PerfResult processAssembly(BenchmarkResult br, File stdOut, File stdErr) * 2. Read out PrintAssembly output */ - Assembly assembly = readAssembly(new File(hsLog)); + Assembly assembly = readAssembly(hsLog.file()); if (assembly.size() > 0) { pw.printf("PrintAssembly processed: %d total address lines.%n", assembly.size()); } else if (skipAssembly) { @@ -584,7 +589,7 @@ public int compare(Region o1, Region o2) { savePerfOutputTo + "/" + br.getParams().id() + ".perf" : savePerfOutputToFile; try { - FileUtils.copy(perfParsedData, target); + FileUtils.copy(perfParsedData.getAbsolutePath(), target); pw.println("Perf output saved to " + target); } catch (IOException e) { pw.println("Unable to save perf output to " + target); @@ -599,7 +604,7 @@ public int compare(Region o1, Region o2) { savePerfBinTo + "/" + br.getParams().id() + perfBinaryExtension() : savePerfBinFile; try { - FileUtils.copy(perfBinData, target); + FileUtils.copy(perfBinData.getAbsolutePath(), target); pw.println("Perf binary output saved to " + target); } catch (IOException e) { pw.println("Unable to save perf binary output to " + target); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index e41798ebe..1c4a1fef9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -67,7 +67,7 @@ protected void addMyOptions(OptionParser parser) { @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { - return Arrays.asList(PerfSupport.PERF_EXEC, "record", "--freq", String.valueOf(sampleFrequency), "--event", Utils.join(events, ","), "--output", perfBinData); + return Arrays.asList(PerfSupport.PERF_EXEC, "record", "--freq", String.valueOf(sampleFrequency), "--event", Utils.join(events, ","), "--output", perfBinData.getAbsolutePath()); } @Override @@ -77,8 +77,8 @@ public String getDescription() { @Override protected void parseEvents() { - try (FileOutputStream fos = new FileOutputStream(perfParsedData)) { - ProcessBuilder pb = new ProcessBuilder(PerfSupport.PERF_EXEC, "script", "--fields", "time,event,ip,sym,dso", "--input", perfBinData); + try (FileOutputStream fos = new FileOutputStream(perfParsedData.file())) { + ProcessBuilder pb = new ProcessBuilder(PerfSupport.PERF_EXEC, "script", "--fields", "time,event,ip,sym,dso", "--input", perfBinData.getAbsolutePath()); Process p = pb.start(); // drain streams, else we might lock up @@ -102,7 +102,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { double readFrom = skipMs / 1000D; double readTo = (skipMs + lenMs) / 1000D; - try (FileReader fr = new FileReader(perfParsedData); + try (FileReader fr = new FileReader(perfParsedData.file()); BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index 1aef0f9b1..c07ddbfb5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -146,21 +146,21 @@ public String getDescription() { @Override protected void parseEvents() { // 1. Stop profiling by calling xperf dumper. - Collection errs = Utils.tryWith(path, "-d", perfBinData); + Collection errs = Utils.tryWith(path, "-d", perfBinData.getAbsolutePath()); if (!errs.isEmpty()) throw new IllegalStateException("Failed to stop xperf: " + errs); // 2. Convert binary data to text form. try { - ProcessBuilder pb = new ProcessBuilder(path, "-i", perfBinData, "-symbols", "-a", "dumper"); + ProcessBuilder pb = new ProcessBuilder(path, "-i", perfBinData.getAbsolutePath(), "-symbols", "-a", "dumper"); if (symbolDir != null) { pb.environment().put("_NT_SYMBOL_PATH", symbolDir); } Process p = pb.start(); - FileOutputStream fos = new FileOutputStream(perfParsedData); + FileOutputStream fos = new FileOutputStream(perfParsedData.file()); InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), fos); InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), fos); @@ -182,7 +182,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { double readFrom = skipMs / 1000D; double readTo = (skipMs + lenMs) / 1000D; - try (FileReader fr = new FileReader(perfParsedData); + try (FileReader fr = new FileReader(perfParsedData.file()); BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index d14528016..9f7d656c6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -623,13 +623,17 @@ private Multimap runSeparate(ActionPlan action etaBeforeBenchmark(); out.println("# Warmup Fork: " + (i + 1) + " of " + warmupForkCount); - File stdErr = FileUtils.tempFile("stderr"); - File stdOut = FileUtils.tempFile("stdout"); + TempFile stdErr = FileUtils.weakTempFile("stderr"); + TempFile stdOut = FileUtils.weakTempFile("stdout"); - doFork(server, forkedString, stdOut, stdErr, printOut, printErr); + doFork(server, forkedString, stdOut.file(), stdErr.file(), printOut, printErr); etaAfterBenchmark(params); out.println(""); + + // we know these are not needed anymore, proactively delete + stdErr.delete(); + stdOut.delete(); } } @@ -640,8 +644,8 @@ private Multimap runSeparate(ActionPlan action etaBeforeBenchmark(); out.println("# Fork: " + (i + 1) + " of " + forkCount); - File stdErr = FileUtils.tempFile("stderr"); - File stdOut = FileUtils.tempFile("stdout"); + TempFile stdErr = FileUtils.weakTempFile("stderr"); + TempFile stdOut = FileUtils.weakTempFile("stdout"); if (!profilers.isEmpty()) { out.print("# Preparing profilers: "); @@ -659,7 +663,7 @@ private Multimap runSeparate(ActionPlan action } } - List result = doFork(server, forkedString, stdOut, stdErr, printOut, printErr); + List result = doFork(server, forkedString, stdOut.file(), stdErr.file(), printOut, printErr); if (!result.isEmpty()) { long pid = server.getClientPid(); @@ -670,7 +674,7 @@ private Multimap runSeparate(ActionPlan action out.print("# Processing profiler results: "); for (ExternalProfiler profiler : profilersRev) { out.print(profiler.getClass().getSimpleName() + " "); - for (Result profR : profiler.afterTrial(br, pid, stdOut, stdErr)) { + for (Result profR : profiler.afterTrial(br, pid, stdOut.file(), stdErr.file())) { br.addBenchmarkResult(profR); } } @@ -682,6 +686,10 @@ private Multimap runSeparate(ActionPlan action etaAfterBenchmark(params); out.println(""); + + // we know these are not needed anymore, proactively delete + stdOut.delete(); + stdErr.delete(); } out.endBenchmark(new RunResult(params, results.get(params)).getAggregatedResult()); @@ -699,6 +707,7 @@ private Multimap runSeparate(ActionPlan action if (server != null) { server.terminate(); } + FileUtils.purgeTemps(); } return results; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java index b81c168a9..55df03d3f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java @@ -39,6 +39,32 @@ private FileUtils() { } + static final TempFileManager TEMP_FILE_MANAGER = new TempFileManager(); + + /** + * Creates the temp file, and retains it as long as the reference to it + * is reachable. + * + * @param suffix suffix + * @return temp file + * @throws IOException + */ + public static TempFile weakTempFile(String suffix) throws IOException { + return TEMP_FILE_MANAGER.create(suffix); + } + + public static void purgeTemps() { + TEMP_FILE_MANAGER.purge(); + } + + /** + * Creates the temp file with given suffix. The file would be removed + * on JVM exit, or when caller deletes the file itself. + * + * @param suffix suffix + * @return temporary file + * @throws IOException + */ public static File tempFile(String suffix) throws IOException { File file = File.createTempFile("jmh", suffix); file.deleteOnExit(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/TempFile.java b/jmh-core/src/main/java/org/openjdk/jmh/util/TempFile.java new file mode 100644 index 000000000..58840408c --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/TempFile.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, Red Hat Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.util; + +import java.io.*; + +public class TempFile { + private final File file; + + public TempFile(File file) { + this.file = file; + } + + public void delete() { + file.delete(); + } + + public String getAbsolutePath() { + return file.getAbsolutePath(); + } + + public File file() { + return file; + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/TempFileManager.java b/jmh-core/src/main/java/org/openjdk/jmh/util/TempFileManager.java new file mode 100644 index 000000000..ea9aa7123 --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/TempFileManager.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2016, Red Hat Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.util; + +import java.io.File; +import java.io.IOException; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.HashSet; +import java.util.Set; + +public class TempFileManager { + + private final ReferenceQueue rq; + private final Set refs; + + public TempFileManager() { + rq = new ReferenceQueue<>(); + refs = new HashSet<>(); + } + + public TempFile create(String suffix) throws IOException { + purge(); + File file = File.createTempFile("jmh", suffix); + file.deleteOnExit(); + TempFile tf = new TempFile(file); + refs.add(new TempFileReference(tf, rq)); + return tf; + } + + public void purge() { + TempFileReference ref; + while ((ref = (TempFileReference) rq.poll()) != null) { + if (ref.file != null) { + ref.file.delete(); + } + refs.remove(ref); + } + } + + private static class TempFileReference extends WeakReference { + final File file; + + TempFileReference(TempFile referent, ReferenceQueue q) { + super(referent, q); + file = referent.file(); + } + } + +} From 774b6beef9875146a0e05dbf089d8bba1f496f08 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 23 Dec 2016 16:48:55 +0100 Subject: [PATCH 085/342] 7901872: Printing only the result "label" in the log is confusing --- .../java/org/openjdk/jmh/runner/format/TextReportFormat.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index 876c017e3..e2fdcf646 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -185,14 +185,14 @@ public void endBenchmark(BenchmarkResult result) { Result r = result.getPrimaryResult(); String s = r.extendedInfo(); if (!s.trim().isEmpty()) { - out.println("Result \"" + r.getLabel() + "\":"); + out.println("Result \"" + result.getParams().getBenchmark() + "\":"); out.println(s); } } for (Result r : result.getSecondaryResults().values()) { String s = r.extendedInfo(); if (!s.trim().isEmpty()) { - out.println("Secondary result \"" + r.getLabel() + "\":"); + out.println("Secondary result \"" + result.getParams().getBenchmark() + ":" + r.getLabel() + "\":"); out.println(s); } } From fed7b32b13a169171092614da70b6b3384bb9b3a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 23 Dec 2016 19:01:51 +0100 Subject: [PATCH 086/342] 7901873: perfnorm: rehash collected counters --- .../java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index 5bb581609..826c30049 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -47,13 +47,11 @@ public class LinuxPerfNormProfiler implements ExternalProfiler { private static final String[] interestingEvents = new String[]{ "cycles", "instructions", "branches", "branch-misses", - "bus-cycles", "ref-cycles", - "context-switches", "cpu-migrations", - "page-faults", "minor-faults", "major-faults", "alignment-faults", "emulation-faults", "L1-dcache-loads", "L1-dcache-load-misses", "L1-dcache-stores", "L1-dcache-store-misses", "L1-icache-loads", "L1-icache-load-misses", - "LLC-loads", "LLC-stores", + "LLC-loads", "LLC-load-misses", + "LLC-stores", "LLC-store-misses", "dTLB-loads", "dTLB-load-misses", "dTLB-stores", "dTLB-store-misses", "iTLB-loads", "iTLB-load-misses", From eb0358c35fbe697248694275e9cca229094ae686 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 18 Jan 2017 14:37:41 +0100 Subject: [PATCH 087/342] JMH v1.17.4 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 2b88ecbbc..3e445901b 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.4 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 2b782ce02..6b913f139 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.4 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index d4435596f..f473870e9 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.4 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 90714770e..5af18595f 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.4 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 87f9a6b71..dc8f59fc0 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 9b4d4eb89..b5abd38a4 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 8bad703f3..1203efca0 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index c7608af12..f1ce3af21 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 9a6c45537..b9e481148 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 1c13f284c..fe835410c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index a88da5151..0cf959771 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 6bab1921a..f92a287e5 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 5623aa7e2..3946476ec 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 6ce4656e2..100c949f3 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.4 JMH Samples diff --git a/pom.xml b/pom.xml index 8a9b46fb1..9ad3b53c9 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.18-SNAPSHOT + 1.17.4 Java Microbenchmark Harness Parent From c870c4941b7b79b6d1ebb92f67cad931d0df8472 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 18 Jan 2017 14:37:49 +0100 Subject: [PATCH 088/342] Added tag 1.17.4 for changeset 3b9b9cd865e3 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 97b017394..26a040a9c 100644 --- a/.hgtags +++ b/.hgtags @@ -84,3 +84,4 @@ eaf181b4eac282ae20f9cb43ad221cf404a951c0 1.14.1 bf7249ffbfd24a703f18ea90bff379de16182979 1.17.1 d548e3fb7337d8116767e4f669f5a0c901de758b 1.17.2 d4a8ae32b9063cf17c699455ced1b0d718f4977a 1.17.3 +3b9b9cd865e38cf19d08687754ff99eb982e662f 1.17.4 From 5a45b4db7e66049fb3d619c189bd9a86717648fc Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 18 Jan 2017 14:38:04 +0100 Subject: [PATCH 089/342] Continue in 1.18-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 3e445901b..2b88ecbbc 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.4 + 1.18-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 6b913f139..2b782ce02 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.17.4 + 1.18-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index f473870e9..d4435596f 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.4 + 1.18-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 5af18595f..90714770e 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.4 + 1.18-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index dc8f59fc0..87f9a6b71 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index b5abd38a4..9b4d4eb89 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 1203efca0..8bad703f3 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index f1ce3af21..c7608af12 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index b9e481148..9a6c45537 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index fe835410c..1c13f284c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 0cf959771..a88da5151 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index f92a287e5..6bab1921a 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 3946476ec..5623aa7e2 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 100c949f3..6ce4656e2 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.17.4 + 1.18-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 9ad3b53c9..8a9b46fb1 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.17.4 + 1.18-SNAPSHOT Java Microbenchmark Harness Parent From db6ec8a796f8461e65e17d202b6d2b052c0db315 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 24 Feb 2017 13:48:24 +0100 Subject: [PATCH 090/342] 7901904: perfasm should handle the absence of events gracefully --- .../openjdk/jmh/profile/AbstractPerfAsmProfiler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 651482780..becc19637 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -672,7 +672,7 @@ List makeRegions(Assembly asms, PerfEvents events) { List regions = new ArrayList<>(); SortedSet allAddrs = events.getAllAddresses(); - for (Interval intv : figureHotIntervals(allAddrs, allAddrs.first(), allAddrs.last())) { + for (Interval intv : figureHotIntervals(allAddrs)) { SortedSet eventfulAddrs = allAddrs.subSet(intv.src, intv.dst + 1); List regionLines = asms.getLines(intv.src, intv.dst, printMargin); @@ -705,10 +705,12 @@ List makeRegions(Assembly asms, PerfEvents events) { } - private List figureHotIntervals(SortedSet allAddrs, long from, long to) { - List intervals = new ArrayList<>(); - SortedSet addrs = allAddrs.subSet(from, to); + private List figureHotIntervals(SortedSet addrs) { + if (addrs.isEmpty()) { + return Collections.emptyList(); + } + List intervals = new ArrayList<>(); long begAddr = addrs.first(); long lastAddr = addrs.first(); for (long addr : addrs) { From 4232399d4fe932b9b61e7a6eef0dad2cb55d11a4 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 24 Feb 2017 17:07:45 +0100 Subject: [PATCH 091/342] 7901905: perfasm profiler handles event modifiers like "cycles:u" incorrectly --- .../jmh/profile/LinuxPerfAsmProfiler.java | 185 +++++++++++++----- .../openjdk/jmh/profile/PerfParseTest.java | 87 ++++++++ 2 files changed, 220 insertions(+), 52 deletions(-) create mode 100644 jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index 1c4a1fef9..8f5390c1d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -97,6 +97,122 @@ protected void parseEvents() { } } + static PerfLine parsePerfLine(String line) { + if (line.startsWith("#")) { + return null; + } + + // Demangled symbol names can contain spaces, so we need to parse the lines + // in a complicated manner. Using regexps will not solve this without sacrificing + // lots of performance, so we need to get tricky. + // + // We are forcing perf to print: time event ip sym dso + // + // 328992.235251: instructions: 7fa85da61a09 match_symbol (/lib/x86_64-linux-gnu/ld-2.23.so) + // + + // Remove excess spaces + int lastLength = -1; + while (line.length() != lastLength) { + lastLength = line.length(); + line = line.replace(" ", " "); + } + + // Chomp the time + int timeIdx = line.indexOf(": "); + if (timeIdx == -1) return null; + String strTime = line.substring(0, timeIdx); + line = line.substring(timeIdx + 2); + + double time; + try { + time = Double.valueOf(strTime); + } catch (NumberFormatException e) { + return null; + } + + // Chomp the library, handling spaces properly: + int libIdx = line.lastIndexOf(" ("); + if (libIdx == -1) return null; + String lib = line.substring(libIdx); + lib = lib.substring(lib.lastIndexOf("/") + 1, lib.length()).replace("(", "").replace(")", ""); + line = line.substring(0, libIdx); + + // Chomp the event name: + int evIdx = line.indexOf(": "); + if (evIdx == -1) return null; + String evName = line.substring(0, evIdx); + int tagIdx = evName.lastIndexOf(":"); + if (tagIdx != -1) { + evName = evName.substring(0, tagIdx); + } + line = line.substring(evIdx + 2); + + // Chomp the addr: + int addrIdx = line.indexOf(" "); + if (addrIdx == -1) return null; + String strAddr = line.substring(0, addrIdx); + line = line.substring(addrIdx + 1); + + // Try to parse the positive address lightly first. + // If that fails, try to parse the negative address. + // If that fails as well, then address is unresolvable. + long addr; + try { + addr = Long.valueOf(strAddr, 16); + } catch (NumberFormatException e) { + try { + addr = new BigInteger(strAddr, 16).longValue(); + if (addr < 0L && lib.contains("unknown")) { + lib = "kernel"; + } + } catch (NumberFormatException e1) { + addr = 0L; + } + } + + // Whatever is left is symbol: + String symbol = line; + + return new PerfLine(time, evName, addr, symbol, lib); + } + + static class PerfLine { + final double time; + final String event; + final long addr; + final String symbol; + final String lib; + + public PerfLine(double time, String event, long addr, String symbol, String lib) { + this.time = time; + this.event = event; + this.addr = addr; + this.symbol = symbol; + this.lib = lib; + } + + public double time() { + return time; + } + + public String eventName() { + return event; + } + + public long addr() { + return addr; + } + + public String symbol() { + return symbol; + } + + public String lib() { + return lib; + } + } + @Override protected PerfEvents readEvents(double skipMs, double lenMs) { double readFrom = skipMs / 1000D; @@ -114,68 +230,33 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { Double startTime = null; - // Demangled symbol names can contain spaces, so we need to parse the lines - // in a complicated manner. Using regexps will not solve this without sacrificing - // lots of performance, so we need to get tricky, and merge the symbol names back - // after splitting. - // - // We are forcing perf to print: time event ip sym dso - // - String line; while ((line = reader.readLine()) != null) { - if (line.startsWith("#")) continue; - - String[] elems = line.trim().split("[ ]+"); - - if (elems.length < 4) continue; - - String strTime = elems[0].replace(":", ""); - String evName = elems[1].replace(":", ""); - String strAddr = elems[2]; - String symbol = Utils.join(Arrays.copyOfRange(elems, 3, elems.length - 1), " "); - String lib = elems[elems.length - 1]; - lib = lib.substring(lib.lastIndexOf("/") + 1, lib.length()).replace("(", "").replace(")", ""); - - try { - Double time = Double.valueOf(strTime); - if (startTime == null) { - startTime = time; - } else { - if (time - startTime < readFrom) { - continue; - } - if (time - startTime > readTo) { - continue; - } - } - } catch (NumberFormatException e) { - // misformatted line, no timestamp + PerfLine perfline = parsePerfLine(line); + if (perfline == null) { continue; } - Multiset evs = events.get(evName); + if (startTime == null) { + startTime = perfline.time(); + } else { + if (perfline.time() - startTime < readFrom) { + continue; + } + if (perfline.time() - startTime > readTo) { + continue; + } + } + + Multiset evs = events.get(perfline.eventName()); if (evs == null) { // we are not prepared to handle this event, skip continue; } - // Try to parse the positive address lightly first. - // If that fails, try to parse the negative address. - // If that fails as well, then address is unresolvable. - Long addr; - try { - addr = Long.valueOf(strAddr, 16); - } catch (NumberFormatException e) { - try { - addr = new BigInteger(strAddr, 16).longValue(); - } catch (NumberFormatException e1) { - addr = 0L; - } - } - - evs.add(addr); - methods.put(dedup.dedup(MethodDesc.nativeMethod(symbol, lib)), addr); + evs.add(perfline.addr()); + MethodDesc desc = dedup.dedup(MethodDesc.nativeMethod(perfline.symbol(), perfline.lib())); + methods.put(desc, perfline.addr()); } IntervalMap methodMap = new IntervalMap<>(); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java b/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java new file mode 100644 index 000000000..86aac3f56 --- /dev/null +++ b/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2016, Red Hat Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.profile; + +import junit.framework.Assert; +import org.junit.Test; + +public class PerfParseTest { + + @Test + public void parsePerf_4_4() { + String[] lines = new String[] { + "328650.667569: instructions: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", + "328650.667569: instructions: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/with spaces/libjvm.so)" + }; + + for (String line : lines) { + LinuxPerfAsmProfiler.PerfLine perfLine = LinuxPerfAsmProfiler.parsePerfLine(line); + Assert.assertEquals(328650.667569D, perfLine.time()); + Assert.assertEquals("instructions", perfLine.eventName()); + Assert.assertEquals(0x7f82b6a8beb4L, perfLine.addr()); + Assert.assertEquals("ConstantPoolCache::allocate", perfLine.symbol()); + Assert.assertEquals("libjvm.so", perfLine.lib()); + } + } + + @Test + public void parseRaggedSymbols() { + String[] lines = new String[] { + "328650.667569: instructions: 7f82b6a8beb4 ConstantPoolCache::allocate(Thread* thr) (/somewhere/on/my/filesystem/libjvm.so)", + }; + + for (String line : lines) { + LinuxPerfAsmProfiler.PerfLine perfLine = LinuxPerfAsmProfiler.parsePerfLine(line); + Assert.assertEquals(328650.667569D, perfLine.time()); + Assert.assertEquals("instructions", perfLine.eventName()); + Assert.assertEquals(0x7f82b6a8beb4L, perfLine.addr()); + Assert.assertEquals("ConstantPoolCache::allocate(Thread* thr)", perfLine.symbol()); + Assert.assertEquals("libjvm.so", perfLine.lib()); + } + } + + @Test + public void parseOptionalTag() { + String[] lines = new String[] { + "328650.667569: instructions:u: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", + "328650.667569: instructions:uk: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", + "328650.667569: instructions:k: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", + "328650.667569: instructions:HG: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", + "328650.667569: instructions:H: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)", + "328650.667569: instructions:: 7f82b6a8beb4 ConstantPoolCache::allocate (/somewhere/on/my/filesystem/libjvm.so)" + }; + for (String line : lines) { + LinuxPerfAsmProfiler.PerfLine perfLine = LinuxPerfAsmProfiler.parsePerfLine(line); + + Assert.assertEquals(328650.667569D, perfLine.time()); + Assert.assertEquals("instructions", perfLine.eventName()); + Assert.assertEquals(0x7f82b6a8beb4L, perfLine.addr()); + Assert.assertEquals("ConstantPoolCache::allocate", perfLine.symbol()); + Assert.assertEquals("libjvm.so", perfLine.lib()); + } + } + + +} From 22ca8d5fd6058f1972de150e3f0b4ae205a5011a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 24 Feb 2017 21:43:42 +0100 Subject: [PATCH 092/342] JMH v1.17.5 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 2b88ecbbc..0c319e06c 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.5 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 2b782ce02..4d31d6c71 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.5 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index d4435596f..13dc238fd 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.5 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 90714770e..112601278 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.17.5 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 87f9a6b71..eb87beafb 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 9b4d4eb89..704dd5974 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 8bad703f3..1b4312829 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index c7608af12..371c03797 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 9a6c45537..287dfd14e 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 1c13f284c..5d43dfe56 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index a88da5151..9e71e1cef 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 6bab1921a..5564187b1 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 5623aa7e2..f6a302534 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 6ce4656e2..fa1872226 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.17.5 JMH Samples diff --git a/pom.xml b/pom.xml index 8a9b46fb1..ae6b6e566 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.18-SNAPSHOT + 1.17.5 Java Microbenchmark Harness Parent From 5d1d64d63b4f46ff21e8d3452adcbf2c751b9ede Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 24 Feb 2017 21:43:46 +0100 Subject: [PATCH 093/342] Added tag 1.17.5 for changeset 5e3781c05e28 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 26a040a9c..aedaa0683 100644 --- a/.hgtags +++ b/.hgtags @@ -85,3 +85,4 @@ bf7249ffbfd24a703f18ea90bff379de16182979 1.17.1 d548e3fb7337d8116767e4f669f5a0c901de758b 1.17.2 d4a8ae32b9063cf17c699455ced1b0d718f4977a 1.17.3 3b9b9cd865e38cf19d08687754ff99eb982e662f 1.17.4 +5e3781c05e283dd4f5a71503e7cd7b9b151e5484 1.17.5 From b3e8594923cd21a6d1c14b7971561d89b3f241b5 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 24 Feb 2017 21:43:59 +0100 Subject: [PATCH 094/342] Continue in 1.18-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 0c319e06c..2b88ecbbc 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.5 + 1.18-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 4d31d6c71..2b782ce02 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.17.5 + 1.18-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 13dc238fd..d4435596f 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.5 + 1.18-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 112601278..90714770e 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.17.5 + 1.18-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index eb87beafb..87f9a6b71 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 704dd5974..9b4d4eb89 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 1b4312829..8bad703f3 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 371c03797..c7608af12 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 287dfd14e..9a6c45537 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 5d43dfe56..1c13f284c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 9e71e1cef..a88da5151 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 5564187b1..6bab1921a 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index f6a302534..5623aa7e2 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index fa1872226..6ce4656e2 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.17.5 + 1.18-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index ae6b6e566..8a9b46fb1 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.17.5 + 1.18-SNAPSHOT Java Microbenchmark Harness Parent From ddab8d6d201f43c9d26d37e35acc61415aca9331 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 10 Mar 2017 22:47:33 +0100 Subject: [PATCH 095/342] 7901910: Non-ASCII @Param values get garbled on non-UTF-8 platform encoding --- .../jmh/ct/InMemoryGeneratorDestination.java | 29 ++--- .../openjdk/jmh/it/params/UTF8ParamsTest.java | 71 ++++++++++ .../generators/core/BenchmarkGenerator.java | 38 ++---- .../core/CompilerControlPlugin.java | 7 +- .../core/FileSystemDestination.java | 15 +-- .../generators/core/GeneratorDestination.java | 20 ++- .../jmh/runner/AbstractResourceReader.java | 5 +- .../org/openjdk/jmh/runner/BenchmarkList.java | 25 +++- .../jmh/runner/TestBenchmarkListEncoding.java | 121 ++++++++++++++++++ .../annotations/APGeneratorDestinaton.java | 12 +- 10 files changed, 264 insertions(+), 79 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java create mode 100644 jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListEncoding.java diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java index c5d403272..5ca2bd53d 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java @@ -27,12 +27,7 @@ import org.openjdk.jmh.generators.core.GeneratorDestination; import org.openjdk.jmh.generators.core.MetadataInfo; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; +import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -45,22 +40,22 @@ public class InMemoryGeneratorDestination implements GeneratorDestination { private final List infos = new ArrayList<>(); private final Map classBodies = new HashMap<>(); - private final Map resourceBodies = new HashMap<>(); + private final Map resourceBodies = new HashMap<>(); @Override - public Writer newResource(String resourcePath) throws IOException { - StringWriter sw = new StringWriter(); + public OutputStream newResource(String resourcePath) throws IOException { + ByteArrayOutputStream sw = new ByteArrayOutputStream(); resourceBodies.put(resourcePath, sw); - return new PrintWriter(sw, true); + return sw; } @Override - public Reader getResource(String resourcePath) throws IOException { - StringWriter sw = resourceBodies.get(resourcePath); + public InputStream getResource(String resourcePath) throws IOException { + ByteArrayOutputStream sw = resourceBodies.get(resourcePath); if (sw == null) { throw new IOException("Does not exist: " + resourcePath); } - return new StringReader(sw.toString()); + return new ByteArrayInputStream(sw.toByteArray()); } @Override @@ -126,8 +121,12 @@ public Map getClasses() { public Map getResources() { Map result = new HashMap<>(); - for (Map.Entry e : resourceBodies.entrySet()) { - result.put(e.getKey(), e.getValue().toString()); + for (Map.Entry e : resourceBodies.entrySet()) { + try { + result.put(e.getKey(), e.getValue().toString("UTF-8")); + } catch (UnsupportedEncodingException e1) { + e1.printStackTrace(); + } } return result; } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java new file mode 100644 index 000000000..48efd907d --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.params; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.Locale; +import java.util.concurrent.TimeUnit; + +@State(Scope.Benchmark) +public class UTF8ParamsTest { + + @Param("\uff11000") + String value; + + @Benchmark + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(1) + public void test() { + Fixtures.work(); + Assert.assertEquals("\uff11000", value); + } + + @Test + public void vals() throws RunnerException { + Locale prev = Locale.getDefault(); + Locale.setDefault(Locale.ROOT); + + try { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .build(); + + new Runner(opts).run(); + } finally { + Locale.setDefault(prev); + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 90b50558e..937641c7c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -29,14 +29,11 @@ import org.openjdk.jmh.results.*; import org.openjdk.jmh.runner.*; import org.openjdk.jmh.runner.Defaults; -import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.HashMultimap; import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.SampleBuffer; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.Reader; +import java.io.*; import java.lang.reflect.Field; import java.util.*; import java.util.concurrent.TimeUnit; @@ -131,12 +128,13 @@ public void complete(GeneratorSource source, GeneratorDestination destination) { // to detect removed @Benchmark entries. To do so, we are overwriting all benchmark // records that belong to a current compilation unit. Multimap entriesByQName = new HashMultimap<>(); - try { - for (String line : readBenchmarkList(destination)) { - BenchmarkListEntry br = new BenchmarkListEntry(line); - entries.add(br); - entriesByQName.put(br.getUserClassQName(), br); + try (InputStream stream = destination.getResource(BenchmarkList.BENCHMARK_LIST.substring(1))) { + for (BenchmarkListEntry ble : BenchmarkList.readBenchmarkList(stream)) { + entries.add(ble); + entriesByQName.put(ble.getUserClassQName(), ble); } + } catch (IOException e) { + // okay, move on } catch (UnsupportedOperationException e) { destination.printError("Unable to read the existing benchmark list.", e); } @@ -185,26 +183,8 @@ public void complete(GeneratorSource source, GeneratorDestination destination) { } } - writeBenchmarkList(destination, entries); - } - - private Collection readBenchmarkList(GeneratorDestination destination) { - String list = BenchmarkList.BENCHMARK_LIST.substring(1); - try (Reader reader = destination.getResource(list)) { - return FileUtils.readAllLines(reader); - } catch (IOException e) { - // okay, move on - } - return Collections.emptyList(); - } - - private void writeBenchmarkList(GeneratorDestination destination, Collection entries) { - String list = BenchmarkList.BENCHMARK_LIST.substring(1); - try (PrintWriter writer = new PrintWriter(destination.newResource(list))) { - // Write out the complete benchmark list - for (BenchmarkListEntry entry : entries) { - writer.println(entry.toLine()); - } + try (OutputStream stream = destination.newResource(BenchmarkList.BENCHMARK_LIST.substring(1))) { + BenchmarkList.writeBenchmarkList(stream, entries); } catch (IOException ex) { destination.printError("Error writing benchmark list", ex); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java index ede3a23bf..73975bc5a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/CompilerControlPlugin.java @@ -28,7 +28,10 @@ import org.openjdk.jmh.runner.CompilerHints; import java.io.IOException; +import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Writer; +import java.nio.charset.StandardCharsets; import java.util.Comparator; import java.util.Set; import java.util.SortedSet; @@ -97,8 +100,8 @@ public void process(GeneratorSource source, GeneratorDestination destination) { } public void finish(GeneratorSource source, GeneratorDestination destination) { - try { - PrintWriter writer = new PrintWriter(destination.newResource(CompilerHints.LIST.substring(1))); + try (Writer w = new OutputStreamWriter(destination.newResource(CompilerHints.LIST.substring(1)), StandardCharsets.UTF_8)){ + PrintWriter writer = new PrintWriter(w); for (String line : lines) { writer.println(line); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java index 7333a6b59..5dcbc0ab9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java @@ -24,12 +24,7 @@ */ package org.openjdk.jmh.generators.core; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; +import java.io.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -49,23 +44,23 @@ public FileSystemDestination(File resourceDir, File sourceDir) { } @Override - public Writer newResource(String resourcePath) throws IOException { + public OutputStream newResource(String resourcePath) throws IOException { String pathName = resourceDir.getAbsolutePath() + "/" + resourcePath; File p = new File(pathName.substring(0, pathName.lastIndexOf("/"))); if (!p.mkdirs() && !p.isDirectory()) { throw new IOException("Unable to create " + p.getAbsolutePath()); } - return new FileWriter(new File(pathName)); + return new FileOutputStream(new File(pathName)); } @Override - public Reader getResource(String resourcePath) throws IOException { + public InputStream getResource(String resourcePath) throws IOException { String pathName = resourceDir.getAbsolutePath() + "/" + resourcePath; File p = new File(pathName.substring(0, pathName.lastIndexOf("/"))); if (!p.isFile() && !p.exists()) { throw new IOException("Unable to open " + pathName); } - return new FileReader(new File(pathName)); + return new FileInputStream(new File(pathName)); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/GeneratorDestination.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/GeneratorDestination.java index 35778d66a..2b4af3e22 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/GeneratorDestination.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/GeneratorDestination.java @@ -24,9 +24,7 @@ */ package org.openjdk.jmh.generators.core; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; +import java.io.*; /** * Generator destination. @@ -36,24 +34,24 @@ public interface GeneratorDestination { /** - * Returns the Writer for the given resource. - * Callers are responsible for closing Writers. + * Returns the stream for the given resource. + * Callers are responsible for closing streams. * * @param resourcePath resource path - * @return writer usable to write the resource + * @return output stream to write the resource to. * @throws java.io.IOException if something wacked happens */ - Writer newResource(String resourcePath) throws IOException; + OutputStream newResource(String resourcePath) throws IOException; /** - * Returns the Reader for the given resource. - * Callers are responsible for closing Readers. + * Returns the stream for the given resource. + * Callers are responsible for closing streams. * * @param resourcePath resource path - * @return reader usable to read the resource + * @return stream usable to read the resource * @throws java.io.IOException if something wacked happens */ - Reader getResource(String resourcePath) throws IOException; + InputStream getResource(String resourcePath) throws IOException; /** * Returns the Writer for the given class. diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java index 28db4420c..6484003a1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/AbstractResourceReader.java @@ -26,6 +26,7 @@ import java.io.*; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; @@ -55,7 +56,7 @@ protected List getReaders() { if (file != null) { try { - return Collections.singletonList(new FileReader(file)); + return Collections.singletonList(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); } catch (FileNotFoundException e) { throw new RuntimeException("ERROR: Could not find resource", e); } @@ -80,7 +81,7 @@ protected List getReaders() { while (urls.hasMoreElements()) { url = urls.nextElement(); InputStream stream = url.openStream(); - readers.add(new InputStreamReader(stream)); + readers.add(new InputStreamReader(stream, StandardCharsets.UTF_8)); } } catch (IOException e) { for (Reader r : readers) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java index 0fbff80ae..79a45572b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java @@ -25,10 +25,10 @@ package org.openjdk.jmh.runner; import org.openjdk.jmh.runner.format.OutputFormat; +import org.openjdk.jmh.util.FileUtils; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.Reader; +import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Pattern; @@ -56,6 +56,25 @@ public static BenchmarkList fromString(String strings) { return new BenchmarkList(null, null, strings); } + public static Collection readBenchmarkList(InputStream stream) throws IOException { + try (Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { + Collection entries = new ArrayList<>(); + for (String line : FileUtils.readAllLines(reader)) { + BenchmarkListEntry ble = new BenchmarkListEntry(line); + entries.add(ble); + } + return entries; + } + } + + public static void writeBenchmarkList(OutputStream stream, Collection entries) throws IOException { + try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8))) { + for (BenchmarkListEntry entry : entries) { + writer.println(entry.toLine()); + } + } + } + private BenchmarkList(String file, String resource, String strings) { super(file, resource, strings); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListEncoding.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListEncoding.java new file mode 100644 index 000000000..69ffd1263 --- /dev/null +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListEncoding.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2017, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.runner; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.runner.options.TimeValue; +import org.openjdk.jmh.util.Optional; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.nio.charset.Charset; +import java.util.*; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; + +public class TestBenchmarkListEncoding { + + private static BenchmarkListEntry stub(String userClassQName, String generatedClassQName, String method, Mode mode) { + BenchmarkListEntry br = new BenchmarkListEntry( + userClassQName, + generatedClassQName, + method, + mode, + Optional.none(), + new int[]{1}, + Optional.>none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.>none(), + Optional.>none(), + Optional.>none(), + Optional.>none(), + Optional.none(), + Optional.none(), + Optional.none() + ); + return br; + } + + @Test + public void test_ASCII_UTF8() throws Exception { + testWith("ASCII", "UTF-8"); + } + + @Test + public void test_UTF8_ASCII() throws Exception { + testWith("UTF-8", "ASCII"); + } + + @Test + public void test_UTF8_UTF8() throws Exception { + testWith("UTF-8", "UTF-8"); + } + + @Test + public void test_ASCII_ASCII() throws Exception { + testWith("ASCII", "ASCII"); + } + + public void testWith(String src, String dst) throws IOException { + BenchmarkListEntry br = stub("something.Test", + "something.generated.Test", + "testКонкаррентХэшмап", + Mode.AverageTime); + + resetCharset(); + System.setProperty("file.encoding", src); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + BenchmarkList.writeBenchmarkList(bos, Collections.singleton(br)); + + resetCharset(); + System.setProperty("file.encoding", dst); + ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); + Collection read = BenchmarkList.readBenchmarkList(bis); + BenchmarkListEntry first = read.iterator().next(); + assertEquals("something.Test.testКонкаррентХэшмап", first.getUsername()); + } + + private void resetCharset() { + try { + Field f = Charset.class.getDeclaredField("defaultCharset"); + f.setAccessible(true); + f.set(null, null); + } catch (Exception e) { + // okay then. + } + } +} diff --git a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java index 1820f80d1..5f8738287 100644 --- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java +++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java @@ -32,9 +32,7 @@ import javax.annotation.processing.RoundEnvironment; import javax.tools.Diagnostic; import javax.tools.StandardLocation; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; +import java.io.*; public class APGeneratorDestinaton implements GeneratorDestination { @@ -45,13 +43,13 @@ public APGeneratorDestinaton(RoundEnvironment roundEnv, ProcessingEnvironment pr } @Override - public Writer newResource(String resourcePath) throws IOException { - return processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resourcePath).openWriter(); + public OutputStream newResource(String resourcePath) throws IOException { + return processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resourcePath).openOutputStream(); } @Override - public Reader getResource(String resourcePath) throws IOException { - return processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resourcePath).openReader(true); + public InputStream getResource(String resourcePath) throws IOException { + return processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resourcePath).openInputStream(); } @Override From 463d789cf058bf25c4ce6396c7e1bb2c3d8f73e6 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 13 Mar 2017 15:26:44 +0100 Subject: [PATCH 096/342] JMH v1.18 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 2b88ecbbc..c03b07803 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.18 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 2b782ce02..94e968022 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.18 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index d4435596f..578c66c2c 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.18 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 90714770e..9824f5e81 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18-SNAPSHOT + 1.18 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 87f9a6b71..2d8fc498c 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 9b4d4eb89..b645cf2a5 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 8bad703f3..a96af187c 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index c7608af12..85f25def1 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 9a6c45537..189eddcdc 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 1c13f284c..633d0cc8a 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index a88da5151..bc37bb3fb 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 6bab1921a..9310d61da 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 5623aa7e2..2f604851f 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 6ce4656e2..2495bfb39 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.18-SNAPSHOT + 1.18 JMH Samples diff --git a/pom.xml b/pom.xml index 8a9b46fb1..9e8dc5ae5 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.18-SNAPSHOT + 1.18 Java Microbenchmark Harness Parent From e8cb3fb68a408800be90ae187f2d92f8e1b12360 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 13 Mar 2017 15:26:49 +0100 Subject: [PATCH 097/342] Added tag 1.18 for changeset 6eb89dc11810 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index aedaa0683..dc6fa7bbe 100644 --- a/.hgtags +++ b/.hgtags @@ -86,3 +86,4 @@ d548e3fb7337d8116767e4f669f5a0c901de758b 1.17.2 d4a8ae32b9063cf17c699455ced1b0d718f4977a 1.17.3 3b9b9cd865e38cf19d08687754ff99eb982e662f 1.17.4 5e3781c05e283dd4f5a71503e7cd7b9b151e5484 1.17.5 +6eb89dc11810e824b1f5416033cb1cf1f5f30f63 1.18 From 24e5a4abf29dbc58fde0bd17a8af1dad7ea1a15e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 13 Mar 2017 15:27:01 +0100 Subject: [PATCH 098/342] Continue in 1.19-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index c03b07803..312be076f 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18 + 1.19-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 94e968022..5eae7576d 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.18 + 1.19-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 578c66c2c..de9f576df 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18 + 1.19-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 9824f5e81..271c3d2fd 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.18 + 1.19-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 2d8fc498c..87e6ab0bc 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index b645cf2a5..31094db66 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index a96af187c..30d06f9b7 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 85f25def1..257b6fc56 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 189eddcdc..a04c1590e 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 633d0cc8a..b44610b64 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index bc37bb3fb..41768d245 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 9310d61da..ef7358068 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 2f604851f..faaff9568 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 2495bfb39..519dfbe7c 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.18 + 1.19-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 9e8dc5ae5..9fa98728a 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.18 + 1.19-SNAPSHOT Java Microbenchmark Harness Parent From 38b95b6b267cb2240f558e0a3909e79500a4ed10 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 16 Mar 2017 20:59:37 +0100 Subject: [PATCH 099/342] 7901917: Update jmh-ant-sample to download artifacts --- jmh-ant-sample/build.xml | 48 ++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/jmh-ant-sample/build.xml b/jmh-ant-sample/build.xml index 3b132eb25..a686470a3 100644 --- a/jmh-ant-sample/build.xml +++ b/jmh-ant-sample/build.xml @@ -31,28 +31,35 @@ questions. - - - - - - - - + Select JMH version to build with. Requires clean rebuild if changed. + --> + + + + + + + + + + + + + + - - + - + @@ -78,7 +84,7 @@ questions. - + From 856c517d41f448be2f5135c307ba90223c20ee27 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 28 Mar 2017 18:34:51 +0200 Subject: [PATCH 100/342] 7901930: MultisetStatistics replies +Inf, -Inf when empty --- .../openjdk/jmh/util/MultisetStatistics.java | 36 ++++++++++++------- .../jmh/util/TestMultisetStatistics.java | 6 ++-- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java index 792d33a2d..0ed1dc033 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/MultisetStatistics.java @@ -41,20 +41,28 @@ public void addValue(double d, long count) { @Override public double getMax() { - double max = Double.NEGATIVE_INFINITY; - for (double d : values.keys()) { - max = Math.max(max, d); + if (!values.isEmpty()) { + double max = Double.NEGATIVE_INFINITY; + for (double d : values.keys()) { + max = Math.max(max, d); + } + return max; + } else { + return Double.NaN; } - return max; } @Override public double getMin() { - double min = Double.POSITIVE_INFINITY; - for (double d : values.keys()) { - min = Math.min(min, d); + if (!values.isEmpty()) { + double min = Double.POSITIVE_INFINITY; + for (double d : values.keys()) { + min = Math.min(min, d); + } + return min; + } else { + return Double.NaN; } - return min; } @Override @@ -64,11 +72,15 @@ public long getN() { @Override public double getSum() { - double sum = 0; - for (double d : values.keys()) { - sum += d*values.count(d); + if (!values.isEmpty()) { + double sum = 0; + for (double d : values.keys()) { + sum += d * values.count(d); + } + return sum; + } else { + return Double.NaN; } - return sum; } private double get(long index) { diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java index cd0eb052a..161a5764e 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java @@ -59,8 +59,8 @@ public static void setUpClass() throws Exception { */ @Test public strictfp void testAdd_double() { - ListStatistics stats = new ListStatistics(); - stats.addValue(VALUES[0]); + MultisetStatistics stats = new MultisetStatistics(); + stats.addValue(VALUES[0], 1); assertEquals(1, stats.getN()); assertEquals(VALUES[0], stats.getSum(), 0.0); assertEquals(VALUES[0], stats.getMax(), 0.0); @@ -229,7 +229,7 @@ public strictfp void testSignificant_Sometimes() { @Test public strictfp void testEmpty() { - Statistics s = new ListStatistics(); + Statistics s = new MultisetStatistics(); Assert.assertEquals(0, s.getN()); Assert.assertEquals(Double.NaN, s.getSum()); From 7134bbb3d4eec87c0be16bf0938a91ec648261b7 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 17 Apr 2017 12:45:00 +0200 Subject: [PATCH 101/342] Add missing file --- src/license/LICENSE | 347 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 347 insertions(+) create mode 100644 src/license/LICENSE diff --git a/src/license/LICENSE b/src/license/LICENSE new file mode 100644 index 000000000..8b400c7ab --- /dev/null +++ b/src/license/LICENSE @@ -0,0 +1,347 @@ +The GNU General Public License (GPL) + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license +document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to +most of the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software is +covered by the GNU Library General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom to +distribute copies of free software (and charge for this service if you wish), +that you receive source code or can get it if you want it, that you can change +the software or use pieces of it in new free programs; and that you know you +can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny +you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for +a fee, you must give the recipients all the rights that you have. You must +make sure that they, too, receive or can get the source code. And you must +show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) +offer you this license which gives you legal permission to copy, distribute +and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If the +software is modified by someone else and passed on, we want its recipients to +know that what they have is not the original, so that any problems introduced +by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We +wish to avoid the danger that redistributors of a free program will +individually obtain patent licenses, in effect making the program proprietary. +To prevent this, we have made it clear that any patent must be licensed for +everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms of +this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or +translated into another language. (Hereinafter, translation is included +without limitation in the term "modification".) Each licensee is addressed as +"you". + +Activities other than copying, distribution and modification are not covered by +this License; they are outside its scope. The act of running the Program is +not restricted, and the output from the Program is covered only if its contents +constitute a work based on the Program (independent of having been made by +running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as +you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this License +and to the absence of any warranty; and give any other recipients of the +Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may +at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus +forming a work based on the Program, and copy and distribute such modifications +or work under the terms of Section 1 above, provided that you also meet all of +these conditions: + + a) You must cause the modified files to carry prominent notices stating + that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or + in part contains or is derived from the Program or any part thereof, to be + licensed as a whole at no charge to all third parties under the terms of + this License. + + c) If the modified program normally reads commands interactively when run, + you must cause it, when started running for such interactive use in the + most ordinary way, to print or display an announcement including an + appropriate copyright notice and a notice that there is no warranty (or + else, saying that you provide a warranty) and that users may redistribute + the program under these conditions, and telling the user how to view a copy + of this License. (Exception: if the Program itself is interactive but does + not normally print such an announcement, your work based on the Program is + not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, and +its terms, do not apply to those sections when you distribute them as separate +works. But when you distribute the same sections as part of a whole which is a +work based on the Program, the distribution of the whole must be on the terms +of this License, whose permissions for other licensees extend to the entire +whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise the +right to control the distribution of derivative or collective works based on +the Program. + +In addition, mere aggregation of another work not based on the Program with the +Program (or with a work based on the Program) on a volume of a storage or +distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under +Section 2) in object code or executable form under the terms of Sections 1 and +2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source + code, which must be distributed under the terms of Sections 1 and 2 above + on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to + give any third party, for a charge no more than your cost of physically + performing source distribution, a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of Sections 1 + and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to + distribute corresponding source code. (This alternative is allowed only + for noncommercial distribution and only if you received the program in + object code or executable form with such an offer, in accord with + Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all +the source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and installation +of the executable. However, as a special exception, the source code +distributed need not include anything that is normally distributed (in either +source or binary form) with the major components (compiler, kernel, and so on) +of the operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the source +code from the same place counts as distribution of the source code, even though +third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, or +rights, from you under this License will not have their licenses terminated so +long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the Program +or its derivative works. These actions are prohibited by law if you do not +accept this License. Therefore, by modifying or distributing the Program (or +any work based on the Program), you indicate your acceptance of this License to +do so, and all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor to +copy, distribute or modify the Program subject to these terms and conditions. +You may not impose any further restrictions on the recipients' exercise of the +rights granted herein. You are not responsible for enforcing compliance by +third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), conditions +are imposed on you (whether by court order, agreement or otherwise) that +contradict the conditions of this License, they do not excuse you from the +conditions of this License. If you cannot distribute so as to satisfy +simultaneously your obligations under this License and any other pertinent +obligations, then as a consequence you may not distribute the Program at all. +For example, if a patent license would not permit royalty-free redistribution +of the Program by all those who receive copies directly or indirectly through +you, then the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply and +the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or +other property right claims or to contest validity of any such claims; this +section has the sole purpose of protecting the integrity of the free software +distribution system, which is implemented by public license practices. Many +people have made generous contributions to the wide range of software +distributed through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing to +distribute software through any other system and a licensee cannot impose that +choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original +copyright holder who places the Program under this License may add an explicit +geographical distribution limitation excluding those countries, so that +distribution is permitted only in or among countries not thus excluded. In +such case, this License incorporates the limitation as if written in the body +of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the +General Public License from time to time. Such new versions will be similar in +spirit to the present version, but may differ in detail to address new problems +or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any later +version", you have the option of following the terms and conditions either of +that version or of any later version published by the Free Software Foundation. +If the Program does not specify a version number of this License, you may +choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status of +all derivatives of our free software and of promoting the sharing and reuse of +software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR +THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE +STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE +PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, +YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL +ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE +PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR +INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA +BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER +OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible +use to the public, the best way to achieve this is to make it free software +which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach +them to the start of each source file to most effectively convey the exclusion +of warranty; and each file should have at least the "copyright" line and a +pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + + Copyright (C) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it +starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes + with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free + software, and you are welcome to redistribute it under certain conditions; + type 'show c' for details. + +The hypothetical commands 'show w' and 'show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may be +called something other than 'show w' and 'show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, +if any, to sign a "copyright disclaimer" for the program, if necessary. Here +is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + 'Gnomovision' (which makes passes at compilers) written by James Hacker. + + signature of Ty Coon, 1 April 1989 + + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General Public +License instead of this License. + + +"CLASSPATH" EXCEPTION TO THE GPL + +Certain source files distributed by Oracle America and/or its affiliates are +subject to the following clarification and special exception to the GPL, but +only where Oracle has expressly included in the particular source file's header +the words "Oracle designates this particular file as subject to the "Classpath" +exception as provided by Oracle in the LICENSE file that accompanied this code." + + Linking this library statically or dynamically with other modules is making + a combined work based on this library. Thus, the terms and conditions of + the GNU General Public License cover the whole combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules, + and to copy and distribute the resulting executable under terms of your + choice, provided that you also meet, for each linked independent module, + the terms and conditions of the license of that module. An independent + module is a module which is not derived from or based on this library. If + you modify this library, you may extend this exception to your version of + the library, but you are not obligated to do so. If you do not wish to do + so, delete this exception statement from your version. From f20dd1831afe27053740f9a70188c18901e932c5 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 17 Apr 2017 13:02:02 +0200 Subject: [PATCH 102/342] 7901948: Maven build should not use --- .../resources/archetype-resources/pom.xml | 4 --- .../resources/archetype-resources/pom.xml | 4 --- .../resources/archetype-resources/pom.xml | 4 --- .../resources/archetype-resources/pom.xml | 4 --- jmh-archetypes/pom.xml | 4 --- jmh-core-benchmarks/pom.xml | 4 --- jmh-core-ct/pom.xml | 4 --- jmh-core-it/pom.xml | 4 --- jmh-core/pom.xml | 4 --- jmh-generator-annprocess/pom.xml | 4 --- jmh-generator-asm/pom.xml | 4 --- jmh-generator-bytecode/pom.xml | 4 --- jmh-generator-reflection/pom.xml | 4 --- jmh-samples/pom.xml | 4 --- pom.xml | 25 ++++++++++++++++--- 15 files changed, 21 insertions(+), 60 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 2c1df6433..d3af47c98 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -56,10 +56,6 @@ THE POSSIBILITY OF SUCH DAMAGE. - - 3.0.4 - - UTF-8 diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 9286e9949..dc7dc9a6a 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -45,10 +45,6 @@ THE POSSIBILITY OF SUCH DAMAGE. Edit as needed. --> - - 3.0 - - org.openjdk.jmh diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 962a72754..be2cd12d1 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -57,10 +57,6 @@ THE POSSIBILITY OF SUCH DAMAGE. - - 3.0.4 - - UTF-8 diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index f9312a9c6..5cc00dd86 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -56,10 +56,6 @@ THE POSSIBILITY OF SUCH DAMAGE. - - 3.0.4 - - UTF-8 diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 87e6ab0bc..d9cc83648 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -37,10 +37,6 @@ questions. jmh-archetypes pom - - 3.0 - - UTF-8 diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 31094db66..a1795e865 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -57,10 +57,6 @@ questions. - - 3.0 - - UTF-8 diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 30d06f9b7..39bdc13be 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -72,10 +72,6 @@ questions. - - 3.0 - - UTF-8 diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 257b6fc56..d4b69dc8e 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -57,10 +57,6 @@ questions. - - 3.0 - - UTF-8 diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index a04c1590e..b8c4d4467 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -69,10 +69,6 @@ questions. - - 3.0 - - UTF-8 ${maven.build.timestamp} diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index b44610b64..fbe6626bd 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -50,10 +50,6 @@ questions. - - 3.0 - - UTF-8 diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 41768d245..1fda73df0 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -59,10 +59,6 @@ questions. - - 3.0 - - UTF-8 diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index ef7358068..35848e786 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -59,10 +59,6 @@ questions. - - 3.0 - - UTF-8 diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index faaff9568..5120d6934 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -49,10 +49,6 @@ questions. - - 3.0 - - UTF-8 diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 519dfbe7c..c53d30306 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -63,10 +63,6 @@ THE POSSIBILITY OF SUCH DAMAGE. - - 3.0 - - UTF-8 benchmarks diff --git a/pom.xml b/pom.xml index 9fa98728a..3f1629381 100644 --- a/pom.xml +++ b/pom.xml @@ -146,13 +146,30 @@ questions. true + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.4.1 + + + enforce-maven + + enforce + + + + + 3.0 + + + + + + - - 3.0 - - jmh-core jmh-core-it From 7406af9d36f6bcab5b0331b17b359e40f51001e6 Mon Sep 17 00:00:00 2001 From: Christoph Dreis Date: Sun, 23 Apr 2017 22:19:07 +0200 Subject: [PATCH 103/342] 7901955: Replace .compareTo with .compare --- .../java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java | 4 ++-- .../src/main/java/org/openjdk/jmh/profile/StackProfiler.java | 2 +- .../src/main/java/org/openjdk/jmh/runner/WorkloadParams.java | 2 +- jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java | 2 +- .../java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index becc19637..52eef744a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -389,8 +389,8 @@ private PerfResult processAssembly(BenchmarkResult br, File stdOut, File stdErr) Collections.sort(regions, new Comparator() { @Override public int compare(Region o1, Region o2) { - return Long.valueOf(o2.getEventCount(events, mainEvent)). - compareTo(o1.getEventCount(events, mainEvent)); + return Long.compare(o2.getEventCount(events, mainEvent), + o1.getEventCount(events, mainEvent)); } }); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java index 7c1f0e231..3e703c5a5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java @@ -288,7 +288,7 @@ private long stateSize(Thread.State state) { @Override public int compare(Thread.State s1, Thread.State s2) { - return Long.valueOf(stateSize(s2)).compareTo(stateSize(s1)); + return Long.compare(stateSize(s2), stateSize(s1)); } }); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java index 72bff253f..170ca1b94 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java @@ -123,7 +123,7 @@ public Value(String value, int order) { @Override public int compareTo(Value o) { - return Integer.valueOf(order).compareTo(o.order); + return Integer.compare(order, o.order); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java index 60c4b91e9..c9edce90c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Multisets.java @@ -58,7 +58,7 @@ public static List sortedDesc(final Multiset set) { Collections.sort(sorted, new Comparator() { @Override public int compare(T o1, T o2) { - return Long.valueOf(set.count(o2)).compareTo(set.count(o1)); + return Long.compare(set.count(o2), set.count(o1)); } }); return sorted; diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java index 75b18204a..4d4ad178e 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java @@ -253,7 +253,7 @@ public double score() { @Override public int compareTo(Chromosome o) { // Order by score, descending. - return -Double.valueOf(score()).compareTo(o.score()); + return -Double.compare(score(), o.score()); } @Override From f5bd0773952894dcf8d09f5d5622525660f3cd41 Mon Sep 17 00:00:00 2001 From: Jens Wilke Date: Tue, 2 May 2017 13:38:06 +0200 Subject: [PATCH 104/342] 7901965: Add JMH and JDK version and effective JVM path to the JSON output --- .../openjdk/jmh/infra/BenchmarkParams.java | 58 ++++++++++-- .../java/org/openjdk/jmh/infra/Blackhole.java | 2 + .../java/org/openjdk/jmh/results/Result.java | 5 +- .../jmh/results/format/JSONResultFormat.java | 65 ++++++++++++- .../org/openjdk/jmh/runner/BaseRunner.java | 10 -- .../jmh/runner/PrintPropertiesMain.java | 44 +++++++++ .../java/org/openjdk/jmh/runner/Runner.java | 33 +++---- .../jmh/runner/format/TextReportFormat.java | 10 ++ .../java/org/openjdk/jmh/util/FileUtils.java | 4 +- .../main/java/org/openjdk/jmh/util/Utils.java | 43 +++++++++ .../java/org/openjdk/jmh/util/Version.java | 26 ++++++ .../jmh/results/TestAggregateResult.java | 2 + .../results/format/JSONResultFormatTest.java | 93 +++++++++++++++++++ .../jmh/results/format/ResultFormatTest.java | 17 +++- .../org/openjdk/jmh/runner/RunnerTest.java | 4 + .../jmh/results/format/output-golden.json | 30 ++++++ 16 files changed, 403 insertions(+), 43 deletions(-) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/runner/PrintPropertiesMain.java create mode 100644 jmh-core/src/test/java/org/openjdk/jmh/results/format/JSONResultFormatTest.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java index d9df4a176..c9486fea0 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java @@ -28,6 +28,7 @@ import org.openjdk.jmh.runner.WorkloadParams; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Utils; +import org.openjdk.jmh.util.Version; import java.io.Serializable; import java.util.Arrays; @@ -64,20 +65,23 @@ public class BenchmarkParams extends BenchmarkParamsL4 { } public BenchmarkParams(String benchmark, String generatedTarget, boolean synchIterations, - int threads, int[] threadGroups, Collection threadGroupLabels, - int forks, int warmupForks, - IterationParams warmup, IterationParams measurement, - Mode mode, WorkloadParams params, - TimeUnit timeUnit, int opsPerInvocation, - String jvm, Collection jvmArgs, - TimeValue timeout) { + int threads, int[] threadGroups, Collection threadGroupLabels, + int forks, int warmupForks, + IterationParams warmup, IterationParams measurement, + Mode mode, WorkloadParams params, + TimeUnit timeUnit, int opsPerInvocation, + String jvm, Collection jvmArgs, + String jdkVersion, String vmVersion, String jmhVersion, + TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, threads, threadGroups, threadGroupLabels, forks, warmupForks, warmup, measurement, mode, params, timeUnit, opsPerInvocation, - jvm, jvmArgs, timeout); + jvm, jvmArgs, + jdkVersion, vmVersion, jmhVersion, + timeout); } } @@ -92,6 +96,7 @@ public BenchmarkParamsL4(String benchmark, String generatedTarget, boolean synch Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, + String jdkVersion, String vmVersion, String jmhVersion, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, threads, threadGroups, threadGroupLabels, @@ -100,6 +105,7 @@ public BenchmarkParamsL4(String benchmark, String generatedTarget, boolean synch mode, params, timeUnit, opsPerInvocation, jvm, jvmArgs, + jdkVersion, vmVersion, jmhVersion, timeout); } } @@ -131,6 +137,7 @@ public BenchmarkParamsL3(String benchmark, String generatedTarget, boolean synch Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, + String jdkVersion, String vmVersion, String jmhVersion, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, threads, threadGroups, threadGroupLabels, @@ -139,6 +146,7 @@ public BenchmarkParamsL3(String benchmark, String generatedTarget, boolean synch mode, params, timeUnit, opsPerInvocation, jvm, jvmArgs, + jdkVersion, vmVersion, jmhVersion, timeout); } } @@ -185,6 +193,9 @@ abstract class BenchmarkParamsL2 extends BenchmarkParamsL1 implements Serializab protected final int opsPerInvocation; protected final String jvm; protected final Collection jvmArgs; + protected final String jdkVersion; + protected final String jmhVersion; + protected final String vmVersion; protected final TimeValue timeout; public BenchmarkParamsL2(String benchmark, String generatedTarget, boolean synchIterations, @@ -194,6 +205,7 @@ public BenchmarkParamsL2(String benchmark, String generatedTarget, boolean synch Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, + String jdkVersion, String vmVersion, String jmhVersion, TimeValue timeout) { this.benchmark = benchmark; this.generatedTarget = generatedTarget; @@ -211,6 +223,9 @@ public BenchmarkParamsL2(String benchmark, String generatedTarget, boolean synch this.opsPerInvocation = opsPerInvocation; this.jvm = jvm; this.jvmArgs = jvmArgs; + this.jdkVersion = jdkVersion; + this.vmVersion = vmVersion; + this.jmhVersion = jmhVersion; this.timeout = timeout; } @@ -333,10 +348,21 @@ public String generatedBenchmark() { return generatedTarget; } + /** + * @return JVM executable path + */ public String getJvm() { return jvm; } + /** + * @return JMH version identical to {@link Version#getPlainVersion()}, but output format should + * get there input via bean for testing purposes. + */ + public String getJmhVersion() { + return jmhVersion; + } + /** * @return JVM options */ @@ -344,6 +370,22 @@ public Collection getJvmArgs() { return Collections.unmodifiableCollection(jvmArgs); } + /** + * @return version information as returned by the effective target JVM, + * via system property {@code java.version} and {@code java.vm.version} + */ + public String getJdkVersion() { + return jdkVersion; + } + + /** + * @return version information as returned by the effective target JVM, + * via system property {@code java.vm.version} + */ + public String getVmVersion() { + return vmVersion; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java index 987e28c33..874c74b03 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java @@ -288,6 +288,8 @@ public Blackhole(String challengeResponse) { * * WARNING: This method should only be called by the infrastructure code, in clearly understood cases. * Even though it is public, it is not supposed to be called by users. + * + * @param challengeResponse arbitrary string */ public void evaporate(String challengeResponse) { if (!challengeResponse.equals("Yes, I am Stephen Hawking, and know a thing or two about black holes.")) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java index 30b4e8bfa..3a90b2dd5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/Result.java @@ -186,9 +186,8 @@ protected T getZeroResult() { } /** - * Get derivative results for this result. These do not participate in aggregation, - * and computed on the spot from the aggregated result. - * @return + * @return derivative results for this result. These do not participate in aggregation, + * and computed on the spot from the aggregated result. */ protected Collection getDerivativeResults() { return Collections.emptyList(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java index 60a9338bb..6b826c308 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java @@ -69,10 +69,18 @@ public void writeOut(Collection results) { } pw.println("{"); + pw.println("\"jmhVersion\" : \"" + params.getJmhVersion() + "\","); pw.println("\"benchmark\" : \"" + params.getBenchmark() + "\","); pw.println("\"mode\" : \"" + params.getMode().shortLabel() + "\","); pw.println("\"threads\" : " + params.getThreads() + ","); pw.println("\"forks\" : " + params.getForks() + ","); + pw.println("\"jvm\" : " + toJsonString(params.getJvm()) + ","); + // if empty, write an empty array. + pw.println("\"jvmArgs\" : ["); + printStringArray(pw, params.getJvmArgs()); + pw.println("],"); + pw.println("\"jdkVersion\" : " + toJsonString(params.getJdkVersion()) + ","); + pw.println("\"vmVersion\" : " + toJsonString(params.getVmVersion()) + ","); pw.println("\"warmupIterations\" : " + params.getWarmup().getCount() + ","); pw.println("\"warmupTime\" : \"" + params.getWarmup().getTime() + "\","); pw.println("\"warmupBatchSize\" : " + params.getWarmup().getBatchSize() + ","); @@ -234,7 +242,41 @@ private String emit(double d) { return String.valueOf(d); } - private String tidy(String s) { + /** + * Escaping for a JSON string. Does the typical escaping of double quotes and backslash. + * Also escapes characters that are handled by the tidying process, so that every ASCII + * character makes it correctly into the JSON output. Control characters are filtered. + */ + static String toJsonString(String s) { + StringBuilder sb = new StringBuilder(); + sb.append("\""); + for (char c : s.toCharArray()) { + if (Character.isISOControl(c)) { + continue; + } + switch (c) { + // use & as escape character to escape the tidying + case '&': sb.append("&&"); break; + // we cannot escape to \\\\ since this would create sequences interpreted by the tidying + case '\\': sb.append("&/"); break; + case '"': sb.append("&'"); break; + // escape spacial chars for the tidying formatting below that might appear in a string + case ',': sb.append(";"); break; + case '[': sb.append("<"); break; + case ']': sb.append(">"); break; + case '<': sb.append("&-"); break; + case '>': sb.append("&="); break; + case ';': sb.append("&:"); break; + case '{': sb.append("&("); break; + case '}': sb.append("&)"); break; + default: sb.append(c); + } + } + sb.append("\""); + return sb.toString(); + } + + static String tidy(String s) { s = s.replaceAll("\r", ""); s = s.replaceAll("\n", " "); s = s.replaceAll(",", ",\n"); @@ -250,6 +292,15 @@ private String tidy(String s) { s = s.replaceAll(";", ","); s = s.replaceAll("\\<", "["); s = s.replaceAll("\\>", "]"); + // translate back from string escaping to keep all string characters intact + s = s.replaceAll("&:", ";"); + s = s.replaceAll("&'", "\\\\\""); + s = s.replaceAll("&\\(", "{"); + s = s.replaceAll("&\\)", "}"); + s = s.replaceAll("&-", "<"); + s = s.replaceAll("&=", ">"); + s = s.replaceAll("&/", "\\\\\\\\"); + s = s.replaceAll("&&", "&"); String[] lines = s.split("\n"); @@ -292,4 +343,16 @@ private String printMultiple(Collection elements, String leftBracket, St return sb.toString(); } + private static void printStringArray(PrintWriter pw, Collection col) { + boolean isFirst = true; + for (String e : col) { + if (isFirst) { + isFirst = false; + } else { + pw.print(','); + } + pw.print(toJsonString(e)); + } + } + } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java index 8339df089..6a93d6017 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java @@ -84,16 +84,6 @@ protected Multimap runBenchmarksEmbedded(Actio BenchmarkParams params = action.getParams(); ActionMode mode = action.getMode(); - String realOpts = Utils.join(ManagementFactory.getRuntimeMXBean().getInputArguments(), " ").trim(); - if (realOpts.isEmpty()) { - realOpts = ""; - } - - out.println("# " + Version.getVersion()); - out.println("# VM version: " + Utils.getCurrentJvmVersion()); - out.println("# VM invoker: " + Utils.getCurrentJvm()); - out.println("# VM options: " + realOpts); - out.startBenchmark(params); out.println(""); etaBeforeBenchmark(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/PrintPropertiesMain.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/PrintPropertiesMain.java new file mode 100644 index 000000000..07669344a --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/PrintPropertiesMain.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.runner; + +import org.openjdk.jmh.util.Utils; + +/** + * Main program entry point for exporting the system properties, used for detecting the VM version. + */ +class PrintPropertiesMain { + + /** + * @param argv Command line arguments + */ + public static void main(String[] argv) throws Exception { + Utils.getRecordedSystemProperties().storeToXML( + System.out, + "JMH properties export for target JVM", + "UTF-8"); + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 9f7d656c6..a22664034 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -465,6 +465,13 @@ private BenchmarkParams newBenchmarkParams(BenchmarkListEntry benchmark, ActionM String jvm = options.getJvm().orElse( benchmark.getJvm().orElse(Utils.getCurrentJvm())); + Properties targetProperties; + if (jvm.equals(Utils.getCurrentJvm())) { + targetProperties = Utils.getRecordedSystemProperties(); + } else { + targetProperties = Utils.readPropertiesFromCommand(getPrintPropertiesCommand(jvm)); + } + Collection jvmArgs = new ArrayList<>(); jvmArgs.addAll(options.getJvmArgsPrepend().orElse( @@ -479,11 +486,15 @@ private BenchmarkParams newBenchmarkParams(BenchmarkListEntry benchmark, ActionM TimeValue timeout = options.getTimeout().orElse( benchmark.getTimeout().orElse(Defaults.TIMEOUT)); + String jdkVersion = targetProperties.getProperty("java.version"); + String vmVersion = targetProperties.getProperty("java.vm.version"); return new BenchmarkParams(benchmark.getUsername(), benchmark.generatedTarget(), synchIterations, threads, threadGroups, benchmark.getThreadGroupLabels().orElse(Collections.emptyList()), forks, warmupForks, warmup, measurement, benchmark.getMode(), benchmark.getWorkloadParams(), timeUnit, opsPerInvocation, - jvm, jvmArgs, timeout); + jvm, jvmArgs, + jdkVersion, vmVersion, Version.getPlainVersion(), + timeout); } private List explodeAllParams(BenchmarkListEntry br) throws RunnerException { @@ -599,17 +610,6 @@ private Multimap runSeparate(ActionPlan action printOut = forcePrint || printOut; printErr = forcePrint || printErr; - List versionString = getVersionMainCommand(params); - - String opts = Utils.join(params.getJvmArgs(), " "); - if (opts.trim().isEmpty()) { - opts = ""; - } - - out.println("# " + Version.getVersion()); - out.print("# VM version: " + Utils.join(Utils.runWith(versionString), "\n")); - out.println("# VM invoker: " + params.getJvm()); - out.println("# VM options: " + opts); out.startBenchmark(params); out.println(""); @@ -832,14 +832,11 @@ List getForkedMainCommand(BenchmarkParams benchmark, List getVersionMainCommand(BenchmarkParams benchmark) { + private List getPrintPropertiesCommand(String jvm) { List command = new ArrayList<>(); // use supplied jvm, if given - command.add(benchmark.getJvm()); + command.add(jvm); // assemble final process command command.add("-cp"); @@ -849,7 +846,7 @@ List getVersionMainCommand(BenchmarkParams benchmark) { command.add(System.getProperty("java.class.path")); } - command.add(VersionMain.class.getName()); + command.add(PrintPropertiesMain.class.getName()); return command; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index e2fdcf646..e288f29aa 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -56,6 +56,16 @@ public TextReportFormat(PrintStream out, VerboseMode verbose) { @Override public void startBenchmark(BenchmarkParams params) { + String opts = Utils.join(params.getJvmArgs(), " "); + if (opts.trim().isEmpty()) { + opts = ""; + } + + println("# JMH version: " + params.getJmhVersion()); + println("# VM version: JDK " + params.getJdkVersion() + ", VM " + params.getVmVersion()); + println("# VM invoker: " + params.getJvm()); + println("# VM options: " + opts); + IterationParams warmup = params.getWarmup(); if (warmup.getCount() > 0) { out.println("# Warmup: " + warmup.getCount() + " iterations, " + diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java index 55df03d3f..5597d6999 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java @@ -47,7 +47,7 @@ private FileUtils() { * * @param suffix suffix * @return temp file - * @throws IOException + * @throws IOException if things go crazy */ public static TempFile weakTempFile(String suffix) throws IOException { return TEMP_FILE_MANAGER.create(suffix); @@ -63,7 +63,7 @@ public static void purgeTemps() { * * @param suffix suffix * @return temporary file - * @throws IOException + * @throws IOException if things go crazy */ public static File tempFile(String suffix) throws IOException { File file = File.createTempFile("jmh", suffix); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index e25c1220b..cd21935a9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -474,6 +474,49 @@ public static Collection runWith(List cmd) { return messages; } + /** + * We don't access the complete system properties via {@link System#getProperties()} because + * this would require read/write permissions to the properties. Just copy the properties we + * want to record in the result. + * + * @return Copy of system properties we want to record in the results. + */ + public static Properties getRecordedSystemProperties() { + String[] names = new String[]{"java.version", "java.vm.version"}; + Properties p = new Properties(); + for (String i : names) { + p.setProperty(i, System.getProperty(i)); + } + return p; + } + + public static Properties readPropertiesFromCommand(List cmd) { + Properties out = new Properties(); + try { + Process p = new ProcessBuilder(cmd).start(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + // drain streams, else we might lock up + InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), System.err); + InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), baos); + + errDrainer.start(); + outDrainer.start(); + + int err = p.waitFor(); + + errDrainer.join(); + outDrainer.join(); + out.loadFromXML(new ByteArrayInputStream(baos.toByteArray())); + } catch (IOException ex) { + throw new RuntimeException(ex); + } catch (InterruptedException ex) { + throw new IllegalStateException(ex); + } + return out; + } + /** * Adapts Iterator for Iterable. * Can be iterated only once! diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java index 52d15e331..4a71360c8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Version.java @@ -39,6 +39,9 @@ public class Version { private static final int UPDATE_INTERVAL = 180; + /** + * @return the version, build date and update hint. + */ public static String getVersion() { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); @@ -48,6 +51,29 @@ public static String getVersion() { return sw.toString(); } + /** + * @return only version, e.g. "1.19", or "-" if the version cannot be determined. + */ + public static String getPlainVersion() { + Properties p = new Properties(); + InputStream s = Version.class.getResourceAsStream("/jmh.properties"); + if (s == null) { + return "-"; + } + try { + p.load(s); + } catch (IOException e) { + return "-"; + } finally { + FileUtils.safelyClose(s); + } + String version = (String) p.get("jmh.version"); + if (version == null) { + return "-"; + } + return version; + } + private static void printVersion(PrintWriter pw) { Properties p = new Properties(); InputStream s = Version.class.getResourceAsStream("/jmh.properties"); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java index 7075f510a..43cf606aa 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java @@ -32,6 +32,7 @@ import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Utils; +import org.openjdk.jmh.util.Version; import java.util.Collections; import java.util.concurrent.TimeUnit; @@ -56,6 +57,7 @@ public static void setupClass() { new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.emptyList(), + System.getProperty("java.version"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.days(1), 1), null diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/format/JSONResultFormatTest.java b/jmh-core/src/test/java/org/openjdk/jmh/results/format/JSONResultFormatTest.java new file mode 100644 index 000000000..bd49b6ad8 --- /dev/null +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/format/JSONResultFormatTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.results.format; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Extra tests for special cases of the JSON formatter. + * + * @author Jens Wilke + * @see JSONResultFormat + */ +public class JSONResultFormatTest { + + @Test + public void toJsonString_tidy() { + String s = JSONResultFormat.toJsonString("abc,\"{}()\\(\\)[]{}"); + s = JSONResultFormat.tidy(s); + assertEquals("\"abc,\\\"{}()\\\\(\\\\)[]{}\"\n", s); + } + + @Test + public void toJsonString_tidy_curly() { + String s = JSONResultFormat.toJsonString("{}"); + s = JSONResultFormat.tidy(s); + assertEquals("\"{}\"\n", s); + } + + @Test + public void toJsonString_tidy_curved() { + String s = JSONResultFormat.toJsonString("()"); + s = JSONResultFormat.tidy(s); + assertEquals("\"()\"\n", s); + } + + @Test + public void toJsonString_tidy_escapedDoubleQuote() { + String s = JSONResultFormat.toJsonString("\""); + s = JSONResultFormat.tidy(s); + assertEquals("\"\\\"\"\n", s); + } + + @Test + public void toJsonString_tidy_escapedEscape() { + String s = JSONResultFormat.toJsonString("\\"); + s = JSONResultFormat.tidy(s); + assertEquals("\"\\\\\"\n", s); + } + + /** + * Check that every ASCII character in a string makes it transparently through + * the JSON tidying and formatting process. + */ + @Test + public void toJsonString_tidy_asciiTransparent () { + for (char i = 32; i < 127; i++) { + if (i == '"') { + continue; + } + if (i == '\\') { + continue; + } + String s = JSONResultFormat.toJsonString(Character.toString(i)); + s = JSONResultFormat.tidy(s); + assertEquals("\"" + i + "\"\n", s); + } + } + +} \ No newline at end of file diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java index 97ee63fa1..7d998008c 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java @@ -46,6 +46,20 @@ */ public class ResultFormatTest { + /** + * Use constant dummy for JVM instead of current JVM to compare with golden file. + */ + private static final String JVM_DUMMY = "javadummy"; + + /** + * Use constant dummy for JVM instead of current JVM to compare with golden file. + */ + private static final String JDK_VERSION_DUMMY = "1.8-dummy"; + + private static final String VM_VERSION_DUMMY = "4711"; + + private static final String JMH_VERSION_DUMMY = "1.18"; + private Collection getStub() { Collection results = new TreeSet<>(RunResult.DEFAULT_SORT_COMPARATOR); @@ -70,8 +84,9 @@ private Collection getStub() { Mode.Throughput, ps, TimeUnit.SECONDS, 1, - Utils.getCurrentJvm(), + JVM_DUMMY, Collections.emptyList(), + JDK_VERSION_DUMMY, VM_VERSION_DUMMY, JMH_VERSION_DUMMY, TimeValue.days(1)); Collection benchmarkResults = new ArrayList<>(); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java index 0169ab9c2..0fb019153 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java @@ -33,6 +33,7 @@ import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.FileUtils; import org.openjdk.jmh.util.Utils; +import org.openjdk.jmh.util.Version; import java.io.File; import java.io.IOException; @@ -65,6 +66,7 @@ public void testEmptyOptsHaveCompileCommandFile() { new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.emptyList(), + System.getProperty("java.version"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); @@ -96,6 +98,7 @@ public void testOptsWithCompileCommandFileResultInMergedCompileCommandFile() thr new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.singletonList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints), + System.getProperty("java.version"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); @@ -132,6 +135,7 @@ public void testOptsWith2CompileCommandFilesResultInMergedCompileCommandFile() t Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Arrays.asList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints1, CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints2), + System.getProperty("java.version"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json index a42cb7864..718467124 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json @@ -1,9 +1,15 @@ [ { + "jmhVersion" : "1.18", "benchmark" : "benchmark_0", "mode" : "thrpt", "threads" : 80, "forks" : 828, + "jvm" : "javadummy", + "jvmArgs" : [ + ], + "jdkVersion" : "1.8-dummy", + "vmVersion" : "4711", "warmupIterations" : 84, "warmupTime" : "375 s", "warmupBatchSize" : 1, @@ -216,10 +222,16 @@ } }, { + "jmhVersion" : "1.18", "benchmark" : "benchmark_1", "mode" : "thrpt", "threads" : 900, "forks" : 364, + "jvm" : "javadummy", + "jvmArgs" : [ + ], + "jdkVersion" : "1.8-dummy", + "vmVersion" : "4711", "warmupIterations" : 544, "warmupTime" : "409 s", "warmupBatchSize" : 1, @@ -315,10 +327,16 @@ } }, { + "jmhVersion" : "1.18", "benchmark" : "benchmark_2", "mode" : "thrpt", "threads" : 466, "forks" : 677, + "jvm" : "javadummy", + "jvmArgs" : [ + ], + "jdkVersion" : "1.8-dummy", + "vmVersion" : "4711", "warmupIterations" : 384, "warmupTime" : "105 s", "warmupBatchSize" : 1, @@ -476,10 +494,16 @@ } }, { + "jmhVersion" : "1.18", "benchmark" : "benchmark_3", "mode" : "thrpt", "threads" : 968, "forks" : 581, + "jvm" : "javadummy", + "jvmArgs" : [ + ], + "jdkVersion" : "1.8-dummy", + "vmVersion" : "4711", "warmupIterations" : 628, "warmupTime" : "207 s", "warmupBatchSize" : 1, @@ -669,10 +693,16 @@ } }, { + "jmhVersion" : "1.18", "benchmark" : "benchmark_4", "mode" : "thrpt", "threads" : 739, "forks" : 670, + "jvm" : "javadummy", + "jvmArgs" : [ + ], + "jdkVersion" : "1.8-dummy", + "vmVersion" : "4711", "warmupIterations" : 997, "warmupTime" : "651 s", "warmupBatchSize" : 1, From 1b16a7e6cc1f02eaf429237f212fc0271ee4ceb6 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 2 May 2017 20:11:37 +0200 Subject: [PATCH 105/342] 7901966: Profilers mishandle filtering when VM startup is slow --- .../jmh/profile/AbstractPerfAsmProfiler.java | 2 +- .../jmh/profile/LinuxPerfNormProfiler.java | 3 +-- .../openjdk/jmh/profile/ProfilerUtils.java | 2 +- .../jmh/profile/SafepointsProfiler.java | 2 +- .../jmh/results/BenchmarkResultMetaData.java | 19 ++++++++++++++++--- .../org/openjdk/jmh/runner/BaseRunner.java | 13 ++++++++++--- .../java/org/openjdk/jmh/runner/Runner.java | 6 ++++++ 7 files changed, 36 insertions(+), 11 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 52eef744a..e6ca41c34 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -344,7 +344,7 @@ private PerfResult processAssembly(BenchmarkResult br, File stdOut, File stdErr) long skipMs; if (delayMsec == -1) { // not set - skipMs = ProfilerUtils.warmupDelayMs(br); + skipMs = ProfilerUtils.measurementDelayMs(br); } else { skipMs = delayMsec; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index 826c30049..955dab156 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -39,7 +39,6 @@ import java.text.NumberFormat; import java.text.ParseException; import java.util.*; -import java.util.concurrent.TimeUnit; public class LinuxPerfNormProfiler implements ExternalProfiler { @@ -188,7 +187,7 @@ private Collection process(BenchmarkResult br, File stdOut, Fi long skipMs; if (delayMs == -1) { // not set - skipMs = ProfilerUtils.warmupDelayMs(br); + skipMs = ProfilerUtils.measurementDelayMs(br); } else { skipMs = delayMs; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java index a92ca554f..7e9e0cc16 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerUtils.java @@ -82,7 +82,7 @@ public static OptionSet parseInitLine(String initLine, OptionParser parser) thro return set; } - public static long warmupDelayMs(BenchmarkResult br) { + public static long measurementDelayMs(BenchmarkResult br) { BenchmarkResultMetaData md = br.getMetadata(); if (md != null) { // try to ask harness itself: diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java index 3b40d5a1a..ed693301b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -76,7 +76,7 @@ public Collection afterTrial(BenchmarkResult br, long pid, Fil long measuredTimeMs = ProfilerUtils.measuredTimeMs(br); long measuredTimeNs = TimeUnit.MILLISECONDS.toNanos(measuredTimeMs); - long measureFrom = TimeUnit.MILLISECONDS.toNanos(ProfilerUtils.warmupDelayMs(br)); + long measureFrom = TimeUnit.MILLISECONDS.toNanos(ProfilerUtils.measurementDelayMs(br)); long measureTo = measureFrom + measuredTimeNs; List ds = new ArrayList<>(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResultMetaData.java b/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResultMetaData.java index 47fd2cbf1..b571c59e6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResultMetaData.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/BenchmarkResultMetaData.java @@ -28,14 +28,16 @@ public class BenchmarkResultMetaData implements Serializable { - private final long startTime; + private long startTime; + private final long warmupTime; private final long measurementTime; private final long stopTime; private final long warmupOps; private final long measurementOps; - public BenchmarkResultMetaData(long startTime, long measurementTime, long stopTime, long warmupOps, long measurementOps) { - this.startTime = startTime; + public BenchmarkResultMetaData(long warmupTime, long measurementTime, long stopTime, long warmupOps, long measurementOps) { + this.startTime = Long.MIN_VALUE; + this.warmupTime = warmupTime; this.measurementTime = measurementTime; this.stopTime = stopTime; this.warmupOps = warmupOps; @@ -43,9 +45,16 @@ public BenchmarkResultMetaData(long startTime, long measurementTime, long stopTi } public long getStartTime() { + if (startTime == Long.MIN_VALUE) { + throw new IllegalStateException("Unset start time"); + } return startTime; } + public long getWarmupTime() { + return warmupTime; + } + public long getMeasurementTime() { return measurementTime; } @@ -61,4 +70,8 @@ public long getMeasurementOps() { public long getWarmupOps() { return warmupOps; } + + public void adjustStart(long startTime) { + this.startTime = startTime; + } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java index 6a93d6017..5351d558a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java @@ -84,6 +84,8 @@ protected Multimap runBenchmarksEmbedded(Actio BenchmarkParams params = action.getParams(); ActionMode mode = action.getMode(); + long startTime = System.currentTimeMillis(); + out.startBenchmark(params); out.println(""); etaBeforeBenchmark(); @@ -109,7 +111,12 @@ public void acceptMeta(BenchmarkResultMetaData md) { doSingle(params, mode, acceptor); if (!res.isEmpty()) { - BenchmarkResult br = new BenchmarkResult(params, res, mds.get(0)); + BenchmarkResultMetaData md = mds.get(0); + if (md != null) { + md.adjustStart(startTime); + } + + BenchmarkResult br = new BenchmarkResult(params, res, md); results.put(params, br); out.endBenchmark(br); } @@ -237,7 +244,7 @@ void runBenchmark(BenchmarkParams benchParams, IterationResultAcceptor acceptor) } protected void runBenchmark(BenchmarkParams benchParams, BenchmarkHandler handler, IterationResultAcceptor acceptor) { - long startTime = System.currentTimeMillis(); + long warmupTime = System.currentTimeMillis(); long allWarmup = 0; long allMeasurement = 0; @@ -285,7 +292,7 @@ protected void runBenchmark(BenchmarkParams benchParams, BenchmarkHandler handle long stopTime = System.currentTimeMillis(); BenchmarkResultMetaData md = new BenchmarkResultMetaData( - startTime, measurementTime, stopTime, + warmupTime, measurementTime, stopTime, allWarmup, allMeasurement); if (acceptor != null) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index a22664034..79f47bce0 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -663,11 +663,17 @@ private Multimap runSeparate(ActionPlan action } } + long startTime = System.currentTimeMillis(); + List result = doFork(server, forkedString, stdOut.file(), stdErr.file(), printOut, printErr); if (!result.isEmpty()) { long pid = server.getClientPid(); BenchmarkResultMetaData md = server.getMetadata(); + if (md != null) { + md.adjustStart(startTime); + } + BenchmarkResult br = new BenchmarkResult(params, result, md); if (!profilersRev.isEmpty()) { From 16481fe278ad595189a13d05e9e25782d80f3944 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 2 May 2017 20:19:43 +0200 Subject: [PATCH 106/342] 7901967: -prof safepoints mishandles parsing when additional UL is enabled --- .../org/openjdk/jmh/profile/SafepointsProfiler.java | 6 +++--- .../openjdk/jmh/profile/SafepointsProfilerTest.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java index ed693301b..486897fa9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -207,7 +207,7 @@ public SafepointProfilerResult aggregate(Collection res Pattern.compile("([0-9\\.,]*): (.*) stopped: ([0-9\\.,]*) seconds, (.*) took: ([0-9\\.,]*) seconds"); private static final Pattern JDK_9_LINE = - Pattern.compile("\\[([0-9\\.,]*)s\\]\\[info\\]\\[safepoint\\] (.*) stopped: ([0-9\\.,]*) seconds, (.*) took: ([0-9\\.,]*) seconds"); + Pattern.compile("\\[([0-9\\.,]*)s\\]\\[info\\]\\[safepoint( *)\\] (.*) stopped: ([0-9\\.,]*) seconds, (.*) took: ([0-9\\.,]*) seconds"); /** * Parse the line into the triplet. This is tested with unit tests, make sure to @@ -244,8 +244,8 @@ static ParsedData parse(String line) { return new ParsedData( 9, parseNs(m.group(1)), - parseNs(m.group(3)), - parseNs(m.group(5)) + parseNs(m.group(4)), + parseNs(m.group(6)) ); } } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java index 4a7dc9251..2af31ddff 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java @@ -89,4 +89,14 @@ public void parseJDK9b140_Comma() { Assert.assertEquals( 51_600L, data.ttspTime); } + @Test + public void parseJDK9b140_Whitespace() { + SafepointsProfiler.ParsedData data = SafepointsProfiler.parse( + "[71,633s][info][safepoint ] Total time for which application threads were stopped: 0,0359611 seconds, Stopping threads took: 0.0000516 seconds"); + Assert.assertNotNull(data); + Assert.assertEquals(71_633_000_000L, data.timestamp); + Assert.assertEquals( 35_961_100L, data.stopTime); + Assert.assertEquals( 51_600L, data.ttspTime); + } + } From e588dc2f386adddbda9e3f64637cc6068acab693 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 2 May 2017 21:12:36 +0200 Subject: [PATCH 107/342] 7901968: GC detection should be stricter: make sure finalization had run, make sure GC is silent, etc --- .../org/openjdk/jmh/runner/BaseRunner.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java index 5351d558a..63023be06 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java @@ -321,8 +321,20 @@ public boolean runSystemGC() { beforeGcCount += bean.getCollectionCount(); } - // this call is asynchronous, should check whether it completes + // Run the GC twice, and force finalization before each GCs. + System.runFinalization(); System.gc(); + System.runFinalization(); + System.gc(); + + // Now make sure GC actually happened. We have to wait for two things: + // a) That at least two collections happened, indicating GC work. + // b) That counter updates have not happened for a while, indicating GC work had ceased. + // + // Note there is an opportunity window for a concurrent GC to happen before the first + // System.gc() call, which would get counted towards our GCs. This race is unresolvable + // unless we have GC-specific information about the collection cycles, and verify those + // were indeed GCs triggered by us. final int MAX_WAIT_MSEC = 20 * 1000; @@ -336,6 +348,8 @@ public boolean runSystemGC() { return true; } + boolean gcHappened = false; + long start = System.nanoTime(); while (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) < MAX_WAIT_MSEC) { try { @@ -349,12 +363,24 @@ public boolean runSystemGC() { afterGcCount += bean.getCollectionCount(); } - if (afterGcCount > beforeGcCount) { - return true; + if (!gcHappened) { + if (afterGcCount - beforeGcCount >= 2) { + gcHappened = true; + } + } else { + if (afterGcCount == beforeGcCount) { + // Stable! + return true; + } + beforeGcCount = afterGcCount; } } - out.println("WARNING: System.gc() was invoked but couldn't detect a GC occuring, is System.gc() disabled?"); + if (gcHappened) { + out.println("WARNING: System.gc() was invoked but unable to wait while GC stopped, is GC too asynchronous?"); + } else { + out.println("WARNING: System.gc() was invoked but couldn't detect a GC occurring, is System.gc() disabled?"); + } return false; } return false; From b63de39123d7213409574c222cc3b3379db35564 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 3 May 2017 14:23:40 +0200 Subject: [PATCH 108/342] Amend 7901965: Fix accidental whitespace --- .../org/openjdk/jmh/runner/format/TextReportFormat.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index e288f29aa..ceb85b3f8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -62,9 +62,9 @@ public void startBenchmark(BenchmarkParams params) { } println("# JMH version: " + params.getJmhVersion()); - println("# VM version: JDK " + params.getJdkVersion() + ", VM " + params.getVmVersion()); - println("# VM invoker: " + params.getJvm()); - println("# VM options: " + opts); + println("# VM version: JDK " + params.getJdkVersion() + ", VM " + params.getVmVersion()); + println("# VM invoker: " + params.getJvm()); + println("# VM options: " + opts); IterationParams warmup = params.getWarmup(); if (warmup.getCount() > 0) { From 36a79dacbd682094ff14d024a40e328a44c2803e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 3 May 2017 14:23:57 +0200 Subject: [PATCH 109/342] JMH v1.19 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 312be076f..f2f83dbf2 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.19-SNAPSHOT + 1.19 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 5eae7576d..6e89b1327 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.19-SNAPSHOT + 1.19 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index de9f576df..73fa2e605 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.19-SNAPSHOT + 1.19 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 271c3d2fd..7e421f887 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.19-SNAPSHOT + 1.19 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index d9cc83648..de5d8858a 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index a1795e865..2b86e89bc 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 39bdc13be..24bd0ff7f 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index d4b69dc8e..4f2c991bd 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index b8c4d4467..7ab7ec4a3 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index fbe6626bd..f73151c6c 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 1fda73df0..84b90fdbc 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 35848e786..5d1f5ba49 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 5120d6934..c958113fa 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index c53d30306..78823f083 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.19-SNAPSHOT + 1.19 JMH Samples diff --git a/pom.xml b/pom.xml index 3f1629381..3748ef596 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.19-SNAPSHOT + 1.19 Java Microbenchmark Harness Parent From 66173c4aeedb591594d4ad6e232143f4237d90c3 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 3 May 2017 14:24:06 +0200 Subject: [PATCH 110/342] Added tag 1.19 for changeset b7dc6e851f12 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index dc6fa7bbe..48f8fc917 100644 --- a/.hgtags +++ b/.hgtags @@ -87,3 +87,4 @@ d4a8ae32b9063cf17c699455ced1b0d718f4977a 1.17.3 3b9b9cd865e38cf19d08687754ff99eb982e662f 1.17.4 5e3781c05e283dd4f5a71503e7cd7b9b151e5484 1.17.5 6eb89dc11810e824b1f5416033cb1cf1f5f30f63 1.18 +b7dc6e851f12a5bf2086f6f5d963d939ea5bd509 1.19 From 201716902a6bade52749ea72dfcfafc47058aca1 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 3 May 2017 14:24:25 +0200 Subject: [PATCH 111/342] Continue in 1.20-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index f2f83dbf2..de37935ef 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.19 + 1.20-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 6e89b1327..66209552a 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.19 + 1.20-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 73fa2e605..eabd2ec18 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.19 + 1.20-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 7e421f887..9d1b5a6e7 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.19 + 1.20-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index de5d8858a..916671940 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 2b86e89bc..71af36707 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 24bd0ff7f..13bbc1a93 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 4f2c991bd..137dfd5d4 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 7ab7ec4a3..00cdc47da 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index f73151c6c..5a92f2eb2 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 84b90fdbc..700d920a6 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 5d1f5ba49..3da177134 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index c958113fa..9ec9ba541 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 78823f083..620dd067c 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.19 + 1.20-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 3748ef596..914806575 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.19 + 1.20-SNAPSHOT Java Microbenchmark Harness Parent From 8ed50d61818ca76c882906b6ed6c8c6b484fbddf Mon Sep 17 00:00:00 2001 From: Christoph Dreis Date: Thu, 18 May 2017 11:28:46 +0200 Subject: [PATCH 112/342] 7901984: Cleanup unused code in BenchmarkGenerator --- .../generators/core/BenchmarkGenerator.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 937641c7c..69ac73337 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -81,7 +81,7 @@ public void generate(GeneratorSource source, GeneratorDestination destination) { validateBenchmark(clazz, clazzes.get(clazz)); Collection infos = makeBenchmarkInfo(clazz, clazzes.get(clazz)); for (BenchmarkInfo info : infos) { - generateClass(source, destination, clazz, info); + generateClass(destination, clazz, info); } benchmarkInfos.addAll(infos); } catch (GenerationException ge) { @@ -436,7 +436,7 @@ private Collection makeBenchmarkInfo(ClassInfo clazz, Collection< /** * Create and generate Java code for a class and it's methods */ - private void generateClass(GeneratorSource source, GeneratorDestination destination, ClassInfo classInfo, BenchmarkInfo info) throws IOException { + private void generateClass(GeneratorDestination destination, ClassInfo classInfo, BenchmarkInfo info) throws IOException { StateObjectHandler states = new StateObjectHandler(compilerControl); // bind all methods @@ -469,7 +469,7 @@ private void generateClass(GeneratorSource source, GeneratorDestination destinat // write all methods for (Mode benchmarkKind : Mode.values()) { if (benchmarkKind == Mode.All) continue; - generateMethod(classInfo, benchmarkKind, writer, info.methodGroup, states); + generateMethod(benchmarkKind, writer, info.methodGroup, states); } // Write out state initializers @@ -520,31 +520,31 @@ private void generateImport(PrintWriter writer) { /** * Generate the method for a specific benchmark method */ - private void generateMethod(ClassInfo classInfo, Mode benchmarkKind, PrintWriter writer, MethodGroup methodGroup, StateObjectHandler states) { + private void generateMethod(Mode benchmarkKind, PrintWriter writer, MethodGroup methodGroup, StateObjectHandler states) { writer.println(); switch (benchmarkKind) { case Throughput: - generateThroughput(classInfo, writer, benchmarkKind, methodGroup, states); + generateThroughput(writer, benchmarkKind, methodGroup, states); break; case AverageTime: - generateAverageTime(classInfo, writer, benchmarkKind, methodGroup, states); + generateAverageTime(writer, benchmarkKind, methodGroup, states); break; case SampleTime: - generateSampleTime(classInfo, writer, benchmarkKind, methodGroup, states); + generateSampleTime(writer, benchmarkKind, methodGroup, states); break; case SingleShotTime: - generateSingleShotTime(classInfo, writer, benchmarkKind, methodGroup, states); + generateSingleShotTime(writer, benchmarkKind, methodGroup, states); break; default: throw new AssertionError("Shouldn't be here"); } } - private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { + private void generateThroughput(PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { writer.println(ident(1) + "public BenchmarkTaskResult " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {"); - methodProlog(writer, methodGroup); + methodProlog(writer); boolean isSingleMethod = (methodGroup.methods().size() == 1); int subGroup = -1; @@ -633,7 +633,7 @@ private void generateThroughput(ClassInfo classInfo, PrintWriter writer, Mode be writer.println(ident(3) + "results.add(" + res + ");"); } - methodEpilog(writer, methodGroup); + methodEpilog(writer); writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); @@ -676,11 +676,11 @@ private void addAuxCounters(PrintWriter writer, String resName, StateObjectHandl } } - private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { + private void generateAverageTime(PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { writer.println(ident(1) + "public BenchmarkTaskResult " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {"); - methodProlog(writer, methodGroup); + methodProlog(writer); boolean isSingleMethod = (methodGroup.methods().size() == 1); int subGroup = -1; @@ -765,7 +765,7 @@ private void generateAverageTime(ClassInfo classInfo, PrintWriter writer, Mode b } addAuxCounters(writer, "AverageTimeResult", states, method); - methodEpilog(writer, methodGroup); + methodEpilog(writer); writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); @@ -811,7 +811,7 @@ private String getStubTypeArgs() { "Blackhole blackhole, Control notifyControl, int startRndMask"; } - private void methodProlog(PrintWriter writer, MethodGroup methodGroup) { + private void methodProlog(PrintWriter writer) { // do nothing writer.println(ident(2) + "this.benchmarkParams = control.benchmarkParams;"); writer.println(ident(2) + "this.iterationParams = control.iterationParams;"); @@ -822,7 +822,7 @@ private void methodProlog(PrintWriter writer, MethodGroup methodGroup) { writer.println(ident(2) + "}"); } - private void methodEpilog(PrintWriter writer, MethodGroup methodGroup) { + private void methodEpilog(PrintWriter writer) { writer.println(ident(3) + "this.blackhole.evaporate(\"Yes, I am Stephen Hawking, and know a thing or two about black holes.\");"); } @@ -834,11 +834,11 @@ private String prefix(String argList) { } } - private void generateSampleTime(ClassInfo classInfo, PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { + private void generateSampleTime(PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { writer.println(ident(1) + "public BenchmarkTaskResult " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {"); - methodProlog(writer, methodGroup); + methodProlog(writer); boolean isSingleMethod = (methodGroup.methods().size() == 1); int subGroup = -1; @@ -920,7 +920,7 @@ private void generateSampleTime(ClassInfo classInfo, PrintWriter writer, Mode be writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.SECONDARY, \"" + method.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); } - methodEpilog(writer, methodGroup); + methodEpilog(writer); writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); @@ -981,10 +981,10 @@ private void generateSampleTime(ClassInfo classInfo, PrintWriter writer, Mode be } } - private void generateSingleShotTime(ClassInfo classInfo, PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { + private void generateSingleShotTime(PrintWriter writer, Mode benchmarkKind, MethodGroup methodGroup, StateObjectHandler states) { writer.println(ident(1) + "public BenchmarkTaskResult " + methodGroup.getName() + "_" + benchmarkKind + "(InfraControl control, ThreadParams threadParams) throws Throwable {"); - methodProlog(writer, methodGroup); + methodProlog(writer); boolean isSingleMethod = (methodGroup.methods().size() == 1); int subGroup = -1; @@ -1027,7 +1027,7 @@ private void generateSingleShotTime(ClassInfo classInfo, PrintWriter writer, Mod writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + methodGroup.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.SECONDARY, \"" + method.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); } - methodEpilog(writer, methodGroup); + methodEpilog(writer); writer.println(ident(3) + "return results;"); writer.println(ident(2) + "} else"); From 6ddef1dd37fd8d279cdbb1b3d1dbdbe7c6a1a70e Mon Sep 17 00:00:00 2001 From: Michal Vala Date: Thu, 18 May 2017 11:32:24 +0200 Subject: [PATCH 113/342] 7901985: Typo in jvmAppendArgs help --- .../java/org/openjdk/jmh/runner/options/CommandLineOptions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java index 285aeeda9..615bb1f57 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java @@ -207,7 +207,7 @@ public CommandLineOptions(String... argv) throws CommandLineOptionException { .withRequiredArg().ofType(String.class).describedAs("string"); OptionSpec optJvmArgsAppend = parser.accepts("jvmArgsAppend", "Same as jvmArgs, but append these " + - "options before the already given JVM args.") + "options after the already given JVM args.") .withRequiredArg().ofType(String.class).describedAs("string"); OptionSpec optJvmArgsPrepend = parser.accepts("jvmArgsPrepend", "Same as jvmArgs, but prepend these " + From 34d2793543e91682cf0e05e8b831bf0dad9e7d38 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 7 Jun 2017 15:19:29 +0200 Subject: [PATCH 114/342] 7901990: Make sure only a single profiler of given type is used --- .../it/profilers/DuplicateProfilerTest.java | 115 ++++++++++++++++++ .../java/org/openjdk/jmh/runner/Runner.java | 4 + 2 files changed, 119 insertions(+) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java new file mode 100644 index 000000000..31f9b8ab1 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2017, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.CommandLineOptionException; +import org.openjdk.jmh.runner.options.CommandLineOptions; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; + +import java.util.concurrent.TimeUnit; + +public class DuplicateProfilerTest { + + @Benchmark + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) + @Fork(1) + public void bench() { + // intentionally left blank + } + + @Test + public void testInternal_API() { + try { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(ItInternalProfiler.class) + .addProfiler(ItInternalProfiler.class) + .build(); + new Runner(opts).run(); + Assert.fail("Expected to fail"); + } catch (RunnerException e) { + String msg = e.getMessage(); + Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler")); + } + } + + @Test + public void testExternal_API() { + try { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(ItExternalProfiler.class) + .addProfiler(ItExternalProfiler.class) + .build(); + new Runner(opts).run(); + Assert.fail("Expected to fail"); + } catch (RunnerException e) { + String msg = e.getMessage(); + Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler")); + } + } + + @Test + public void testInternal_CLI() throws CommandLineOptionException { + try { + Options opts = new CommandLineOptions( + "-prof", ItInternalProfiler.class.getCanonicalName(), + "-prof", ItInternalProfiler.class.getCanonicalName(), + Fixtures.getTestMask(this.getClass())); + new Runner(opts).run(); + Assert.fail("Expected to fail"); + } catch (RunnerException e) { + String msg = e.getMessage(); + Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler")); + } + } + + @Test + public void testExternal_CLI() throws CommandLineOptionException { + try { + Options opts = new CommandLineOptions( + "-prof", ItExternalProfiler.class.getCanonicalName(), + "-prof", ItExternalProfiler.class.getCanonicalName(), + Fixtures.getTestMask(this.getClass())); + new Runner(opts).run(); + Assert.fail("Expected to fail"); + } catch (RunnerException e) { + String msg = e.getMessage(); + Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler")); + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 79f47bce0..f36de5f89 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -225,8 +225,12 @@ public Collection run() throws RunnerException { } private Collection internalRun() throws RunnerException { + Set profilerClasses = new HashSet<>(); boolean someProfilersFail = false; for (ProfilerConfig p : options.getProfilers()) { + if (!profilerClasses.add(p.getKlass())) { + throw new RunnerException("Cannot instantiate the same profiler more than once: " + p.getKlass()); + } try { ProfilerFactory.getProfilerOrException(p); } catch (ProfilerException e) { From d512409712c4fc211be5657a7c8aaf8b2790c25d Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 7 Sep 2017 13:28:40 +0200 Subject: [PATCH 115/342] Typo in org.openjdk.jmh.annotations.Param javadoc --- jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java index 121b5b7c0..68c35253c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Param.java @@ -34,7 +34,7 @@ *

    Marks the configurable parameter in the benchmark.

    * *

    {@link Param} fields should be non-final fields, - * and should only reside in in {@link State} classes. JMH will inject + * and should only reside in {@link State} classes. JMH will inject * the value into the annotated field before any {@link Setup} method * is called. It is not guaranteed the field value would be accessible * in any initializer or any constructor of {@link State}.

    From 6071cdb845b26637485fdc9c87a0a8e711c1573e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Sep 2017 14:30:27 +0200 Subject: [PATCH 116/342] 7902040: JMH Core Benchmarks should include more advanced timing tests --- .../CurrentTimeMillisTimerBench.java | 55 ++++++++++ .../tests/TimingMeasurementsTest.java | 102 ++++++++++++++---- 2 files changed, 134 insertions(+), 23 deletions(-) create mode 100644 jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CurrentTimeMillisTimerBench.java diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CurrentTimeMillisTimerBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CurrentTimeMillisTimerBench.java new file mode 100644 index 000000000..835d9af1b --- /dev/null +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CurrentTimeMillisTimerBench.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.benchmarks; + +import org.openjdk.jmh.annotations.*; + +import java.util.concurrent.TimeUnit; + +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@BenchmarkMode(Mode.AverageTime) +@Warmup(iterations = 5, time = 1) +@Measurement(iterations = 5, time = 1) +public class CurrentTimeMillisTimerBench { + + private long last; + + @Benchmark + public long latency() { + return System.currentTimeMillis(); + } + + @Benchmark + public long granularity() { + long lst = last; + long cur; + do { + cur = System.currentTimeMillis(); + } while (cur == lst); + last = cur; + return cur; + } +} diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/TimingMeasurementsTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/TimingMeasurementsTest.java index 5380f34ba..b3f441794 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/TimingMeasurementsTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/TimingMeasurementsTest.java @@ -24,6 +24,10 @@ */ package org.openjdk.jmh.validation.tests; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.benchmarks.CurrentTimeMillisTimerBench; +import org.openjdk.jmh.benchmarks.EmptyBench; import org.openjdk.jmh.benchmarks.NanoTimerBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; @@ -50,36 +54,88 @@ public void runWith(PrintWriter pw, Options parent) throws RunnerException { 80, 2); pw.println(); - { - Options opts = new OptionsBuilder() - .parent(parent) - .include(NanoTimerBench.class.getCanonicalName() + ".latency$") - .verbosity(VerboseMode.SILENT) - .build(); + doNanoTime(pw, parent, "latency", false); + doNanoTime(pw, parent, "latency", true); - RunResult result = new Runner(opts).runSingle(); - Result r = result.getPrimaryResult(); + pw.println(); - pw.printf("%50s", "System.nanoTime latency: "); - pw.flush(); - pw.printf("%.2f \u00b1 %.2f ns\n", r.getScore(), r.getScoreError()); - } + doCurrentTimeMillis(pw, parent, "latency", false); + doCurrentTimeMillis(pw, parent, "latency", true); - { - Options opts = new OptionsBuilder() - .parent(parent) - .include(NanoTimerBench.class.getCanonicalName() + ".granularity$") - .verbosity(VerboseMode.SILENT) - .build(); + pw.println(); - RunResult result = new Runner(opts).runSingle(); - Result r = result.getPrimaryResult(); + doNanoTime(pw, parent, "granularity", false); + doNanoTime(pw, parent, "granularity", true); - pw.printf("%50s", "System.nanoTime granularity: "); - pw.flush(); - pw.printf("%.2f \u00b1 %.2f ns\n", r.getScore(), r.getScoreError()); + pw.println(); + + doCurrentTimeMillis(pw, parent, "granularity", false); + doCurrentTimeMillis(pw, parent, "granularity", true); + + pw.println(); + + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + doEmpty(pw, parent, mode, false); + } + + pw.println(); + + for (Mode mode : Mode.values()) { + if (mode == Mode.All) continue; + doEmpty(pw, parent, mode, true); } pw.println(); } + + private void doEmpty(PrintWriter pw, Options parent, Mode mode, boolean max) throws RunnerException { + Options opts = new OptionsBuilder() + .parent(parent) + .include(EmptyBench.class.getCanonicalName()) + .verbosity(VerboseMode.SILENT) + .threads(max ? Threads.MAX : 1) + .mode(mode) + .build(); + + RunResult result = new Runner(opts).runSingle(); + Result r = result.getPrimaryResult(); + + pw.printf("%50s", mode + ", empty benchmark, " + (max ? "max thread" : "one thread") + ": "); + pw.flush(); + pw.printf("%10.2f \u00b1 %10.2f %s\n", r.getScore(), r.getScoreError(), r.getScoreUnit()); + } + + void doNanoTime(PrintWriter pw, Options parent, String type, boolean max) throws RunnerException { + Options opts = new OptionsBuilder() + .parent(parent) + .include(NanoTimerBench.class.getCanonicalName() + "." + type + "$") + .verbosity(VerboseMode.SILENT) + .threads(max ? Threads.MAX : 1) + .build(); + + RunResult result = new Runner(opts).runSingle(); + Result r = result.getPrimaryResult(); + + pw.printf("%50s", "nanoTime() " + type + ", " + (max ? "max thread" : "one thread") + ": "); + pw.flush(); + pw.printf("%10.2f \u00b1 %10.2f ns\n", r.getScore(), r.getScoreError()); + } + + void doCurrentTimeMillis(PrintWriter pw, Options parent, String type, boolean max) throws RunnerException { + Options opts = new OptionsBuilder() + .parent(parent) + .include(CurrentTimeMillisTimerBench.class.getCanonicalName() + "." + type + "$") + .verbosity(VerboseMode.SILENT) + .threads(max ? Threads.MAX : 1) + .build(); + + RunResult result = new Runner(opts).runSingle(); + Result r = result.getPrimaryResult(); + + pw.printf("%50s", "currentTimeMillis() " + type + ", " + (max ? "max thread" : "one thread") + ": "); + pw.flush(); + pw.printf("%10.2f \u00b1 %10.2f ns\n", r.getScore(), r.getScoreError()); + } + } From ff15b7457a3514af739a92dcefafbd61c6a7f405 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Sep 2017 18:11:47 +0200 Subject: [PATCH 117/342] 7902041: Make sure JMH builds and runs with JDK 9 GA --- jmh-archetypes/pom.xml | 5 +- jmh-core-benchmarks/pom.xml | 4 - jmh-core-ct/pom.xml | 6 - jmh-core-it/pom.xml | 10 -- jmh-core/pom.xml | 15 --- .../jmh/profile/AbstractHotspotProfiler.java | 111 ++++++++++++--- .../profile/HotspotClassloadingProfiler.java | 11 +- .../profile/HotspotCompilationProfiler.java | 9 +- .../jmh/profile/HotspotMemoryProfiler.java | 11 +- .../jmh/profile/HotspotRuntimeProfiler.java | 9 +- .../jmh/profile/HotspotThreadProfiler.java | 9 +- jmh-generator-annprocess/pom.xml | 3 - jmh-generator-asm/pom.xml | 4 - jmh-generator-bytecode/pom.xml | 4 - jmh-generator-reflection/pom.xml | 3 - jmh-samples/pom.xml | 4 - pom.xml | 126 +++++++++++++++++- 17 files changed, 221 insertions(+), 123 deletions(-) diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 916671940..3b832f783 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -52,7 +52,7 @@ questions. maven-archetype-plugin - 2.2 + 3.0.1 integration-test @@ -74,7 +74,7 @@ questions. maven-archetype-plugin - 2.2 + 3.0.1 integration-test @@ -94,7 +94,6 @@ questions. org.apache.maven.plugins maven-resources-plugin - 2.5 \ diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 71af36707..9acadbf3f 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -66,7 +66,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.0 1.7 1.7 @@ -76,7 +75,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 always true @@ -85,7 +83,6 @@ questions. org.apache.maven.plugins maven-shade-plugin - 2.0 benchmarks @@ -127,7 +124,6 @@ questions. com.mycila.maven-license-plugin maven-license-plugin - 1.10.b1 diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 13bbc1a93..2201abe39 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -67,7 +67,6 @@ questions. junit junit - 4.10 test @@ -81,7 +80,6 @@ questions. com.mycila.maven-license-plugin maven-license-plugin - 1.10.b1 @@ -103,7 +101,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.0 1.7 1.7 @@ -131,7 +128,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 true -Djmh.ct.generator=annprocess @@ -148,7 +144,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 true -Djmh.ct.generator=asm @@ -165,7 +160,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 true -Djmh.ct.generator=reflection diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 137dfd5d4..c60256300 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -52,7 +52,6 @@ questions. junit junit - 4.10 test @@ -66,7 +65,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 -Djmh.ignoreLock=true -Xms256m -Xmx256m -Djmh.core.it.profile=${jmh.core.it.profile} @@ -79,7 +77,6 @@ questions. com.mycila.maven-license-plugin maven-license-plugin - 1.10.b1 @@ -122,7 +119,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.0 1.7 1.7 @@ -150,7 +146,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.0 1.7 1.7 @@ -181,7 +176,6 @@ questions. org.codehaus.mojo build-helper-maven-plugin - 1.8 add-source @@ -200,7 +194,6 @@ questions. org.codehaus.mojo exec-maven-plugin - 1.2.1 process-test-sources @@ -240,7 +233,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.0 1.7 1.7 @@ -271,7 +263,6 @@ questions. org.codehaus.mojo build-helper-maven-plugin - 1.8 add-source @@ -290,7 +281,6 @@ questions. org.codehaus.mojo exec-maven-plugin - 1.2.1 process-test-sources diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 00cdc47da..910602cfc 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -54,18 +54,15 @@ questions. junit junit - 4.10 test net.sf.jopt-simple jopt-simple - 4.6 org.apache.commons commons-math3 - 3.2 @@ -80,7 +77,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.1 1.7 1.7 @@ -92,7 +88,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 true @@ -101,7 +96,6 @@ questions. com.mycila.maven-license-plugin maven-license-plugin - 1.10.b1 @@ -123,7 +117,6 @@ questions. org.apache.maven.plugins maven-site-plugin - 3.2 @@ -154,13 +147,11 @@ questions. org.apache.maven.plugins maven-site-plugin - 3.0 org.apache.maven.plugins maven-javadoc-plugin - 2.9 @@ -180,25 +171,21 @@ questions. org.codehaus.mojo cobertura-maven-plugin - 2.5.2 org.apache.maven.plugins maven-surefire-report-plugin - 2.14.1 org.apache.maven.plugins maven-jxr-plugin - 2.3 org.codehaus.mojo findbugs-maven-plugin - 2.5.2 Max Low @@ -209,7 +196,6 @@ questions. org.apache.maven.plugins maven-checkstyle-plugin - 2.10 false ${project.basedir}/src/main/resources/checkstyle.xml @@ -219,7 +205,6 @@ questions. org.codehaus.mojo taglist-maven-plugin - 2.4 diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java index de38f7483..60b87950a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java @@ -27,26 +27,27 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; -import sun.management.counter.Counter; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.*; abstract class AbstractHotspotProfiler implements InternalProfiler { - private Map prevs; + private final Method getListMethod; + private final Object bean; - /** - * Returns internal counters for specific MXBean - * @return list of internal counters. - */ - protected abstract Collection getCounters(); + private Map prevs; - public AbstractHotspotProfiler() throws ProfilerException { + public AbstractHotspotProfiler(String beanName) throws ProfilerException { try { - Class.forName("sun.management.ManagementFactoryHelper"); - } catch (ClassNotFoundException e) { - throw new ProfilerException("Class not found: " + e.getMessage() + ", are you running HotSpot VM?"); + Class helper = Class.forName("sun.management.ManagementFactoryHelper"); + bean = helper.getMethod("get" + beanName).invoke(null); + getListMethod = bean.getClass().getMethod("getInternalRuntimeCounters"); + getListMethod.setAccessible(true); + getListMethod.invoke(bean); // try + } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + throw new ProfilerException("Problem initializing profiler (" + e.getMessage() + "), are you running HotSpot VM?"); } } @@ -63,7 +64,7 @@ public Collection afterIteration(BenchmarkParams benchmarkPara @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { prevs = new HashMap<>(); - for (Counter counter : getCounters()) { + for (HotspotCounter counter : getCounters()) { prevs.put(counter.getName(), convert(counter.getValue())); } } @@ -79,7 +80,7 @@ public static Long convert(Object o) { protected HotspotInternalResult counters() { Map difference = new TreeMap<>(); Map current = new TreeMap<>(); - for (Counter counter : getCounters()) { + for (HotspotCounter counter : getCounters()) { Long prev = prevs.get(counter.getName()); if (prev != null) { long diff = convert(counter.getValue()) - prev; @@ -91,12 +92,19 @@ protected HotspotInternalResult counters() { return new HotspotInternalResult(current, difference); } - public static T getInstance(String name) { + public List getCounters() { try { - Object o = Class.forName("sun.management.ManagementFactoryHelper").getMethod("get" + name).invoke(null); - return (T) o; - } catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { - throw new IllegalStateException("Should not be here"); + List counters = new ArrayList<>(); + for (Object c : (List) getListMethod.invoke(bean)) { + try { + counters.add(new HotspotCounter(c)); + } catch (UnsupportedOperationException e) { + // ignore this counter + } + } + return counters; + } catch (IllegalAccessException | InvocationTargetException e) { + throw new IllegalStateException("Should not be here", e); } } @@ -125,4 +133,71 @@ public String toString() { return "difference: " + diff.toString(); } } + + /** + * Reflective proxy for Hotspot counters to dodge compatibility problems. + */ + private static class HotspotCounter { + private static final Method GET_VALUE; + private static final Method GET_NAME; + + static { + Method name = null; + Method value = null; + try { + Class cntClass = Class.forName("sun.management.counter.Counter"); + if (cntClass != null) { + try { + name = cntClass.getMethod("getName"); + } catch (NoSuchMethodException e) { + // do nothing + } + try { + value = cntClass.getMethod("getValue"); + } catch (NoSuchMethodException e) { + // do nothing + } + } + } catch (ClassNotFoundException e) { + // no nothing + } + + GET_NAME = name; + GET_VALUE = value; + } + + private final Object proxy; + + public HotspotCounter(Object proxy) throws UnsupportedOperationException { + this.proxy = proxy; + + // Try these right now + if (GET_NAME == null || GET_VALUE == null) { + throw new UnsupportedOperationException(); + } + try { + String k = (String) GET_NAME.invoke(proxy); + Object v = GET_VALUE.invoke(proxy); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new UnsupportedOperationException(e); + } + } + + public String getName() { + try { + return (String) GET_NAME.invoke(proxy); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new IllegalStateException("Cannot be here"); + } + } + + public Object getValue() { + try { + return GET_VALUE.invoke(proxy); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new IllegalStateException("Cannot be here"); + } + } + } + } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java index 3a97033c9..2410bce5b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java @@ -24,19 +24,10 @@ */ package org.openjdk.jmh.profile; -import sun.management.HotspotClassLoadingMBean; -import sun.management.counter.Counter; - -import java.util.List; - public class HotspotClassloadingProfiler extends AbstractHotspotProfiler { public HotspotClassloadingProfiler() throws ProfilerException { - } - - @Override - public List getCounters() { - return AbstractHotspotProfiler.getInstance("HotspotClassLoadingMBean").getInternalClassLoadingCounters(); + super("HotspotClassLoadingMBean"); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java index 455b6d79a..9158c9fdd 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java @@ -27,23 +27,16 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; -import sun.management.HotspotCompilationMBean; -import sun.management.counter.Counter; import java.util.Arrays; import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; public class HotspotCompilationProfiler extends AbstractHotspotProfiler { public HotspotCompilationProfiler() throws ProfilerException { - } - - @Override - public List getCounters() { - return AbstractHotspotProfiler.getInstance("HotspotCompilationMBean").getInternalCompilerCounters(); + super("HotspotCompilationMBean"); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java index d4d9d2dbd..8c1a17f01 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java @@ -24,19 +24,10 @@ */ package org.openjdk.jmh.profile; -import sun.management.HotspotMemoryMBean; -import sun.management.counter.Counter; - -import java.util.List; - public class HotspotMemoryProfiler extends AbstractHotspotProfiler { public HotspotMemoryProfiler() throws ProfilerException { - } - - @Override - public List getCounters() { - return AbstractHotspotProfiler.getInstance("HotspotMemoryMBean").getInternalMemoryCounters(); + super("HotspotMemoryMBean"); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java index 276839efb..9c9cceb54 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java @@ -27,23 +27,16 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; -import sun.management.HotspotRuntimeMBean; -import sun.management.counter.Counter; import java.util.Arrays; import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; public class HotspotRuntimeProfiler extends AbstractHotspotProfiler { public HotspotRuntimeProfiler() throws ProfilerException { - } - - @Override - public List getCounters() { - return AbstractHotspotProfiler.getInstance("HotspotRuntimeMBean").getInternalRuntimeCounters(); + super("HotspotRuntimeMBean"); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java index 1e5696103..a668e224a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java @@ -27,22 +27,15 @@ import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.infra.IterationParams; import org.openjdk.jmh.results.*; -import sun.management.HotspotThreadMBean; -import sun.management.counter.Counter; import java.util.Arrays; import java.util.Collection; -import java.util.List; import java.util.Map; public class HotspotThreadProfiler extends AbstractHotspotProfiler { public HotspotThreadProfiler() throws ProfilerException { - } - - @Override - public List getCounters() { - return AbstractHotspotProfiler.getInstance("HotspotThreadMBean").getInternalThreadingCounters(); + super("HotspotThreadMBean"); } @Override diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 5a92f2eb2..71b5bd5a1 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -59,7 +59,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.1 1.7 1.7 @@ -71,7 +70,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 false @@ -80,7 +78,6 @@ questions. com.mycila.maven-license-plugin maven-license-plugin - 1.10.b1 diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 700d920a6..65a07cd9e 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -55,7 +55,6 @@ questions. org.ow2.asm asm - 5.0.3 @@ -68,7 +67,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.1 1.7 1.7 @@ -80,7 +78,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 false @@ -89,7 +86,6 @@ questions. com.mycila.maven-license-plugin maven-license-plugin - 1.10.b1 diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 3da177134..89615a51e 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -68,7 +68,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.1 1.7 1.7 @@ -80,7 +79,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 false @@ -89,7 +87,6 @@ questions. com.mycila.maven-license-plugin maven-license-plugin - 1.10.b1 @@ -111,7 +108,6 @@ questions. org.apache.maven.plugins maven-shade-plugin - 2.0 package diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 9ec9ba541..8f237f5a0 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -58,7 +58,6 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.1 1.7 1.7 @@ -70,7 +69,6 @@ questions. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 false @@ -79,7 +77,6 @@ questions. com.mycila.maven-license-plugin maven-license-plugin - 1.10.b1 diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 620dd067c..f19068663 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -73,7 +73,6 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-compiler-plugin - 3.0 1.7 1.7 @@ -83,7 +82,6 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-surefire-plugin - 2.14.1 always true @@ -92,7 +90,6 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-shade-plugin - 2.0 package @@ -115,7 +112,6 @@ THE POSSIBILITY OF SUCH DAMAGE. com.mycila.maven-license-plugin maven-license-plugin - 1.10.b1 diff --git a/pom.xml b/pom.xml index 914806575..c9286b975 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ questions. shade Aleksey Shipilev - Oracle/Sun + Oracle/Sun, Red Hat current-development @@ -105,7 +105,6 @@ questions. org.apache.maven.plugins maven-source-plugin - 2.2.1 attach-sources @@ -121,7 +120,6 @@ questions. org.apache.maven.plugins maven-javadoc-plugin - 2.9 true @@ -140,7 +138,6 @@ questions. org.apache.maven.plugins maven-eclipse-plugin - 2.9 true true @@ -150,7 +147,6 @@ questions. org.apache.maven.plugins maven-enforcer-plugin - 1.4.1 enforce-maven @@ -168,8 +164,128 @@ questions. + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + + org.apache.maven.plugins + maven-shade-plugin + 2.2 + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.4.1 + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.10 + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.0-M1 + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + + com.mycila.maven-license-plugin + maven-license-plugin + 1.10.b1 + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + org.codehaus.mojo + exec-maven-plugin + 1.3.1 + + + org.apache.maven.plugins + maven-site-plugin + 3.3 + + + org.codehaus.mojo + cobertura-maven-plugin + 2.6 + + + org.apache.maven.plugins + maven-jxr-plugin + 2.4 + + + org.codehaus.mojo + findbugs-maven-plugin + 2.5.3 + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.12.1 + + + org.codehaus.mojo + taglist-maven-plugin + 2.4 + + + + + + + junit + junit + 4.10 + test + + + net.sf.jopt-simple + jopt-simple + 4.6 + + + org.apache.commons + commons-math3 + 3.2 + + + org.ow2.asm + asm + 5.0.3 + + + + + + 3.0 + + jmh-core jmh-core-it From bf733e09c9d57d61bff23b40e22fcc12c61b5d6f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 20 Dec 2017 20:47:59 +0100 Subject: [PATCH 118/342] 7902085: hs_* profilers regression: typo in getInternalRuntimeCounter, should be getInternalTYPECounter --- .../AbstractHotspotProfilerTest.java | 48 +++++++++++++++++ .../HotspotClassloadingProfilerTest.java | 53 ++++++++++++++++++ .../HotspotCompilationProfilerTest.java | 54 +++++++++++++++++++ .../profilers/HotspotMemoryProfilerTest.java | 54 +++++++++++++++++++ .../profilers/HotspotRuntimeProfilerTest.java | 54 +++++++++++++++++++ .../profilers/HotspotThreadProfilerTest.java | 54 +++++++++++++++++++ .../jmh/profile/AbstractHotspotProfiler.java | 4 +- .../profile/HotspotClassloadingProfiler.java | 2 +- .../profile/HotspotCompilationProfiler.java | 2 +- .../jmh/profile/HotspotMemoryProfiler.java | 2 +- .../jmh/profile/HotspotRuntimeProfiler.java | 2 +- .../jmh/profile/HotspotThreadProfiler.java | 2 +- 12 files changed, 324 insertions(+), 7 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractHotspotProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractHotspotProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractHotspotProfilerTest.java new file mode 100644 index 000000000..fd35d10fb --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractHotspotProfilerTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.openjdk.jmh.annotations.*; + +import java.util.concurrent.TimeUnit; + +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Fork(1) // 0 to enable debugging +@Warmup(iterations = 5) +@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@BenchmarkMode(Mode.AverageTime) +public class AbstractHotspotProfilerTest { + + @Benchmark + public Object alloc() { + return new Object(); + } + + boolean isHotspotVM() { + String name = System.getProperty("java.vm.name"); + return (name.contains("OpenJDK") || name.contains("HotSpot")); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java new file mode 100644 index 000000000..1b5234779 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.HotspotClassloadingProfiler; +import org.openjdk.jmh.profile.ProfilerException; +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; + +public class HotspotClassloadingProfilerTest extends AbstractHotspotProfilerTest { + + @Test + public void test() throws RunnerException { + try { + new HotspotClassloadingProfiler(); + } catch (ProfilerException e) { + Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); + return; + } + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(HotspotClassloadingProfiler.class) + .build(); + new Runner(opts).run(); + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java new file mode 100644 index 000000000..608c452a6 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.HotspotClassloadingProfiler; +import org.openjdk.jmh.profile.HotspotCompilationProfiler; +import org.openjdk.jmh.profile.ProfilerException; +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; + +public class HotspotCompilationProfilerTest extends AbstractHotspotProfilerTest { + + @Test + public void test() throws RunnerException { + try { + new HotspotCompilationProfiler(); + } catch (ProfilerException e) { + Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); + return; + } + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(HotspotCompilationProfiler.class) + .build(); + new Runner(opts).run(); + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java new file mode 100644 index 000000000..62f785096 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.HotspotCompilationProfiler; +import org.openjdk.jmh.profile.HotspotMemoryProfiler; +import org.openjdk.jmh.profile.ProfilerException; +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; + +public class HotspotMemoryProfilerTest extends AbstractHotspotProfilerTest { + + @Test + public void test() throws RunnerException { + try { + new HotspotMemoryProfiler(); + } catch (ProfilerException e) { + Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); + return; + } + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(HotspotMemoryProfiler.class) + .build(); + new Runner(opts).run(); + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java new file mode 100644 index 000000000..480a4dc8c --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.HotspotMemoryProfiler; +import org.openjdk.jmh.profile.HotspotRuntimeProfiler; +import org.openjdk.jmh.profile.ProfilerException; +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; + +public class HotspotRuntimeProfilerTest extends AbstractHotspotProfilerTest { + + @Test + public void test() throws RunnerException { + try { + new HotspotRuntimeProfiler(); + } catch (ProfilerException e) { + Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); + return; + } + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(HotspotRuntimeProfiler.class) + .build(); + new Runner(opts).run(); + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java new file mode 100644 index 000000000..113e9c2a1 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.HotspotRuntimeProfiler; +import org.openjdk.jmh.profile.HotspotThreadProfiler; +import org.openjdk.jmh.profile.ProfilerException; +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; + +public class HotspotThreadProfilerTest extends AbstractHotspotProfilerTest { + + @Test + public void test() throws RunnerException { + try { + new HotspotThreadProfiler(); + } catch (ProfilerException e) { + Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); + return; + } + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(HotspotThreadProfiler.class) + .build(); + new Runner(opts).run(); + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java index 60b87950a..3c1f12cc7 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java @@ -39,11 +39,11 @@ abstract class AbstractHotspotProfiler implements InternalProfiler { private Map prevs; - public AbstractHotspotProfiler(String beanName) throws ProfilerException { + public AbstractHotspotProfiler(String beanName, String methodName) throws ProfilerException { try { Class helper = Class.forName("sun.management.ManagementFactoryHelper"); bean = helper.getMethod("get" + beanName).invoke(null); - getListMethod = bean.getClass().getMethod("getInternalRuntimeCounters"); + getListMethod = bean.getClass().getMethod(methodName); getListMethod.setAccessible(true); getListMethod.invoke(bean); // try } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java index 2410bce5b..f8cf068c0 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java @@ -27,7 +27,7 @@ public class HotspotClassloadingProfiler extends AbstractHotspotProfiler { public HotspotClassloadingProfiler() throws ProfilerException { - super("HotspotClassLoadingMBean"); + super("HotspotClassLoadingMBean", "getInternalClassLoadingCounters"); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java index 9158c9fdd..e46c8b08e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java @@ -36,7 +36,7 @@ public class HotspotCompilationProfiler extends AbstractHotspotProfiler { public HotspotCompilationProfiler() throws ProfilerException { - super("HotspotCompilationMBean"); + super("HotspotCompilationMBean", "getInternalCompilerCounters"); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java index 8c1a17f01..ff72794f1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java @@ -27,7 +27,7 @@ public class HotspotMemoryProfiler extends AbstractHotspotProfiler { public HotspotMemoryProfiler() throws ProfilerException { - super("HotspotMemoryMBean"); + super("HotspotMemoryMBean", "getInternalMemoryCounters"); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java index 9c9cceb54..8d1f589f8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java @@ -36,7 +36,7 @@ public class HotspotRuntimeProfiler extends AbstractHotspotProfiler { public HotspotRuntimeProfiler() throws ProfilerException { - super("HotspotRuntimeMBean"); + super("HotspotRuntimeMBean", "getInternalRuntimeCounters"); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java index a668e224a..a699d169b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java @@ -35,7 +35,7 @@ public class HotspotThreadProfiler extends AbstractHotspotProfiler { public HotspotThreadProfiler() throws ProfilerException { - super("HotspotThreadMBean"); + super("HotspotThreadMBean", "getInternalThreadingCounters"); } @Override From 8fec77647da8dc18945d90dd0c959e76e167062b Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 21 Dec 2017 08:21:17 +0100 Subject: [PATCH 119/342] 7902088: External profilers should be called with before/afterTrial during warmup forks --- .../profilers/CountingExternalProfiler.java | 89 +++++++++++++++++++ .../CountingExternalProfilerTest.java | 77 ++++++++++++++++ .../java/org/openjdk/jmh/runner/Runner.java | 39 +++----- 3 files changed, 180 insertions(+), 25 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfiler.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfiler.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfiler.java new file mode 100644 index 000000000..22709b86d --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfiler.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.openjdk.jmh.infra.BenchmarkParams; +import org.openjdk.jmh.profile.ExternalProfiler; +import org.openjdk.jmh.results.BenchmarkResult; +import org.openjdk.jmh.results.Result; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicInteger; + +public class CountingExternalProfiler implements ExternalProfiler { + + static final AtomicInteger jvmOpts = new AtomicInteger(); + static final AtomicInteger jvmInvokeOpts = new AtomicInteger(); + static final AtomicInteger beforeTrial = new AtomicInteger(); + static final AtomicInteger afterTrial = new AtomicInteger(); + + public static void reset() { + jvmOpts.set(0); + jvmInvokeOpts.set(0); + beforeTrial.set(0); + afterTrial.set(0); + } + + @Override + public boolean allowPrintErr() { + return true; + } + + @Override + public boolean allowPrintOut() { + return true; + } + + @Override + public Collection addJVMOptions(BenchmarkParams params) { + jvmOpts.incrementAndGet(); + return Collections.emptyList(); + } + + @Override + public Collection addJVMInvokeOptions(BenchmarkParams params) { + jvmInvokeOpts.incrementAndGet(); + return Collections.emptyList(); + } + + @Override + public void beforeTrial(BenchmarkParams benchmarkParams) { + beforeTrial.incrementAndGet(); + } + + @Override + public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { + afterTrial.incrementAndGet(); + return Collections.emptyList(); + } + + @Override + public String getDescription() { + return "Integration Test External Profiler with Stage Counting"; + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java new file mode 100644 index 000000000..cdc3ba8b5 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +public class CountingExternalProfilerTest { + + @Benchmark + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) + @Fork(1) + public void bench() { + // intentionally left blank + } + + @Test + public void test() throws RunnerException { + for (int warmupForks : new int[]{0, 1, 5}) { + for (int forks : new int[]{1, 5}) { + CountingExternalProfiler.reset(); + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(CountingExternalProfiler.class) + .forks(forks) + .warmupForks(warmupForks) + .build(); + new Runner(opts).run(); + + Assert.assertEquals("jvmOpts count is correct for warmupForks = " + warmupForks + ", and forks = " + forks, + warmupForks + forks, CountingExternalProfiler.jvmOpts.get()); + Assert.assertEquals("jvmInvokeOpts count is correct for warmupForks = " + warmupForks + ", and forks = " + forks, + warmupForks + forks, CountingExternalProfiler.jvmInvokeOpts.get()); + Assert.assertEquals("afterTrial count is correct for warmupForks = " + warmupForks + ", and forks = " + forks, + warmupForks + forks, CountingExternalProfiler.afterTrial.get()); + Assert.assertEquals("beforeTrial count is correct for warmupForks = " + warmupForks + ", and forks = " + forks, + warmupForks + forks, CountingExternalProfiler.beforeTrial.get()); + } + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index f36de5f89..9eff9cbc9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -619,34 +619,21 @@ private Multimap runSeparate(ActionPlan action int forkCount = params.getForks(); int warmupForkCount = params.getWarmupForks(); - if (warmupForkCount > 0) { - for (int i = 0; i < warmupForkCount; i++) { - List forkedString = getForkedMainCommand(params, profilers, server.getHost(), server.getPort()); - out.verbosePrintln("Warmup forking using command: " + forkedString); - - etaBeforeBenchmark(); - out.println("# Warmup Fork: " + (i + 1) + " of " + warmupForkCount); - - TempFile stdErr = FileUtils.weakTempFile("stderr"); - TempFile stdOut = FileUtils.weakTempFile("stdout"); - - doFork(server, forkedString, stdOut.file(), stdErr.file(), printOut, printErr); - - etaAfterBenchmark(params); - out.println(""); - - // we know these are not needed anymore, proactively delete - stdErr.delete(); - stdOut.delete(); - } - } + int totalForks = warmupForkCount + forkCount; - for (int i = 0; i < forkCount; i++) { + for (int i = 0; i < totalForks; i++) { + boolean warmupFork = (i < warmupForkCount); List forkedString = getForkedMainCommand(params, profilers, server.getHost(), server.getPort()); - out.verbosePrintln("Forking using command: " + forkedString); etaBeforeBenchmark(); - out.println("# Fork: " + (i + 1) + " of " + forkCount); + + if (warmupFork) { + out.verbosePrintln("Warmup forking using command: " + forkedString); + out.println("# Warmup Fork: " + (i + 1) + " of " + warmupForkCount); + } else { + out.verbosePrintln("Forking using command: " + forkedString); + out.println("# Fork: " + (i + 1 - warmupForkCount) + " of " + forkCount); + } TempFile stdErr = FileUtils.weakTempFile("stderr"); TempFile stdOut = FileUtils.weakTempFile("stdout"); @@ -691,7 +678,9 @@ private Multimap runSeparate(ActionPlan action out.println(""); } - results.put(params, br); + if (!warmupFork) { + results.put(params, br); + } } etaAfterBenchmark(params); From ce3abee3723499bd02a9ab132eda79c538a8644b Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Tue, 16 Jan 2018 12:13:36 +0100 Subject: [PATCH 120/342] 7902095: Support enum params that override Object#toString() --- .../EnumParamToStringOverridingTest.java | 76 +++++++++++++++++++ .../jmh/generators/asm/ASMClassInfo.java | 2 +- .../generators/reflection/RFClassInfo.java | 2 +- 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java new file mode 100644 index 000000000..638263b3f --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.params; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) +@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS) +@Fork(1) +@State(Scope.Thread) +public class EnumParamToStringOverridingTest { + + @Param({"VALUE_A", "VALUE_B", "VALUE_C"}) + public SampleEnumA a; + + @Benchmark + public void test() { + Fixtures.work(); + } + + @Test + public void normal() throws RunnerException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .build(); + + Assert.assertEquals(3, new Runner(opts).run().size()); + } + + public enum SampleEnumA { + VALUE_A, VALUE_B, VALUE_C; + + @Override + public String toString() { + return name().toLowerCase(); + } + } +} diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java index 8badf9b2f..c7b85a12a 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java @@ -221,7 +221,7 @@ public Collection getEnumConstants() { try { Collection res = new ArrayList<>(); for (Object cnst : Class.forName(origQualifiedName, false, Thread.currentThread().getContextClassLoader()).getEnumConstants()) { - res.add(cnst.toString()); + res.add(((Enum) cnst).name()); } return res; } catch (ClassNotFoundException e) { diff --git a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java index 327da999e..6d8b7da96 100644 --- a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java +++ b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java @@ -162,7 +162,7 @@ public boolean isEnum() { public Collection getEnumConstants() { Collection res = new ArrayList<>(); for (Object cnst : klass.getEnumConstants()) { - res.add(cnst.toString()); + res.add(((Enum) cnst).name()); } return res; } From 3dcd570f0b62a75ae06f1b819e947a649c446485 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 17 Jan 2018 11:53:49 +0100 Subject: [PATCH 121/342] 7902096: State order DAG does not work correctly with mixed Scope-d state objects --- .../MixedBGTIterationDagOrderTest.java | 124 +++++++++++++++++ .../dagorder/MixedBGTTrialDagOrderTest.java | 124 +++++++++++++++++ .../MixedBTGIterationDagOrderTest.java | 124 +++++++++++++++++ .../dagorder/MixedBTGTrialDagOrderTest.java | 124 +++++++++++++++++ .../MixedGBTIterationDagOrderTest.java | 125 ++++++++++++++++++ .../dagorder/MixedGBTTrialDagOrderTest.java | 125 ++++++++++++++++++ .../MixedGTBIterationDagOrderTest.java | 125 ++++++++++++++++++ .../dagorder/MixedGTBTrialDagOrderTest.java | 125 ++++++++++++++++++ .../MixedTBGIterationDagOrderTest.java | 124 +++++++++++++++++ .../dagorder/MixedTBGTrialDagOrderTest.java | 124 +++++++++++++++++ .../MixedTGBIterationDagOrderTest.java | 124 +++++++++++++++++ .../dagorder/MixedTGBTrialDagOrderTest.java | 124 +++++++++++++++++ .../generators/core/StateObjectHandler.java | 37 ++---- 13 files changed, 1506 insertions(+), 23 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTIterationDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTTrialDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGIterationDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGTrialDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTIterationDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTTrialDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBIterationDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBTrialDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGIterationDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGTrialDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBIterationDagOrderTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBTrialDagOrderTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTIterationDagOrderTest.java new file mode 100644 index 000000000..073be5195 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTIterationDagOrderTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedBGTIterationDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Thread) + public static class S3 { + + @Setup(Level.Iteration) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Group) + public static class S2 { + + @Setup(Level.Iteration) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Benchmark) + public static class S1 { + + @Setup(Level.Iteration) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @Threads(1) + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTTrialDagOrderTest.java new file mode 100644 index 000000000..6bc913cd0 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTTrialDagOrderTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedBGTTrialDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Thread) + public static class S3 { + + @Setup(Level.Trial) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Group) + public static class S2 { + + @Setup(Level.Trial) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Benchmark) + public static class S1 { + + @Setup(Level.Trial) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @Threads(1) + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGIterationDagOrderTest.java new file mode 100644 index 000000000..b6a42f881 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGIterationDagOrderTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedBTGIterationDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Group) + public static class S3 { + + @Setup(Level.Iteration) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Thread) + public static class S2 { + + @Setup(Level.Iteration) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Benchmark) + public static class S1 { + + @Setup(Level.Iteration) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @Threads(1) + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGTrialDagOrderTest.java new file mode 100644 index 000000000..ba5ec8db6 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGTrialDagOrderTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedBTGTrialDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Group) + public static class S3 { + + @Setup(Level.Trial) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Thread) + public static class S2 { + + @Setup(Level.Trial) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Benchmark) + public static class S1 { + + @Setup(Level.Trial) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @Threads(1) + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTIterationDagOrderTest.java new file mode 100644 index 000000000..297b7e5fc --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTIterationDagOrderTest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedGBTIterationDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Thread) + public static class S3 { + + @Setup(Level.Iteration) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Benchmark) + public static class S2 { + + @Setup(Level.Iteration) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Group) + public static class S1 { + + @Setup(Level.Iteration) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @GroupThreads(1) + @Group + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTTrialDagOrderTest.java new file mode 100644 index 000000000..2a34825d2 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTTrialDagOrderTest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedGBTTrialDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Thread) + public static class S3 { + + @Setup(Level.Trial) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Benchmark) + public static class S2 { + + @Setup(Level.Trial) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Group) + public static class S1 { + + @Setup(Level.Trial) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @GroupThreads(1) + @Group + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBIterationDagOrderTest.java new file mode 100644 index 000000000..4976cc54a --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBIterationDagOrderTest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedGTBIterationDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Benchmark) + public static class S3 { + + @Setup(Level.Iteration) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Thread) + public static class S2 { + + @Setup(Level.Iteration) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Group) + public static class S1 { + + @Setup(Level.Iteration) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @GroupThreads(1) + @Group + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBTrialDagOrderTest.java new file mode 100644 index 000000000..c298a188a --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBTrialDagOrderTest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedGTBTrialDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Benchmark) + public static class S3 { + + @Setup(Level.Trial) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Thread) + public static class S2 { + + @Setup(Level.Trial) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Group) + public static class S1 { + + @Setup(Level.Trial) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @GroupThreads(1) + @Group + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGIterationDagOrderTest.java new file mode 100644 index 000000000..944d21b8a --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGIterationDagOrderTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedTBGIterationDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Group) + public static class S3 { + + @Setup(Level.Iteration) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Benchmark) + public static class S2 { + + @Setup(Level.Iteration) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Thread) + public static class S1 { + + @Setup(Level.Iteration) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @Threads(1) + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGTrialDagOrderTest.java new file mode 100644 index 000000000..5bf1f1ba5 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGTrialDagOrderTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedTBGTrialDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Group) + public static class S3 { + + @Setup(Level.Trial) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Benchmark) + public static class S2 { + + @Setup(Level.Trial) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Thread) + public static class S1 { + + @Setup(Level.Trial) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @Threads(1) + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBIterationDagOrderTest.java new file mode 100644 index 000000000..10570fcda --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBIterationDagOrderTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedTGBIterationDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Benchmark) + public static class S3 { + + @Setup(Level.Iteration) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Group) + public static class S2 { + + @Setup(Level.Iteration) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Thread) + public static class S1 { + + @Setup(Level.Iteration) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Iteration) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @Threads(1) + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBTrialDagOrderTest.java new file mode 100644 index 000000000..818c4af25 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBTrialDagOrderTest.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.dagorder; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests global setup -> run -> tearDown sequence. + */ +public class MixedTGBTrialDagOrderTest { + + public static final AtomicInteger TICKER = new AtomicInteger(); + + private static volatile int s1setup, s1teardown; + private static volatile int s2setup, s2teardown; + private static volatile int s3setup, s3teardown; + private static volatile int run; + + @State(Scope.Benchmark) + public static class S3 { + + @Setup(Level.Trial) + public void setupInstance() { + s3setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s3teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Group) + public static class S2 { + + @Setup(Level.Trial) + public void setupInstance(S3 s3) { + s2setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s2teardown = TICKER.incrementAndGet(); + } + } + + @State(Scope.Thread) + public static class S1 { + + @Setup(Level.Trial) + public void setupInstance(S2 s2) { + s1setup = TICKER.incrementAndGet(); + } + + @TearDown(Level.Trial) + public void tearDownInstance() { + s1teardown = TICKER.incrementAndGet(); + } + } + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(0) + @Threads(1) + public void test(S1 state) { + run = TICKER.incrementAndGet(); + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + for (int c = 0; c < Fixtures.repetitionCount(); c++) { + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .syncIterations(false) + .build(); + new Runner(opt).run(); + + + Assert.assertTrue(s3setup + " < " + s2setup, s3setup < s2setup); + Assert.assertTrue(s2setup + " < " + s1setup, s2setup < s1setup); + Assert.assertTrue(s1setup + " < " + run, s1setup < run); + + Assert.assertTrue(run + " < " + s1teardown, run < s1teardown); + Assert.assertTrue(s1teardown + " < " + s2teardown, s1teardown < s2teardown); + Assert.assertTrue(s2teardown + " < " + s3teardown, s2teardown < s3teardown); + } + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 35d987c57..20705a179 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -588,9 +588,9 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H // Handle Thread object helpers for (StateObject so : statesForward) { - if (so.scope != Scope.Thread) continue; + if (type != HelperType.SETUP) continue; - if (type == HelperType.SETUP) { + if (so.scope == Scope.Thread) { for (HelperMethodInvocation mi : so.getHelpers()) { if (mi.helperLevel == helperLevel && mi.type == HelperType.SETUP) { Collection args = so.helperArgs.get(mi.method.getQualifiedName()); @@ -598,26 +598,8 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H } } } - } - - for (StateObject so : statesReverse) { - if (so.scope != Scope.Thread) continue; - - if (type == HelperType.TEARDOWN) { - for (HelperMethodInvocation mi : so.getHelpers()) { - if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) { - Collection args = so.helperArgs.get(mi.method.getQualifiedName()); - result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); - } - } - } - } - - // Handle Benchmark/Group object helpers - for (StateObject so : statesForward) { - if (so.scope != Scope.Benchmark && so.scope != Scope.Group) continue; - if (type == HelperType.SETUP) { + if (so.scope == Scope.Benchmark || so.scope == Scope.Group) { result.add("if (" + so.type + ".setup" + helperLevel + "MutexUpdater.compareAndSet(" + so.localIdentifier + ", 0, 1)) {"); result.add(" try {"); result.add(" if (control.isFailing) throw new FailureAssistException();"); @@ -646,9 +628,18 @@ public Collection getHelperBlock(MethodInfo method, Level helperLevel, H } for (StateObject so : statesReverse) { - if (so.scope != Scope.Benchmark && so.scope != Scope.Group) continue; + if (type != HelperType.TEARDOWN) continue; + + if (so.scope == Scope.Thread) { + for (HelperMethodInvocation mi : so.getHelpers()) { + if (mi.helperLevel == helperLevel && mi.type == HelperType.TEARDOWN) { + Collection args = so.helperArgs.get(mi.method.getQualifiedName()); + result.add(so.localIdentifier + "." + mi.method.getName() + "(" + Utils.join(args, ",") + ");"); + } + } + } - if (type == HelperType.TEARDOWN) { + if (so.scope == Scope.Benchmark || so.scope == Scope.Group) { result.add("if (" + so.type + ".tear" + helperLevel + "MutexUpdater.compareAndSet(" + so.localIdentifier + ", 0, 1)) {"); result.add(" try {"); result.add(" if (control.isFailing) throw new FailureAssistException();"); From ca20f5f331c56999a5b9de7e0a6734970e1e49b3 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 22 Jan 2018 17:50:08 +0100 Subject: [PATCH 122/342] Linux perf should not assume cycles/instructions counters are always available --- .../main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java | 2 +- .../java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index 8f5390c1d..f6b5b6c36 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -44,7 +44,7 @@ public class LinuxPerfAsmProfiler extends AbstractPerfAsmProfiler { private OptionSpec optFrequency; public LinuxPerfAsmProfiler(String initLine) throws ProfilerException { - super(initLine, "cycles", "instructions"); + super(initLine, "cycles"); Collection failMsg = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "echo", "1"); if (!failMsg.isEmpty()) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index 955dab156..5dccd36df 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -127,7 +127,7 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { if (supportedEvents.isEmpty()) { for (String ev : interestingEvents) { - Collection res = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--event", "cycles,instructions," + ev, "echo", "1"); + Collection res = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--event", ev, "echo", "1"); if (res.isEmpty()) { supportedEvents.add(ev); } From 2c1ad7f44e7d1067f490c1c2313d10761de040ba Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Mon, 22 Jan 2018 18:04:43 +0100 Subject: [PATCH 123/342] 7902097: dtraceasm profiler for Mac OS X --- .../jmh/profile/AbstractPerfAsmProfiler.java | 20 +- .../jmh/profile/DTraceAsmProfiler.java | 218 ++++++++++++++++++ .../openjdk/jmh/profile/ProfilerFactory.java | 2 +- .../main/java/org/openjdk/jmh/util/Utils.java | 25 ++ .../jmh/samples/JMHSample_35_Profilers.java | 4 +- 5 files changed, 257 insertions(+), 12 deletions(-) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index e6ca41c34..5d30c2455 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -270,7 +270,7 @@ public void beforeTrial(BenchmarkParams params) { @Override public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { - PerfResult result = processAssembly(br, stdOut, stdErr); + PerfResult result = processAssembly(br); // we know these are not needed anymore, proactively delete hsLog.delete(); @@ -311,7 +311,7 @@ public boolean allowPrintErr() { */ protected abstract String perfBinaryExtension(); - private PerfResult processAssembly(BenchmarkResult br, File stdOut, File stdErr) { + private PerfResult processAssembly(BenchmarkResult br) { /** * 1. Parse binary events. */ @@ -647,11 +647,11 @@ private static void printLine(PrintWriter pw, PerfEvents events, String event, l } } - void printDottedLine(PrintWriter pw) { + private void printDottedLine(PrintWriter pw) { printDottedLine(pw, null); } - void printDottedLine(PrintWriter pw, String header) { + private void printDottedLine(PrintWriter pw, String header) { final int HEADER_WIDTH = 100; pw.print("...."); @@ -668,7 +668,7 @@ void printDottedLine(PrintWriter pw, String header) { pw.println(); } - List makeRegions(Assembly asms, PerfEvents events) { + private List makeRegions(Assembly asms, PerfEvents events) { List regions = new ArrayList<>(); SortedSet allAddrs = events.getAllAddresses(); @@ -728,7 +728,7 @@ private List figureHotIntervals(SortedSet addrs) { return intervals; } - Collection> splitAssembly(File stdOut) { + private Collection> splitAssembly(File stdOut) { try (FileReader in = new FileReader(stdOut); BufferedReader br = new BufferedReader(in)) { Multimap writerToLines = new HashMultimap<>(); @@ -764,7 +764,7 @@ Collection> splitAssembly(File stdOut) { } } - Assembly readAssembly(File stdOut) { + private Assembly readAssembly(File stdOut) { List lines = new ArrayList<>(); SortedMap addressMap = new TreeMap<>(); @@ -919,11 +919,11 @@ public String extendedInfo() { static class PerfResultAggregator implements Aggregator { @Override public PerfResult aggregate(Collection results) { - String output = ""; + StringBuilder output = new StringBuilder(); for (PerfResult r : results) { - output += r.output; + output.append(r.output); } - return new PerfResult(output); + return new PerfResult(output.toString()); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java new file mode 100644 index 000000000..d3ee7189e --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.profile; + +import joptsimple.OptionException; +import joptsimple.OptionParser; +import joptsimple.OptionSpec; +import org.openjdk.jmh.infra.BenchmarkParams; +import org.openjdk.jmh.results.BenchmarkResult; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.util.*; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.TreeMap; +import java.util.concurrent.TimeUnit; + +/** + * Mac OS X perfasm profiler based on DTrace "profile-n" provider which samples program counter by timer interrupt. + * Due to DTrace limitations on Mac OS X target JVM cannot be run directly under DTrace control, so DTrace is run separately, + * all processes are sampled and irrelevant samples are filtered out in {@link #readEvents(double, double)} stage. + * Super user privileges are required in order to run DTrace. + *

    + * If you see a lot of "[unknown]" regions in profile then you are probably hitting kernel code, kernel sampling is not yet supported. + * + * @author Tolstopyatov Vsevolod + * @since 18/10/2017 + */ +public class DTraceAsmProfiler extends AbstractPerfAsmProfiler { + + private final long sampleFrequency; + private volatile String pid; + private volatile Process dtraceProcess; + private OptionSpec optFrequency; + + public DTraceAsmProfiler(String initLine) throws ProfilerException { + super(initLine, "sampled_pc"); + + // Check DTrace availability + Collection messages = Utils.tryWith("sudo", "dtrace", "-V"); + if (!messages.isEmpty()) { + throw new ProfilerException(messages.toString()); + } + + try { + sampleFrequency = set.valueOf(optFrequency); + } catch (OptionException e) { + throw new ProfilerException(e.getMessage()); + } + } + + @Override + public void beforeTrial(BenchmarkParams params) { + super.beforeTrial(params); + } + + @Override + public Collection afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { + if (pid == 0) { + throw new IllegalStateException("DTrace needs the forked VM PID, but it is not initialized"); + } + + Collection messages = Utils.destroy(dtraceProcess); + if (!messages.isEmpty()) { + throw new IllegalStateException(messages.toString()); + } + + this.pid = String.valueOf(pid); + return super.afterTrial(br, pid, stdOut, stdErr); + } + + @Override + public Collection addJVMInvokeOptions(BenchmarkParams params) { + dtraceProcess = Utils.runAsync("sudo", "dtrace", "-n", "profile-" + sampleFrequency + + " /arg1/ { printf(\"%d 0x%lx %d\", pid, arg1, timestamp); ufunc(arg1)}", "-o", + perfBinData.getAbsolutePath()); + return Collections.emptyList(); + } + + @Override + public String getDescription() { + return "DTrace profile provider + PrintAssembly Profiler"; + } + + @Override + protected void addMyOptions(OptionParser parser) { + optFrequency = parser.accepts("frequency", + "Sampling frequency. This is synonymous to profile-#") + .withRequiredArg().ofType(Long.class).describedAs("freq").defaultsTo(1001L); + } + + @Override + protected void parseEvents() { + // Do nothing because DTrace writes text output anyway + } + + @Override + protected PerfEvents readEvents(double skipMs, double lenMs) { + long start = (long) skipMs; + long end = (long) (skipMs + lenMs); + + try (FileReader fr = new FileReader(perfBinData.file()); + BufferedReader reader = new BufferedReader(fr)) { + + Deduplicator dedup = new Deduplicator<>(); + Multimap methods = new HashMultimap<>(); + Multiset events = new TreeMultiset<>(); + + long dtraceTimestampBase = 0L; + String line; + while ((line = reader.readLine()) != null) { + + // Filter out DTrace misc + if (!line.contains(":profile")) { + continue; + } + + line = line.trim(); + line = line.substring(line.indexOf(":profile")); + String[] splits = line.split(" ", 5); + String sampledPid = splits[1]; + + if (!sampledPid.equals(pid)) { + continue; + } + + // Sometimes DTrace ufunc fails and gives no information about symbols + if (splits.length < 4) { + continue; + } + + long timestamp = Long.valueOf(splits[3]); + if (dtraceTimestampBase == 0) { + // Use first event timestamp as base for time comparison + dtraceTimestampBase = timestamp; + continue; + } + + long elapsed = timestamp - dtraceTimestampBase; + long elapsedMs = TimeUnit.NANOSECONDS.toMillis(elapsed); + + if (elapsedMs < start || elapsedMs > end) { + continue; + } + + long address = Long.decode(splits[2]); + events.add(address); + + String methodLine = splits[4]; + // JIT-compiled code has address instead of symbol information + if (methodLine.startsWith("0x")) { + continue; + } + + String symbol = "[unknown]"; + String[] methodSplit = methodLine.split("`"); + String library = methodSplit[0]; + if ("".equals(library)) { + library = "[unknown]"; + } + + if (methodSplit.length == 2) { + symbol = methodSplit[1]; + } + + methods.put(dedup.dedup(MethodDesc.nativeMethod(symbol, library)), address); + } + + IntervalMap methodMap = new IntervalMap<>(); + for (MethodDesc md : methods.keys()) { + Collection longs = methods.get(md); + methodMap.add(md, Utils.min(longs), Utils.max(longs)); + } + + Map> allEvents = new TreeMap<>(); + assert this.events.size() == 1; + allEvents.put(this.events.get(0), events); + return new PerfEvents(this.events, allEvents, methodMap); + + } catch (IOException e) { + return new PerfEvents(events); + } + + } + + @Override + protected String perfBinaryExtension() { + // DTrace produces human-readable txt + return ".txt"; + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java index 78db87e0e..be6d829a8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java @@ -27,7 +27,6 @@ import org.openjdk.jmh.runner.options.ProfilerConfig; import java.io.PrintStream; -import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.*; @@ -178,6 +177,7 @@ public static void listProfilers(PrintStream out) { BUILT_IN.put("perfnorm", LinuxPerfNormProfiler.class); BUILT_IN.put("perfasm", LinuxPerfAsmProfiler.class); BUILT_IN.put("xperfasm", WinPerfAsmProfiler.class); + BUILT_IN.put("dtraceasm", DTraceAsmProfiler.class); BUILT_IN.put("pauses", PausesProfiler.class); BUILT_IN.put("safepoints", SafepointsProfiler.class); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index cd21935a9..4f958915f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -446,6 +446,31 @@ public static Collection tryWith(String... cmd) { return messages; } + public static Process runAsync(String... cmd) { + try { + return new ProcessBuilder(cmd).start(); + } catch (IOException ex) { + throw new IllegalStateException(ex); + } + } + + public static Collection destroy(Process process) { + Collection messages = new ArrayList<>(); + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + process.destroy(); + int exitCode = process.waitFor(); + if (exitCode == 0) { + return Collections.emptyList(); + } + + messages.add(baos.toString()); + return messages; + } catch (InterruptedException e) { + throw new IllegalStateException(e); + } + } + public static Collection runWith(List cmd) { Collection messages = new ArrayList<>(); try { diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java index 12dc2125f..e74d6b4a4 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java @@ -33,6 +33,7 @@ import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; import org.openjdk.jmh.profile.ClassloaderProfiler; +import org.openjdk.jmh.profile.DTraceAsmProfiler; import org.openjdk.jmh.profile.LinuxPerfProfiler; import org.openjdk.jmh.profile.StackProfiler; import org.openjdk.jmh.runner.Runner; @@ -352,7 +353,7 @@ public long test() { * $ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof perfnorm -f 3 (Linux) * $ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof perfasm -f 1 (Linux) * $ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof xperfasm -f 1 (Windows) - * + * $ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof dtraceasm -f 1 (Mac OS X) * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: * http://openjdk.java.net/projects/code-tools/jmh/) @@ -365,6 +366,7 @@ public static void main(String[] args) throws RunnerException { // .addProfiler(LinuxPerfNormProfiler.class) // .addProfiler(LinuxPerfAsmProfiler.class) // .addProfiler(WinPerfAsmProfiler.class) +// .addProfiler(DTraceAsmProfiler.class) .build(); new Runner(opt).run(); From 30a5bc7a1d4f9126b1c1829f21634528497a3820 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 22 Jan 2018 18:10:17 +0100 Subject: [PATCH 124/342] Amend 7902097 with better failure message about Mac OS X SIP --- .../org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 5d30c2455..668b72c65 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -576,8 +576,10 @@ public int compare(Region o1, Region o2) { } if (sum < 1000) { - pw.println("WARNING: The perf event count is suspiciously low (" + sum + "). The performance data might be\n" + - "inaccurate or misleading. Try to do the profiling again, or tune up the sampling frequency."); + pw.println("WARNING: The perf event count is suspiciously low (" + sum + "). The performance data might be"); + pw.println("inaccurate or misleading. Try to do the profiling again, or tune up the sampling frequency."); + pw.println("With some profilers on Mac OS X, System Integrity Protection (SIP) may prevent profiling."); + pw.println("In such case, temporarily disabling SIP with 'csrutil disable' might help."); } } From d34d501896d9d8bef5059f5fba50731a95ff53da Mon Sep 17 00:00:00 2001 From: David Karnok Date: Mon, 22 Jan 2018 18:35:26 +0100 Subject: [PATCH 125/342] 7902106: jmh.separateClasspathJAR option to handle benchmarks with long classpath --- .../it/fork/ForkSeparateClasspathJARTest.java | 78 +++++++++++++++++ .../java/org/openjdk/jmh/runner/Runner.java | 87 ++++++++++++++++--- 2 files changed, 153 insertions(+), 12 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkSeparateClasspathJARTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkSeparateClasspathJARTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkSeparateClasspathJARTest.java new file mode 100644 index 000000000..db2e5c0c5 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fork/ForkSeparateClasspathJARTest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.fork; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.results.RunResult; +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 java.util.concurrent.TimeUnit; + +@Fork(1) +@Warmup(iterations = 0) +@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) +public class ForkSeparateClasspathJARTest { + + @Benchmark + public void test() { + Fixtures.work(); + } + + @Test + public void withEnabled() throws RunnerException { + System.setProperty("jmh.separateClasspathJAR", "true"); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .build(); + RunResult result = new Runner(opt).runSingle(); + + Assert.assertEquals(1, result.getAggregatedResult().getPrimaryResult().getSampleCount()); + } + + @Test + public void withDisabled() throws RunnerException { + System.setProperty("jmh.separateClasspathJAR", "false"); + + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .build(); + RunResult result = new Runner(opt).runSingle(); + + Assert.assertEquals(1, result.getAggregatedResult().getPrimaryResult().getSampleCount()); + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 9eff9cbc9..e6eef043f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -45,8 +45,11 @@ import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; +import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.jar.*; +import java.util.zip.*; /** * Runner executes JMH benchmarks. @@ -813,12 +816,7 @@ List getForkedMainCommand(BenchmarkParams benchmark, List getPrintPropertiesCommand(String jvm) { command.add(jvm); // assemble final process command - command.add("-cp"); - if (Utils.isWindows()) { - command.add('"' + System.getProperty("java.class.path") + '"'); - } else { - command.add(System.getProperty("java.class.path")); - } + addClasspath(command); command.add(PrintPropertiesMain.class.getName()); return command; } + private void addClasspath(List command) { + command.add("-cp"); + + String cpProp = System.getProperty("java.class.path"); + File tmpFile = null; + + String jvmargs = "" + + options.getJvmArgs().orElse(Collections.emptyList()) + + options.getJvmArgsPrepend().orElse(Collections.emptyList()) + + options.getJvmArgsAppend().orElse(Collections.emptyList()); + + // The second (creepy) test is for the cases when external plugins are not supplying + // the options properly. Looking at you, JMH Gradle plugin. In this case, we explicitly + // check if the option is provided by the user. + + if (Boolean.getBoolean("jmh.separateClasspathJAR") + || jvmargs.contains("jmh.separateClasspathJAR=true")) { + + // Classpath can be too long and overflow the command line length. + // Looking at you, Windows. + // + // The trick is to generate the JAR file with appropriate Class-Path manifest entry, + // and link it. The complication is that Class-Path entry paths are specified relative + // to JAR file loaded, which is probably somewhere in java.io.tmpdir, outside of current + // directory. Therefore, we have to relativize the paths to all the JAR entries. + + try { + tmpFile = FileUtils.tempFile("classpath.jar"); + Path tmpFileDir = tmpFile.toPath().getParent(); + + StringBuilder sb = new StringBuilder(); + for (String cp : cpProp.split(File.pathSeparator)) { + String rel = tmpFileDir.relativize(new File(cp).getAbsoluteFile().toPath()).toString(); + sb.append(rel.replace('\\', '/').replace(" ", "%20")); + if (!cp.endsWith(".jar")) { + sb.append('/'); + } + sb.append(" "); + } + String classPath = sb.toString().trim(); + + Manifest manifest = new Manifest(); + Attributes attrs = manifest.getMainAttributes(); + attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0"); + attrs.putValue("Class-Path", classPath); + + try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(tmpFile), manifest)) { + jos.putNextEntry(new ZipEntry("META-INF/")); + } + } catch (IOException ex) { + // Something is wrong in file generation, give up and fall-through to usual thing + tmpFile = null; + } + } + + if (tmpFile != null) { + if (Utils.isWindows()) { + command.add("\"" + tmpFile.getAbsolutePath() + "\""); + } else { + command.add(tmpFile.getAbsolutePath()); + } + } else { + if (Utils.isWindows()) { + command.add('"' + cpProp + '"'); + } else { + command.add(cpProp); + } + } + } + } From 9e4ad1df95db28fbb9371902859c643764ddab82 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 22 Jan 2018 22:39:43 +0100 Subject: [PATCH 126/342] 7902107: perfasm should provide better suggestion about PrintAssembly failures --- .../org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 668b72c65..077c39f43 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -334,7 +334,11 @@ private PerfResult processAssembly(BenchmarkResult br) { pw.println(); } else { pw.println(); - pw.println("ERROR: No address lines detected in assembly capture, make sure your JDK is PrintAssembly-enabled:\n https://wiki.openjdk.java.net/display/HotSpot/PrintAssembly"); + pw.println("ERROR: No address lines detected in assembly capture. Make sure your JDK is properly configured to"); + pw.println("print generated assembly. The most probable cause for this failure is that hsdis is not available,"); + pw.println("or resides at the wrong path within the JDK. Try to run the same JDK with -XX:+PrintAssembly with"); + pw.println("a simple non-JMH program and look for warning messages. For details, see the link below:"); + pw.println(" https://wiki.openjdk.java.net/display/HotSpot/PrintAssembly"); pw.println(); } From c51340a8b82c03c08ccd4dd37eba6ef85186d80f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 23 Jan 2018 09:43:51 +0100 Subject: [PATCH 127/342] JMH v1.20 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index de37935ef..ac30f7c45 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.20-SNAPSHOT + 1.20 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 66209552a..65747c052 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.20-SNAPSHOT + 1.20 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index eabd2ec18..d5115c5c8 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.20-SNAPSHOT + 1.20 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 9d1b5a6e7..a09023c41 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.20-SNAPSHOT + 1.20 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 3b832f783..631b1b7df 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 9acadbf3f..791c17122 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 2201abe39..d64893da4 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index c60256300..d5fe698ed 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 910602cfc..2f5ef1618 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 71b5bd5a1..05ac7a643 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 65a07cd9e..3b364f19c 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 89615a51e..e27749fd4 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 8f237f5a0..a33f62df8 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index f19068663..3f7311a23 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.20-SNAPSHOT + 1.20 JMH Samples diff --git a/pom.xml b/pom.xml index c9286b975..1833a6ee6 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.20-SNAPSHOT + 1.20 Java Microbenchmark Harness Parent From f4eefe3c03587b51a61d843f01739c00a7640e9c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 23 Jan 2018 09:43:57 +0100 Subject: [PATCH 128/342] Added tag 1.20 for changeset bd52958ab680 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 48f8fc917..3cd0411f6 100644 --- a/.hgtags +++ b/.hgtags @@ -88,3 +88,4 @@ d4a8ae32b9063cf17c699455ced1b0d718f4977a 1.17.3 5e3781c05e283dd4f5a71503e7cd7b9b151e5484 1.17.5 6eb89dc11810e824b1f5416033cb1cf1f5f30f63 1.18 b7dc6e851f12a5bf2086f6f5d963d939ea5bd509 1.19 +bd52958ab68089093f8c21d0a7c4af2848b845f6 1.20 From fa6fae2e9e13581d8b131927c1052a6810b1eec9 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 23 Jan 2018 09:44:15 +0100 Subject: [PATCH 129/342] Continue in 1.21-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index ac30f7c45..02ab93c34 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.20 + 1.21-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 65747c052..398a026bb 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.20 + 1.21-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index d5115c5c8..d69dd9c3f 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.20 + 1.21-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index a09023c41..b8508d841 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.20 + 1.21-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 631b1b7df..df1b8c541 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 791c17122..6896c455f 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index d64893da4..f5572a1f7 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index d5fe698ed..5aac4c350 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 2f5ef1618..c688258c4 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 05ac7a643..373e52b31 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 3b364f19c..0722d4b8c 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index e27749fd4..cb25005cd 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index a33f62df8..cdfb5fa26 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 3f7311a23..12c00e612 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.20 + 1.21-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 1833a6ee6..036b36a70 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.20 + 1.21-SNAPSHOT Java Microbenchmark Harness Parent From 605d4d13e21594858ba69647fb8334bf0859767c Mon Sep 17 00:00:00 2001 From: Eric Caspole Date: Thu, 3 May 2018 15:11:12 +0200 Subject: [PATCH 130/342] 7902164: JMH should support GraalVM in compiler hints detection --- .../src/main/java/org/openjdk/jmh/runner/CompilerHints.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java index 0dbb2dd26..d32fed2e8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java @@ -37,7 +37,7 @@ public class CompilerHints extends AbstractResourceReader { public static final String LIST = "/META-INF/CompilerHints"; // All OpenJDK/HotSpot VMs are supported - static final String[] HINT_COMPATIBLE_JVMS = { "OpenJDK", "HotSpot" }; + static final String[] HINT_COMPATIBLE_JVMS = { "OpenJDK", "HotSpot", "GraalVM" }; // Zing is only compatible from post 5.10.*.* releases static final String JVM_ZING = "Zing"; From 0adc046452b55e764f99fa7e38ff7a4f2d6c91f0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 3 May 2018 20:30:22 +0200 Subject: [PATCH 131/342] 7902165: Reconsider defaults for warmup and measurement iteration counts, durations --- .../src/main/java/org/openjdk/jmh/runner/Defaults.java | 8 ++++---- .../openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java | 6 ++---- .../org/openjdk/jmh/samples/JMHSample_03_States.java | 6 ++---- .../openjdk/jmh/samples/JMHSample_04_DefaultState.java | 6 ++---- .../openjdk/jmh/samples/JMHSample_05_StateFixtures.java | 6 ++---- .../openjdk/jmh/samples/JMHSample_06_FixtureLevel.java | 6 ++---- .../jmh/samples/JMHSample_07_FixtureLevelInvocation.java | 6 ++---- .../org/openjdk/jmh/samples/JMHSample_08_DeadCode.java | 6 ++---- .../org/openjdk/jmh/samples/JMHSample_09_Blackholes.java | 6 ++---- .../openjdk/jmh/samples/JMHSample_10_ConstantFold.java | 4 +--- .../java/org/openjdk/jmh/samples/JMHSample_11_Loops.java | 6 ++---- .../org/openjdk/jmh/samples/JMHSample_12_Forking.java | 5 +---- .../org/openjdk/jmh/samples/JMHSample_13_RunToRun.java | 4 ++-- .../org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java | 6 ++---- .../jmh/samples/JMHSample_16_CompilerControl.java | 6 +++--- .../openjdk/jmh/samples/JMHSample_17_SyncIterations.java | 9 +++++---- .../org/openjdk/jmh/samples/JMHSample_18_Control.java | 6 ++---- .../org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java | 5 ++--- .../org/openjdk/jmh/samples/JMHSample_30_Interrupts.java | 8 +++----- .../openjdk/jmh/samples/JMHSample_31_InfraParams.java | 6 ++---- .../org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java | 6 ++---- .../jmh/samples/JMHSample_33_SecurityManager.java | 4 ++-- .../openjdk/jmh/samples/JMHSample_34_SafeLooping.java | 2 -- 23 files changed, 49 insertions(+), 84 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java index dd3718e72..5aeccd6e7 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java @@ -40,7 +40,7 @@ public class Defaults { /** * Number of warmup iterations. */ - public static final int WARMUP_ITERATIONS = 20; + public static final int WARMUP_ITERATIONS = 5; /** * Number of warmup iterations in {@link org.openjdk.jmh.annotations.Mode#SingleShotTime} mode. @@ -55,12 +55,12 @@ public class Defaults { /** * The duration of warmup iterations. */ - public static final TimeValue WARMUP_TIME = TimeValue.seconds(1); + public static final TimeValue WARMUP_TIME = TimeValue.seconds(10); /** * Number of measurement iterations. */ - public static final int MEASUREMENT_ITERATIONS = 20; + public static final int MEASUREMENT_ITERATIONS = 5; /** * Number of measurement iterations in {@link org.openjdk.jmh.annotations.Mode#SingleShotTime} mode. @@ -75,7 +75,7 @@ public class Defaults { /** * The duration of measurement iterations. */ - public static final TimeValue MEASUREMENT_TIME = TimeValue.seconds(1); + public static final TimeValue MEASUREMENT_TIME = TimeValue.seconds(10); /** * Number of measurement threads. diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java index 83daf2432..61bbff94b 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java @@ -161,8 +161,8 @@ public void measureAll() throws InterruptedException { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_02 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_02 -f 1 + * (we requested a single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -172,8 +172,6 @@ public void measureAll() throws InterruptedException { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_02_BenchmarkModes.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java index f740d5967..7abfabd33 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java @@ -105,8 +105,8 @@ public void measureShared(BenchmarkState state) { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_03 -wi 5 -i 5 -t 4 -f 1 - * (we requested 5 measurement/warmup iterations, with 4 threads, single fork) + * $ java -jar target/benchmarks.jar JMHSample_03 -t 4 -f 1 + * (we requested 4 threads, single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -116,8 +116,6 @@ public void measureShared(BenchmarkState state) { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_03_States.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .threads(4) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java index 704570958..55970aebc 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java @@ -64,8 +64,8 @@ public void measure() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_04 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_04 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -75,8 +75,6 @@ public void measure() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_04_DefaultState.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java index fbe3d8460..28de69185 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java @@ -111,8 +111,8 @@ public void measureWrong() { * * a) Via the command line: * $ mvn clean install - * $ java -ea -jar target/benchmarks.jar JMHSample_05 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -ea -jar target/benchmarks.jar JMHSample_05 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -122,8 +122,6 @@ public void measureWrong() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_05_StateFixtures.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .jvmArgs("-ea") .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java index fdba38de0..c6c2fb99d 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java @@ -82,8 +82,8 @@ public void measureWrong() { * * a) Via the command line: * $ mvn clean install - * $ java -ea -jar target/benchmarks.jar JMHSample_06 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -ea -jar target/benchmarks.jar JMHSample_06 -f 1 + * (we requested single fork; there are also other options, see -h) * * You can optionally supply -foe to fail the complete run. * @@ -95,8 +95,6 @@ public void measureWrong() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_06_FixtureLevel.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .jvmArgs("-ea") .shouldFailOnError(false) // switch to "true" to fail the complete run diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java index 7604ba64a..aee76f865 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java @@ -148,8 +148,8 @@ public Double call() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_07 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_07 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -159,8 +159,6 @@ public Double call() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_07_FixtureLevelInvocation.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java index 5efebe6a2..6300d1da3 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java @@ -84,8 +84,8 @@ public double measureRight() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_08 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_08 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -95,8 +95,6 @@ public double measureRight() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_08_DeadCode.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java index 0f51aaa67..6a6ed630e 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java @@ -112,8 +112,8 @@ public void measureRight_2(Blackhole bh) { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_09 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_09 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -123,8 +123,6 @@ public void measureRight_2(Blackhole bh) { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_09_Blackholes.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java index c8394a0a2..d89c37de5 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java @@ -98,7 +98,7 @@ public double measureRight() { * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_10 -i 5 -f 1 - * (we requested 5 iterations, single fork) + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -108,8 +108,6 @@ public double measureRight() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_10_ConstantFold.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java index 132f3da97..3deb01e3d 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java @@ -138,8 +138,8 @@ public int measureWrong_100000() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_11 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_11 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -149,8 +149,6 @@ public int measureWrong_100000() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_11_Loops.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java index 78e6ad4a4..94ce21cfb 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java @@ -167,8 +167,7 @@ public int measure_5_forked_c2() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_12 -wi 5 -i 5 - * (we requested 5 warmup/measurement iterations) + * $ java -jar target/benchmarks.jar JMHSample_12 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -178,8 +177,6 @@ public int measure_5_forked_c2() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_12_Forking.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .build(); new Runner(opt).run(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java index 005ae487c..24091fcb6 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java @@ -109,7 +109,7 @@ public void fork_2(SleepyState s) throws InterruptedException { * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_13 -wi 0 -i 3 - * (we requested no warmup, 3 measurement iterations) + * (we requested no warmup, 3 measurement iterations; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -120,7 +120,7 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_13_RunToRun.class.getSimpleName()) .warmupIterations(0) - .measurementIterations(5) + .measurementIterations(3) .build(); new Runner(opt).run(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java index 5061df98e..e19da6f38 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java @@ -107,8 +107,8 @@ public int get() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_15 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_15 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -118,8 +118,6 @@ public int get() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_15_Asymmetric.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java index ed4224d2c..7dc9180ad 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java @@ -124,8 +124,8 @@ public void exclude() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_16 -wi 1 -i 3 -f 1 - * (we requested 1 warmup iterations, 3 iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_16 -wi 0 -i 3 -f 1 + * (we requested no warmup iterations, 3 iterations, single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -135,7 +135,7 @@ public void exclude() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_16_CompilerControl.class.getSimpleName()) - .warmupIterations(1) + .warmupIterations(0) .measurementIterations(3) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java index 725985f54..0b542a8ef 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java @@ -38,6 +38,7 @@ 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 java.util.concurrent.TimeUnit; @@ -103,8 +104,8 @@ public double test() { * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_17 \ - * -i 20 -wi 1 -f 1 -t ${CPU*16} -si {true|false} - * (we requested 1 warmup iterations, 20 iterations, single fork, + * -w 1s -r 1s -f 1 -t ${CPU*16} -si {true|false} + * (we requested shorter warmup/measurement iterations, single fork, * lots of threads, and changeable "synchronize iterations" option) * * b) Via the Java API: @@ -115,8 +116,8 @@ public double test() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_17_SyncIterations.class.getSimpleName()) - .warmupIterations(1) - .measurementIterations(20) + .warmupTime(TimeValue.seconds(1)) + .measurementTime(TimeValue.seconds(1)) .threads(Runtime.getRuntime().availableProcessors()*16) .forks(1) .syncIterations(true) // try to switch to "false" diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java index 299ef1b00..1f057a187 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java @@ -84,8 +84,8 @@ public void pong(Control cnt) { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_18 -wi 1 -i 5 -t 2 -f 1 - * (we requested 1 warmup iterations, 5 iterations, 2 threads, and single fork) + * $ java -jar target/benchmarks.jar JMHSample_18 -t 2 -f 1 + * (we requested 2 threads and single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -95,8 +95,6 @@ public void pong(Control cnt) { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_18_Control.class.getSimpleName()) - .warmupIterations(1) - .measurementIterations(5) .threads(2) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java index 91c3e3091..34db807f0 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java @@ -128,7 +128,8 @@ public void consume_1024() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_21 -w 1 -i 5 -f 1 + * $ java -jar target/benchmarks.jar JMHSample_21 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -138,8 +139,6 @@ public void consume_1024() { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_21_ConsumeCPU.class.getSimpleName()) - .warmupIterations(1) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java index 53043e4de..9b4e6a699 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java @@ -101,8 +101,8 @@ public void put() throws InterruptedException { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_30 -wi 5 -i 5 -t 2 -f 5 -to 5 - * (we requested 5 warmup iterations, 5 iterations, 2 threads, 5 forks, and 5 sec timeout) + * $ java -jar target/benchmarks.jar JMHSample_30 -t 2 -f 5 -to 10 + * (we requested 2 threads, 5 forks, and 10 sec timeout) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -112,11 +112,9 @@ public void put() throws InterruptedException { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_30_Interrupts.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .threads(2) .forks(5) - .timeout(TimeValue.seconds(5)) + .timeout(TimeValue.seconds(10)) .build(); new Runner(opt).run(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java index 312e8b5b2..abaa5a939 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java @@ -120,8 +120,8 @@ public void measureFollowThreads(Ids ids) { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_31 -wi 5 -i 5 -t 4 -f 5 - * (we requested 5 warmup iterations, 5 iterations, 2 threads, and 5 forks) + * $ java -jar target/benchmarks.jar JMHSample_31 -t 4 -f 5 + * (we requested 4 threads, and 5 forks; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -131,8 +131,6 @@ public void measureFollowThreads(Ids ids) { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_31_InfraParams.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .threads(4) .forks(5) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java index aa2666840..e4da01ce4 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java @@ -129,8 +129,8 @@ public int measure_c2() { * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_32 -f 1 -wi 5 -i 5 -wm BULK - * (we requested a single fork, 5 warmup/measurement iterations, and bulk warmup mode) + * $ java -jar target/benchmarks.jar JMHSample_32 -f 1 -wm BULK + * (we requested a single fork, and bulk warmup mode; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -142,8 +142,6 @@ public static void main(String[] args) throws RunnerException { .include(JMHSample_32_BulkWarmup.class.getSimpleName()) // .includeWarmup(...) <-- this may include other benchmarks into warmup .warmupMode(WarmupMode.BULK) // see other WarmupMode.* as well - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build(); diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_33_SecurityManager.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_33_SecurityManager.java index 79c0273d0..89fdcd251 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_33_SecurityManager.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_33_SecurityManager.java @@ -117,8 +117,8 @@ public String testWithoutSM(SecurityManagerEmpty s) throws InterruptedException * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_33 -wi 5 -i 5 -f 1 - * (we requested 5 warmup iterations, 5 iterations, 2 threads, 5 forks) + * $ java -jar target/benchmarks.jar JMHSample_33 -f 1 + * (we requested 5 warmup iterations, 5 forks; there are also other options, see -h)) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_34_SafeLooping.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_34_SafeLooping.java index 86f787540..76620385c 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_34_SafeLooping.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_34_SafeLooping.java @@ -194,8 +194,6 @@ public static void sink(int v) { public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_34_SafeLooping.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(3) .build(); From 246ce066567a82159eee4694e4d6811a0dd181f9 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 4 May 2018 13:19:01 +0200 Subject: [PATCH 132/342] 7902167: JMH should provide stern message about trusting the numbers --- .../org/openjdk/jmh/runner/format/TextReportFormat.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index ceb85b3f8..ca5373dc4 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -217,6 +217,13 @@ public void startRun() { @Override public void endRun(Collection runResults) { + out.println("REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on"); + out.println("why the numbers are the way they are. Use profilers (see -prof, -lprof), build combinatorial"); + out.println("experiments, perform baseline and negative tests that provide experimental control, make sure"); + out.println("the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts."); + out.println("Do not assume the numbers tell you what you want them to tell."); + out.println(""); + ResultFormatFactory.getInstance(ResultFormatType.TEXT, out).writeOut(runResults); } From 5af5e7ee816c833b59d117da2607c3dc87f6d378 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 4 May 2018 14:02:30 +0200 Subject: [PATCH 133/342] 7902169: JMH should capture and print VM name --- .../openjdk/jmh/infra/BenchmarkParams.java | 24 +++++++++++++------ .../jmh/results/format/JSONResultFormat.java | 1 + .../java/org/openjdk/jmh/runner/Runner.java | 3 ++- .../jmh/runner/format/TextReportFormat.java | 2 +- .../main/java/org/openjdk/jmh/util/Utils.java | 2 +- .../jmh/results/TestAggregateResult.java | 2 +- .../jmh/results/format/ResultFormatTest.java | 4 +++- .../org/openjdk/jmh/runner/RunnerTest.java | 6 ++--- .../jmh/results/format/output-golden.json | 5 ++++ 9 files changed, 34 insertions(+), 15 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java index c9486fea0..8acbb721e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/BenchmarkParams.java @@ -71,7 +71,7 @@ public BenchmarkParams(String benchmark, String generatedTarget, boolean synchIt Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, - String jdkVersion, String vmVersion, String jmhVersion, + String jdkVersion, String vmName, String vmVersion, String jmhVersion, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, threads, threadGroups, threadGroupLabels, @@ -80,7 +80,7 @@ public BenchmarkParams(String benchmark, String generatedTarget, boolean synchIt mode, params, timeUnit, opsPerInvocation, jvm, jvmArgs, - jdkVersion, vmVersion, jmhVersion, + jdkVersion, vmName, vmVersion, jmhVersion, timeout); } } @@ -96,7 +96,7 @@ public BenchmarkParamsL4(String benchmark, String generatedTarget, boolean synch Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, - String jdkVersion, String vmVersion, String jmhVersion, + String jdkVersion, String vmName, String vmVersion, String jmhVersion, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, threads, threadGroups, threadGroupLabels, @@ -105,7 +105,7 @@ public BenchmarkParamsL4(String benchmark, String generatedTarget, boolean synch mode, params, timeUnit, opsPerInvocation, jvm, jvmArgs, - jdkVersion, vmVersion, jmhVersion, + jdkVersion, vmName, vmVersion, jmhVersion, timeout); } } @@ -137,7 +137,7 @@ public BenchmarkParamsL3(String benchmark, String generatedTarget, boolean synch Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, - String jdkVersion, String vmVersion, String jmhVersion, + String jdkVersion, String vmName, String vmVersion, String jmhVersion, TimeValue timeout) { super(benchmark, generatedTarget, synchIterations, threads, threadGroups, threadGroupLabels, @@ -146,7 +146,7 @@ public BenchmarkParamsL3(String benchmark, String generatedTarget, boolean synch mode, params, timeUnit, opsPerInvocation, jvm, jvmArgs, - jdkVersion, vmVersion, jmhVersion, + jdkVersion, vmName, vmVersion, jmhVersion, timeout); } } @@ -195,6 +195,7 @@ abstract class BenchmarkParamsL2 extends BenchmarkParamsL1 implements Serializab protected final Collection jvmArgs; protected final String jdkVersion; protected final String jmhVersion; + protected final String vmName; protected final String vmVersion; protected final TimeValue timeout; @@ -205,7 +206,7 @@ public BenchmarkParamsL2(String benchmark, String generatedTarget, boolean synch Mode mode, WorkloadParams params, TimeUnit timeUnit, int opsPerInvocation, String jvm, Collection jvmArgs, - String jdkVersion, String vmVersion, String jmhVersion, + String jdkVersion, String vmName, String vmVersion, String jmhVersion, TimeValue timeout) { this.benchmark = benchmark; this.generatedTarget = generatedTarget; @@ -224,6 +225,7 @@ public BenchmarkParamsL2(String benchmark, String generatedTarget, boolean synch this.jvm = jvm; this.jvmArgs = jvmArgs; this.jdkVersion = jdkVersion; + this.vmName = vmName; this.vmVersion = vmVersion; this.jmhVersion = jmhVersion; this.timeout = timeout; @@ -386,6 +388,14 @@ public String getVmVersion() { return vmVersion; } + /** + * @return name information as returned by the effective target JVM, + * via system property {@code java.vm.name} + */ + public String getVmName() { + return vmName; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java index 6b826c308..061343623 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java @@ -80,6 +80,7 @@ public void writeOut(Collection results) { printStringArray(pw, params.getJvmArgs()); pw.println("],"); pw.println("\"jdkVersion\" : " + toJsonString(params.getJdkVersion()) + ","); + pw.println("\"vmName\" : " + toJsonString(params.getVmName()) + ","); pw.println("\"vmVersion\" : " + toJsonString(params.getVmVersion()) + ","); pw.println("\"warmupIterations\" : " + params.getWarmup().getCount() + ","); pw.println("\"warmupTime\" : \"" + params.getWarmup().getTime() + "\","); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index e6eef043f..9a27ce251 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -495,12 +495,13 @@ private BenchmarkParams newBenchmarkParams(BenchmarkListEntry benchmark, ActionM String jdkVersion = targetProperties.getProperty("java.version"); String vmVersion = targetProperties.getProperty("java.vm.version"); + String vmName = targetProperties.getProperty("java.vm.name"); return new BenchmarkParams(benchmark.getUsername(), benchmark.generatedTarget(), synchIterations, threads, threadGroups, benchmark.getThreadGroupLabels().orElse(Collections.emptyList()), forks, warmupForks, warmup, measurement, benchmark.getMode(), benchmark.getWorkloadParams(), timeUnit, opsPerInvocation, jvm, jvmArgs, - jdkVersion, vmVersion, Version.getPlainVersion(), + jdkVersion, vmName, vmVersion, Version.getPlainVersion(), timeout); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index ca5373dc4..1e2924f20 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -62,7 +62,7 @@ public void startBenchmark(BenchmarkParams params) { } println("# JMH version: " + params.getJmhVersion()); - println("# VM version: JDK " + params.getJdkVersion() + ", VM " + params.getVmVersion()); + println("# VM version: JDK " + params.getJdkVersion() + ", " + params.getVmName() + ", " + params.getVmVersion()); println("# VM invoker: " + params.getJvm()); println("# VM options: " + opts); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 4f958915f..5f47c6500 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -507,7 +507,7 @@ public static Collection runWith(List cmd) { * @return Copy of system properties we want to record in the results. */ public static Properties getRecordedSystemProperties() { - String[] names = new String[]{"java.version", "java.vm.version"}; + String[] names = new String[]{"java.version", "java.vm.version", "java.vm.name"}; Properties p = new Properties(); for (String i : names) { p.setProperty(i, System.getProperty(i)); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java index 43cf606aa..4ca2c27ef 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java @@ -57,7 +57,7 @@ public static void setupClass() { new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.emptyList(), - System.getProperty("java.version"), System.getProperty("java.vm.version"), Version.getPlainVersion(), + System.getProperty("java.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)), new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.days(1), 1), null diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java index 7d998008c..ff864ae31 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java @@ -56,6 +56,8 @@ public class ResultFormatTest { */ private static final String JDK_VERSION_DUMMY = "1.8-dummy"; + private static final String VM_NAME_DUMMY = "DummyVM"; + private static final String VM_VERSION_DUMMY = "4711"; private static final String JMH_VERSION_DUMMY = "1.18"; @@ -86,7 +88,7 @@ private Collection getStub() { TimeUnit.SECONDS, 1, JVM_DUMMY, Collections.emptyList(), - JDK_VERSION_DUMMY, VM_VERSION_DUMMY, JMH_VERSION_DUMMY, + JDK_VERSION_DUMMY, VM_NAME_DUMMY, VM_VERSION_DUMMY, JMH_VERSION_DUMMY, TimeValue.days(1)); Collection benchmarkResults = new ArrayList<>(); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java index 0fb019153..aa5670ddf 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/RunnerTest.java @@ -66,7 +66,7 @@ public void testEmptyOptsHaveCompileCommandFile() { new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.emptyList(), - System.getProperty("java.version"), System.getProperty("java.vm.version"), Version.getPlainVersion(), + System.getProperty("java.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); @@ -98,7 +98,7 @@ public void testOptsWithCompileCommandFileResultInMergedCompileCommandFile() thr new IterationParams(IterationType.MEASUREMENT, 1, TimeValue.seconds(1), 1), Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Collections.singletonList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints), - System.getProperty("java.version"), System.getProperty("java.vm.version"), Version.getPlainVersion(), + System.getProperty("java.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); @@ -135,7 +135,7 @@ public void testOptsWith2CompileCommandFilesResultInMergedCompileCommandFile() t Mode.Throughput, null, TimeUnit.SECONDS, 1, Utils.getCurrentJvm(), Arrays.asList(CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints1, CompilerHints.XX_COMPILE_COMMAND_FILE + tempHints2), - System.getProperty("java.version"), System.getProperty("java.vm.version"), Version.getPlainVersion(), + System.getProperty("java.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.version"), Version.getPlainVersion(), TimeValue.days(1)); List command = blade.getForkedMainCommand(bp, Collections.emptyList(), DUMMY_HOST, DUMMY_PORT); diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json index 718467124..ea23b29b3 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json @@ -9,6 +9,7 @@ "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", + "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 84, "warmupTime" : "375 s", @@ -231,6 +232,7 @@ "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", + "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 544, "warmupTime" : "409 s", @@ -336,6 +338,7 @@ "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", + "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 384, "warmupTime" : "105 s", @@ -503,6 +506,7 @@ "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", + "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 628, "warmupTime" : "207 s", @@ -702,6 +706,7 @@ "jvmArgs" : [ ], "jdkVersion" : "1.8-dummy", + "vmName" : "DummyVM", "vmVersion" : "4711", "warmupIterations" : 997, "warmupTime" : "651 s", From a9eec3c47661a7a7970e1b713223072d38aee6a7 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 4 May 2018 14:03:48 +0200 Subject: [PATCH 134/342] 7902168: JMH should print warnings when JVM support is not guaranteed --- .../org/openjdk/jmh/runner/SupportedVMs.java | 58 +++++++++++++++++++ .../jmh/runner/format/TextReportFormat.java | 15 +++++ 2 files changed, 73 insertions(+) create mode 100644 jmh-core/src/main/java/org/openjdk/jmh/runner/SupportedVMs.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/SupportedVMs.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/SupportedVMs.java new file mode 100644 index 000000000..5d85e397d --- /dev/null +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/SupportedVMs.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.runner; + + +/** + * JMH VM support tester + */ +public class SupportedVMs { + + static final String[] FULL_SUPPORT = { + "OpenJDK", + "HotSpot", + }; + + static final String[] EXPERIMENTAL_SUPPORT = { + "Zing", + "GraalVM", + }; + + public static Level supportLevel(String name) { + for (String vmName : FULL_SUPPORT) { + if (name.contains(vmName)) return Level.FULL; + } + for (String vmName : EXPERIMENTAL_SUPPORT) { + if (name.contains(vmName)) return Level.EXPERIMENTAL; + } + return Level.NONE; + } + + public enum Level { + FULL, + EXPERIMENTAL, + NONE, + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index 1e2924f20..7625f303b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -34,6 +34,7 @@ import org.openjdk.jmh.results.format.ResultFormatFactory; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.IterationType; +import org.openjdk.jmh.runner.SupportedVMs; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.util.Utils; @@ -63,6 +64,20 @@ public void startBenchmark(BenchmarkParams params) { println("# JMH version: " + params.getJmhVersion()); println("# VM version: JDK " + params.getJdkVersion() + ", " + params.getVmName() + ", " + params.getVmVersion()); + + switch (SupportedVMs.supportLevel(params.getVmName())) { + case FULL: + break; + case EXPERIMENTAL: + println("# *** WARNING: JMH support for this VM is experimental. Be extra careful with the produced data."); + break; + case NONE: + println("# *** WARNING: This VM is not supported by JMH. The produced benchmark data can be completely wrong."); + break; + default: + throw new IllegalStateException("Unknown support level"); + } + println("# VM invoker: " + params.getJvm()); println("# VM options: " + opts); From 7f94046aad3c2546af7ef6e8993c00a2a2c1bf1c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 4 May 2018 14:23:42 +0200 Subject: [PATCH 135/342] Amend 7902168: Hide SupportedVMs class from public API --- .../org/openjdk/jmh/runner/{ => format}/SupportedVMs.java | 4 ++-- .../java/org/openjdk/jmh/runner/format/TextReportFormat.java | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) rename jmh-core/src/main/java/org/openjdk/jmh/runner/{ => format}/SupportedVMs.java (96%) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/SupportedVMs.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/SupportedVMs.java similarity index 96% rename from jmh-core/src/main/java/org/openjdk/jmh/runner/SupportedVMs.java rename to jmh-core/src/main/java/org/openjdk/jmh/runner/format/SupportedVMs.java index 5d85e397d..dbfed0ad4 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/SupportedVMs.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/SupportedVMs.java @@ -22,13 +22,13 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package org.openjdk.jmh.runner; +package org.openjdk.jmh.runner.format; /** * JMH VM support tester */ -public class SupportedVMs { +class SupportedVMs { static final String[] FULL_SUPPORT = { "OpenJDK", diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index 7625f303b..f14031403 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -34,7 +34,6 @@ import org.openjdk.jmh.results.format.ResultFormatFactory; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.IterationType; -import org.openjdk.jmh.runner.SupportedVMs; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; import org.openjdk.jmh.util.Utils; From b826cf568992497051363085f817484770f2ee32 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 4 May 2018 16:31:41 +0200 Subject: [PATCH 136/342] Amend 7902167: "combinatorial" -> "factorial" --- .../java/org/openjdk/jmh/runner/format/TextReportFormat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index f14031403..6bbf76c03 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -232,7 +232,7 @@ public void startRun() { @Override public void endRun(Collection runResults) { out.println("REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on"); - out.println("why the numbers are the way they are. Use profilers (see -prof, -lprof), build combinatorial"); + out.println("why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial"); out.println("experiments, perform baseline and negative tests that provide experimental control, make sure"); out.println("the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts."); out.println("Do not assume the numbers tell you what you want them to tell."); From 44250d653bb9920338bbd3071f00bb7b59aed3af Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 4 May 2018 17:38:14 +0200 Subject: [PATCH 137/342] 7902170: Reconsider defaults for fork count --- jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java index 5aeccd6e7..0b79b7954 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java @@ -85,7 +85,7 @@ public class Defaults { /** * Number of forks in which we measure the workload. */ - public static final int MEASUREMENT_FORKS = 10; + public static final int MEASUREMENT_FORKS = 5; /** * Number of warmup forks we discard. From 5772a465e06b341feeec4ceb986c54e26fb8bdfb Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 4 May 2018 16:37:15 +0200 Subject: [PATCH 138/342] JMH v1.21 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 02ab93c34..d1e964be1 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.21-SNAPSHOT + 1.21 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 398a026bb..dc8fad069 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.21-SNAPSHOT + 1.21 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index d69dd9c3f..42f3e2597 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.21-SNAPSHOT + 1.21 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index b8508d841..00c5b8f87 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.21-SNAPSHOT + 1.21 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index df1b8c541..d8a281b92 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 6896c455f..613a4665f 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index f5572a1f7..a4a164e62 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 5aac4c350..e6399b98e 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index c688258c4..030e1f484 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 373e52b31..b5a8830ce 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 0722d4b8c..eb7c2ec56 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index cb25005cd..4304da02c 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index cdfb5fa26..b924a4a31 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 12c00e612..775e3272c 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.21-SNAPSHOT + 1.21 JMH Samples diff --git a/pom.xml b/pom.xml index 036b36a70..be6e3859c 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.21-SNAPSHOT + 1.21 Java Microbenchmark Harness Parent From cd6b761a47e0b01db82dd2f9bec2646a110b6d65 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 4 May 2018 17:58:45 +0200 Subject: [PATCH 139/342] Added tag 1.21 for changeset f25ae8584db1 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 3cd0411f6..424703282 100644 --- a/.hgtags +++ b/.hgtags @@ -89,3 +89,4 @@ d4a8ae32b9063cf17c699455ced1b0d718f4977a 1.17.3 6eb89dc11810e824b1f5416033cb1cf1f5f30f63 1.18 b7dc6e851f12a5bf2086f6f5d963d939ea5bd509 1.19 bd52958ab68089093f8c21d0a7c4af2848b845f6 1.20 +f25ae8584db1d6d4602af701688c2ccb90684396 1.21 From 7ba0ee6cf5e54012459950f86c54b7e7b82a1a33 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 4 May 2018 17:58:58 +0200 Subject: [PATCH 140/342] Continue in 1.22-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index d1e964be1..1d97463c0 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.21 + 1.22-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index dc8fad069..fb57a31b9 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.21 + 1.22-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 42f3e2597..0bbef9e31 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.21 + 1.22-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 00c5b8f87..b155ccf52 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.21 + 1.22-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index d8a281b92..e7a5aa0e6 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 613a4665f..457e24b42 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index a4a164e62..9bfd0eac4 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index e6399b98e..95f97518d 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 030e1f484..625ad8db1 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index b5a8830ce..7dd2b5611 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index eb7c2ec56..a00fda4e8 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 4304da02c..bf5f02d8a 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index b924a4a31..d154b4492 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 775e3272c..84ff98107 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.21 + 1.22-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index be6e3859c..fb45afbdc 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.21 + 1.22-SNAPSHOT Java Microbenchmark Harness Parent From d666821256b5cd7dafca736d9aa1276d806f0259 Mon Sep 17 00:00:00 2001 From: Eric Caspole Date: Wed, 26 Sep 2018 16:57:35 +0200 Subject: [PATCH 141/342] 7902329: perf profiler should accept events --- .../jmh/profile/LinuxPerfProfiler.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java index fc738114e..b2a210076 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java @@ -37,8 +37,10 @@ import java.text.NumberFormat; import java.text.ParseException; import java.util.Arrays; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -47,6 +49,7 @@ public class LinuxPerfProfiler implements ExternalProfiler { private final boolean isDelayed; private final int delayMs; + private final List events; public LinuxPerfProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); @@ -56,9 +59,14 @@ public LinuxPerfProfiler(String initLine) throws ProfilerException { "Delay collection for a given time, in milliseconds; -1 to detect automatically.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); + OptionSpec optEvents = parser.accepts("events", + "Events to gather.") + .withRequiredArg().ofType(String.class).withValuesSeparatedBy(",").describedAs("event"); + OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); try { + events = set.valuesOf(optEvents); delayMs = set.valueOf(optDelay); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); @@ -84,11 +92,18 @@ public Collection addJVMInvokeOptions(BenchmarkParams params) { delay = delayMs; } + List invokeOptions = new ArrayList<>(Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--detailed", "--detailed", "--detailed")); + if (isDelayed) { - return Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--detailed", "--detailed", "--detailed", "--delay", String.valueOf(delay)); - } else { - return Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--detailed", "--detailed", "--detailed"); + invokeOptions.add("--delay"); + invokeOptions.add(String.valueOf(delay)); } + if (!events.isEmpty()) { + invokeOptions.add("-e"); + invokeOptions.add(Utils.join(events, ",")); + } + + return invokeOptions; } @Override From 0b3d56ecbab0562d910f038cb332a67bcb16ea9a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 15 Jan 2019 16:27:09 +0100 Subject: [PATCH 142/342] 7902359: @Param values with braces and quotes should be handled specially --- .../jmh/ct/params/ParamQuotesTest.java | 62 +++++++++++++++ .../jmh/it/params/QuotedParamsTest.java | 79 +++++++++++++++++++ .../jmh/results/format/JSONResultFormat.java | 2 +- .../jmh/results/format/LaTeXResultFormat.java | 4 +- .../jmh/results/format/ResultFormatTest.java | 8 +- .../jmh/results/format/output-golden.csv.root | 40 +++++----- .../jmh/results/format/output-golden.csv.ru | 40 +++++----- .../jmh/results/format/output-golden.csv.us | 40 +++++----- .../jmh/results/format/output-golden.json | 40 +++++----- .../results/format/output-golden.latex.root | 38 ++++----- .../jmh/results/format/output-golden.latex.ru | 38 ++++----- .../jmh/results/format/output-golden.latex.us | 38 ++++----- .../results/format/output-golden.scsv.root | 40 +++++----- .../jmh/results/format/output-golden.scsv.ru | 40 +++++----- .../jmh/results/format/output-golden.scsv.us | 40 +++++----- .../results/format/output-golden.text.root | 38 ++++----- .../jmh/results/format/output-golden.text.ru | 38 ++++----- .../jmh/results/format/output-golden.text.us | 38 ++++----- 18 files changed, 404 insertions(+), 259 deletions(-) create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamQuotesTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamQuotesTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamQuotesTest.java new file mode 100644 index 000000000..f726d5fad --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/params/ParamQuotesTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.params; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.ct.CompileTest; + +@State(Scope.Benchmark) +public class ParamQuotesTest { + + @Param("value") + public String param_plain; + + @Param("[value]") + public String param_square; + + @Param("{value}") + public String param_curly; + + @Param("'value'") + public String param_squote; + + @Param("\"value\"") + public String param_dquote; + + @Benchmark + public void test() { + + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java new file mode 100644 index 000000000..1a3c55347 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2019, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.params; + +import junit.framework.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +@State(Scope.Benchmark) +public class QuotedParamsTest { + + @Param("value") + public String param_plain; + + @Param("[value]") + public String param_square; + + @Param("{value}") + public String param_curly; + + @Param("'value'") + public String param_squote; + + @Param("\"value\"") + public String param_dquote; + + @Benchmark + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) + @Fork(1) + public void test() { + Fixtures.work(); + Assert.assertEquals("value", param_plain); + Assert.assertEquals("[value]", param_square); + Assert.assertEquals("{value}", param_curly); + Assert.assertEquals("'value'", param_squote); + Assert.assertEquals("\"value\"", param_dquote); + } + + @Test + public void vals() throws RunnerException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .build(); + + new Runner(opts).run(); + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java index 061343623..6aa5985a4 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/JSONResultFormat.java @@ -192,7 +192,7 @@ private String emitParams(BenchmarkParams params) { sb.append(", "); } sb.append("\"").append(k).append("\" : "); - sb.append("\"").append(params.getParam(k)).append("\""); + sb.append(toJsonString(params.getParam(k))); } return sb.toString(); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/format/LaTeXResultFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/results/format/LaTeXResultFormat.java index 2edd4966a..57420b929 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/format/LaTeXResultFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/format/LaTeXResultFormat.java @@ -127,7 +127,9 @@ private void printLine(String label, BenchmarkParams benchParams, SortedSet getStub() { Random ar = new Random(12345); for (int b = 0; b < r.nextInt(10); b++) { WorkloadParams ps = new WorkloadParams(); - for (int p = 0; p < 5; p++) { - ps.put("param" + p, "value" + p, p); - } + ps.put("param0", "value0", 0); + ps.put("param1", "[value1]", 1); + ps.put("param2", "{value2}", 2); + ps.put("param3", "'value3'", 3); + ps.put("param4", "\"value4\"", 4); BenchmarkParams params = new BenchmarkParams( "benchmark_" + b, JSONResultFormat.class.getName() + ".benchmark_" + b + "_" + Mode.Throughput, diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.root b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.root index b9a4ea371..ce629a063 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.root +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.root @@ -1,20 +1,20 @@ -"Benchmark","Mode","Threads","Samples","Score","Score Error (99.9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4" -"benchmark_0","thrpt",80,14,528.857143,278.141953,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_0:secondary1","thrpt",80,14,549.714286,320.227488,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_0:secondary2","thrpt",80,14,615.500000,319.209585,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_0:secondary3","thrpt",80,5,246.000000,847.566004,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_1","thrpt",900,1,439.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_1:secondary1","thrpt",900,1,953.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_1:secondary2","thrpt",900,1,367.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_2","thrpt",466,9,545.000000,553.336699,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_2:secondary1","thrpt",466,9,434.444444,465.182504,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_2:secondary2","thrpt",466,9,470.333333,502.273041,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_2:secondary3","thrpt",466,5,574.400000,969.535252,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_3","thrpt",968,14,417.571429,362.813967,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_3:secondary1","thrpt",968,14,672.214286,287.982211,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_3:secondary2","thrpt",968,14,560.142857,289.799961,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_3:secondary3","thrpt",968,6,432.833333,1036.758184,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4","thrpt",739,1,956.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4:secondary1","thrpt",739,1,688.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4:secondary2","thrpt",739,1,237.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4:secondary3","thrpt",739,1,599.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 +"Benchmark","Mode","Threads","Samples","Score","Score Error (99.9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4" +"benchmark_0","thrpt",80,14,528.857143,278.141953,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_0:secondary1","thrpt",80,14,549.714286,320.227488,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_0:secondary2","thrpt",80,14,615.500000,319.209585,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_0:secondary3","thrpt",80,5,246.000000,847.566004,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_1","thrpt",900,1,439.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_1:secondary1","thrpt",900,1,953.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_1:secondary2","thrpt",900,1,367.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2","thrpt",466,9,545.000000,553.336699,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2:secondary1","thrpt",466,9,434.444444,465.182504,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2:secondary2","thrpt",466,9,470.333333,502.273041,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2:secondary3","thrpt",466,5,574.400000,969.535252,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3","thrpt",968,14,417.571429,362.813967,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3:secondary1","thrpt",968,14,672.214286,287.982211,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3:secondary2","thrpt",968,14,560.142857,289.799961,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3:secondary3","thrpt",968,6,432.833333,1036.758184,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4","thrpt",739,1,956.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4:secondary1","thrpt",739,1,688.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4:secondary2","thrpt",739,1,237.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4:secondary3","thrpt",739,1,599.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.ru b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.ru index b47075a2c..0c6697326 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.ru +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.ru @@ -1,20 +1,20 @@ -"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4" -"benchmark_0","thrpt",80,14,"528,857143","278,141953","ops/ms",value0,value1,value2,value3,value4 -"benchmark_0:secondary1","thrpt",80,14,"549,714286","320,227488","ops/ms",value0,value1,value2,value3,value4 -"benchmark_0:secondary2","thrpt",80,14,"615,500000","319,209585","ops/ms",value0,value1,value2,value3,value4 -"benchmark_0:secondary3","thrpt",80,5,"246,000000","847,566004","ops/ms",value0,value1,value2,value3,value4 -"benchmark_1","thrpt",900,1,"439,000000",NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_1:secondary1","thrpt",900,1,"953,000000",NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_1:secondary2","thrpt",900,1,"367,000000",NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_2","thrpt",466,9,"545,000000","553,336699","ops/ms",value0,value1,value2,value3,value4 -"benchmark_2:secondary1","thrpt",466,9,"434,444444","465,182504","ops/ms",value0,value1,value2,value3,value4 -"benchmark_2:secondary2","thrpt",466,9,"470,333333","502,273041","ops/ms",value0,value1,value2,value3,value4 -"benchmark_2:secondary3","thrpt",466,5,"574,400000","969,535252","ops/ms",value0,value1,value2,value3,value4 -"benchmark_3","thrpt",968,14,"417,571429","362,813967","ops/ms",value0,value1,value2,value3,value4 -"benchmark_3:secondary1","thrpt",968,14,"672,214286","287,982211","ops/ms",value0,value1,value2,value3,value4 -"benchmark_3:secondary2","thrpt",968,14,"560,142857","289,799961","ops/ms",value0,value1,value2,value3,value4 -"benchmark_3:secondary3","thrpt",968,6,"432,833333","1036,758184","ops/ms",value0,value1,value2,value3,value4 -"benchmark_4","thrpt",739,1,"956,000000",NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4:secondary1","thrpt",739,1,"688,000000",NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4:secondary2","thrpt",739,1,"237,000000",NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4:secondary3","thrpt",739,1,"599,000000",NaN,"ops/ms",value0,value1,value2,value3,value4 +"Benchmark","Mode","Threads","Samples","Score","Score Error (99,9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4" +"benchmark_0","thrpt",80,14,"528,857143","278,141953","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_0:secondary1","thrpt",80,14,"549,714286","320,227488","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_0:secondary2","thrpt",80,14,"615,500000","319,209585","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_0:secondary3","thrpt",80,5,"246,000000","847,566004","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_1","thrpt",900,1,"439,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_1:secondary1","thrpt",900,1,"953,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_1:secondary2","thrpt",900,1,"367,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2","thrpt",466,9,"545,000000","553,336699","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2:secondary1","thrpt",466,9,"434,444444","465,182504","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2:secondary2","thrpt",466,9,"470,333333","502,273041","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2:secondary3","thrpt",466,5,"574,400000","969,535252","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3","thrpt",968,14,"417,571429","362,813967","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3:secondary1","thrpt",968,14,"672,214286","287,982211","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3:secondary2","thrpt",968,14,"560,142857","289,799961","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3:secondary3","thrpt",968,6,"432,833333","1036,758184","ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4","thrpt",739,1,"956,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4:secondary1","thrpt",739,1,"688,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4:secondary2","thrpt",739,1,"237,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4:secondary3","thrpt",739,1,"599,000000",NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.us b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.us index b9a4ea371..ce629a063 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.us +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.csv.us @@ -1,20 +1,20 @@ -"Benchmark","Mode","Threads","Samples","Score","Score Error (99.9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4" -"benchmark_0","thrpt",80,14,528.857143,278.141953,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_0:secondary1","thrpt",80,14,549.714286,320.227488,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_0:secondary2","thrpt",80,14,615.500000,319.209585,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_0:secondary3","thrpt",80,5,246.000000,847.566004,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_1","thrpt",900,1,439.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_1:secondary1","thrpt",900,1,953.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_1:secondary2","thrpt",900,1,367.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_2","thrpt",466,9,545.000000,553.336699,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_2:secondary1","thrpt",466,9,434.444444,465.182504,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_2:secondary2","thrpt",466,9,470.333333,502.273041,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_2:secondary3","thrpt",466,5,574.400000,969.535252,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_3","thrpt",968,14,417.571429,362.813967,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_3:secondary1","thrpt",968,14,672.214286,287.982211,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_3:secondary2","thrpt",968,14,560.142857,289.799961,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_3:secondary3","thrpt",968,6,432.833333,1036.758184,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4","thrpt",739,1,956.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4:secondary1","thrpt",739,1,688.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4:secondary2","thrpt",739,1,237.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 -"benchmark_4:secondary3","thrpt",739,1,599.000000,NaN,"ops/ms",value0,value1,value2,value3,value4 +"Benchmark","Mode","Threads","Samples","Score","Score Error (99.9%)","Unit","Param: param0","Param: param1","Param: param2","Param: param3","Param: param4" +"benchmark_0","thrpt",80,14,528.857143,278.141953,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_0:secondary1","thrpt",80,14,549.714286,320.227488,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_0:secondary2","thrpt",80,14,615.500000,319.209585,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_0:secondary3","thrpt",80,5,246.000000,847.566004,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_1","thrpt",900,1,439.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_1:secondary1","thrpt",900,1,953.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_1:secondary2","thrpt",900,1,367.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2","thrpt",466,9,545.000000,553.336699,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2:secondary1","thrpt",466,9,434.444444,465.182504,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2:secondary2","thrpt",466,9,470.333333,502.273041,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_2:secondary3","thrpt",466,5,574.400000,969.535252,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3","thrpt",968,14,417.571429,362.813967,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3:secondary1","thrpt",968,14,672.214286,287.982211,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3:secondary2","thrpt",968,14,560.142857,289.799961,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_3:secondary3","thrpt",968,6,432.833333,1036.758184,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4","thrpt",739,1,956.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4:secondary1","thrpt",739,1,688.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4:secondary2","thrpt",739,1,237.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" +"benchmark_4:secondary3","thrpt",739,1,599.000000,NaN,"ops/ms",value0,[value1],{value2},'value3',"""value4""" \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json index ea23b29b3..0be17d8d4 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.json @@ -19,10 +19,10 @@ "measurementBatchSize" : 1, "params" : { "param0" : "value0", - "param1" : "value1", - "param2" : "value2", - "param3" : "value3", - "param4" : "value4" + "param1" : "[value1]", + "param2" : "{value2}", + "param3" : "'value3'", + "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 528.8571428571429, @@ -242,10 +242,10 @@ "measurementBatchSize" : 1, "params" : { "param0" : "value0", - "param1" : "value1", - "param2" : "value2", - "param3" : "value3", - "param4" : "value4" + "param1" : "[value1]", + "param2" : "{value2}", + "param3" : "'value3'", + "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 439.0, @@ -348,10 +348,10 @@ "measurementBatchSize" : 1, "params" : { "param0" : "value0", - "param1" : "value1", - "param2" : "value2", - "param3" : "value3", - "param4" : "value4" + "param1" : "[value1]", + "param2" : "{value2}", + "param3" : "'value3'", + "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 545.0, @@ -516,10 +516,10 @@ "measurementBatchSize" : 1, "params" : { "param0" : "value0", - "param1" : "value1", - "param2" : "value2", - "param3" : "value3", - "param4" : "value4" + "param1" : "[value1]", + "param2" : "{value2}", + "param3" : "'value3'", + "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 417.57142857142856, @@ -716,10 +716,10 @@ "measurementBatchSize" : 1, "params" : { "param0" : "value0", - "param1" : "value1", - "param2" : "value2", - "param3" : "value3", - "param4" : "value4" + "param1" : "[value1]", + "param2" : "{value2}", + "param3" : "'value3'", + "param4" : "\"value4\"" }, "primaryMetric" : { "score" : 956.0, diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.root b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.root index 251a97021..8a95c3227 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.root +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.root @@ -1,23 +1,23 @@ \begin{tabular}{r|l|l|l|l|l|rl} \multicolumn{1}{c|}{\texttt{Benchmark}} & \texttt{param0} & \texttt{param1} & \texttt{param2} & \texttt{param3} & \texttt{param4} & \multicolumn{2}{c}{\texttt{Score, ops/ms}} \\ \hline -\texttt{benchmark\_0} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{528.857} & \scriptsize $\pm$ \texttt{278.142} \\ -\texttt{benchmark\_0:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{549.714} & \scriptsize $\pm$ \texttt{320.227} \\ -\texttt{benchmark\_0:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{615.500} & \scriptsize $\pm$ \texttt{319.210} \\ -\texttt{benchmark\_0:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{246.000} & \scriptsize $\pm$ \texttt{847.566} \\ -\texttt{benchmark\_1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{439.000} & \\ -\texttt{benchmark\_1:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{953.000} & \\ -\texttt{benchmark\_1:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{367.000} & \\ -\texttt{benchmark\_2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{545.000} & \scriptsize $\pm$ \texttt{553.337} \\ -\texttt{benchmark\_2:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{434.444} & \scriptsize $\pm$ \texttt{465.183} \\ -\texttt{benchmark\_2:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{470.333} & \scriptsize $\pm$ \texttt{502.273} \\ -\texttt{benchmark\_2:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{574.400} & \scriptsize $\pm$ \texttt{969.535} \\ -\texttt{benchmark\_3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{417.571} & \scriptsize $\pm$ \texttt{362.814} \\ -\texttt{benchmark\_3:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{672.214} & \scriptsize $\pm$ \texttt{287.982} \\ -\texttt{benchmark\_3:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{560.143} & \scriptsize $\pm$ \texttt{289.800} \\ -\texttt{benchmark\_3:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{432.833} & \scriptsize $\pm$ \texttt{1036.758} \\ -\texttt{benchmark\_4} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{956.000} & \\ -\texttt{benchmark\_4:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{688.000} & \\ -\texttt{benchmark\_4:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{237.000} & \\ -\texttt{benchmark\_4:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{599.000} & \\ +\texttt{benchmark\_0} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{528.857} & \scriptsize $\pm$ \texttt{278.142} \\ +\texttt{benchmark\_0:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{549.714} & \scriptsize $\pm$ \texttt{320.227} \\ +\texttt{benchmark\_0:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{615.500} & \scriptsize $\pm$ \texttt{319.210} \\ +\texttt{benchmark\_0:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{246.000} & \scriptsize $\pm$ \texttt{847.566} \\ +\texttt{benchmark\_1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{439.000} & \\ +\texttt{benchmark\_1:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{953.000} & \\ +\texttt{benchmark\_1:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{367.000} & \\ +\texttt{benchmark\_2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{545.000} & \scriptsize $\pm$ \texttt{553.337} \\ +\texttt{benchmark\_2:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{434.444} & \scriptsize $\pm$ \texttt{465.183} \\ +\texttt{benchmark\_2:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{470.333} & \scriptsize $\pm$ \texttt{502.273} \\ +\texttt{benchmark\_2:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{574.400} & \scriptsize $\pm$ \texttt{969.535} \\ +\texttt{benchmark\_3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{417.571} & \scriptsize $\pm$ \texttt{362.814} \\ +\texttt{benchmark\_3:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{672.214} & \scriptsize $\pm$ \texttt{287.982} \\ +\texttt{benchmark\_3:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{560.143} & \scriptsize $\pm$ \texttt{289.800} \\ +\texttt{benchmark\_3:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{432.833} & \scriptsize $\pm$ \texttt{1036.758} \\ +\texttt{benchmark\_4} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{956.000} & \\ +\texttt{benchmark\_4:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{688.000} & \\ +\texttt{benchmark\_4:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{237.000} & \\ +\texttt{benchmark\_4:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{599.000} & \\ \end{tabular} \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.ru b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.ru index ba9b487c2..7f9e10db9 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.ru +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.ru @@ -1,23 +1,23 @@ \begin{tabular}{r|l|l|l|l|l|rl} \multicolumn{1}{c|}{\texttt{Benchmark}} & \texttt{param0} & \texttt{param1} & \texttt{param2} & \texttt{param3} & \texttt{param4} & \multicolumn{2}{c}{\texttt{Score, ops/ms}} \\ \hline -\texttt{benchmark\_0} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{528,857} & \scriptsize $\pm$ \texttt{278,142} \\ -\texttt{benchmark\_0:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{549,714} & \scriptsize $\pm$ \texttt{320,227} \\ -\texttt{benchmark\_0:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{615,500} & \scriptsize $\pm$ \texttt{319,210} \\ -\texttt{benchmark\_0:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{246,000} & \scriptsize $\pm$ \texttt{847,566} \\ -\texttt{benchmark\_1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{439,000} & \\ -\texttt{benchmark\_1:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{953,000} & \\ -\texttt{benchmark\_1:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{367,000} & \\ -\texttt{benchmark\_2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{545,000} & \scriptsize $\pm$ \texttt{553,337} \\ -\texttt{benchmark\_2:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{434,444} & \scriptsize $\pm$ \texttt{465,183} \\ -\texttt{benchmark\_2:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{470,333} & \scriptsize $\pm$ \texttt{502,273} \\ -\texttt{benchmark\_2:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{574,400} & \scriptsize $\pm$ \texttt{969,535} \\ -\texttt{benchmark\_3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{417,571} & \scriptsize $\pm$ \texttt{362,814} \\ -\texttt{benchmark\_3:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{672,214} & \scriptsize $\pm$ \texttt{287,982} \\ -\texttt{benchmark\_3:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{560,143} & \scriptsize $\pm$ \texttt{289,800} \\ -\texttt{benchmark\_3:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{432,833} & \scriptsize $\pm$ \texttt{1036,758} \\ -\texttt{benchmark\_4} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{956,000} & \\ -\texttt{benchmark\_4:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{688,000} & \\ -\texttt{benchmark\_4:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{237,000} & \\ -\texttt{benchmark\_4:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{599,000} & \\ +\texttt{benchmark\_0} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{528,857} & \scriptsize $\pm$ \texttt{278,142} \\ +\texttt{benchmark\_0:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{549,714} & \scriptsize $\pm$ \texttt{320,227} \\ +\texttt{benchmark\_0:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{615,500} & \scriptsize $\pm$ \texttt{319,210} \\ +\texttt{benchmark\_0:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{246,000} & \scriptsize $\pm$ \texttt{847,566} \\ +\texttt{benchmark\_1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{439,000} & \\ +\texttt{benchmark\_1:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{953,000} & \\ +\texttt{benchmark\_1:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{367,000} & \\ +\texttt{benchmark\_2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{545,000} & \scriptsize $\pm$ \texttt{553,337} \\ +\texttt{benchmark\_2:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{434,444} & \scriptsize $\pm$ \texttt{465,183} \\ +\texttt{benchmark\_2:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{470,333} & \scriptsize $\pm$ \texttt{502,273} \\ +\texttt{benchmark\_2:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{574,400} & \scriptsize $\pm$ \texttt{969,535} \\ +\texttt{benchmark\_3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{417,571} & \scriptsize $\pm$ \texttt{362,814} \\ +\texttt{benchmark\_3:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{672,214} & \scriptsize $\pm$ \texttt{287,982} \\ +\texttt{benchmark\_3:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{560,143} & \scriptsize $\pm$ \texttt{289,800} \\ +\texttt{benchmark\_3:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{432,833} & \scriptsize $\pm$ \texttt{1036,758} \\ +\texttt{benchmark\_4} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{956,000} & \\ +\texttt{benchmark\_4:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{688,000} & \\ +\texttt{benchmark\_4:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{237,000} & \\ +\texttt{benchmark\_4:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{599,000} & \\ \end{tabular} \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.us b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.us index 251a97021..8a95c3227 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.us +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.latex.us @@ -1,23 +1,23 @@ \begin{tabular}{r|l|l|l|l|l|rl} \multicolumn{1}{c|}{\texttt{Benchmark}} & \texttt{param0} & \texttt{param1} & \texttt{param2} & \texttt{param3} & \texttt{param4} & \multicolumn{2}{c}{\texttt{Score, ops/ms}} \\ \hline -\texttt{benchmark\_0} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{528.857} & \scriptsize $\pm$ \texttt{278.142} \\ -\texttt{benchmark\_0:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{549.714} & \scriptsize $\pm$ \texttt{320.227} \\ -\texttt{benchmark\_0:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{615.500} & \scriptsize $\pm$ \texttt{319.210} \\ -\texttt{benchmark\_0:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{246.000} & \scriptsize $\pm$ \texttt{847.566} \\ -\texttt{benchmark\_1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{439.000} & \\ -\texttt{benchmark\_1:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{953.000} & \\ -\texttt{benchmark\_1:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{367.000} & \\ -\texttt{benchmark\_2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{545.000} & \scriptsize $\pm$ \texttt{553.337} \\ -\texttt{benchmark\_2:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{434.444} & \scriptsize $\pm$ \texttt{465.183} \\ -\texttt{benchmark\_2:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{470.333} & \scriptsize $\pm$ \texttt{502.273} \\ -\texttt{benchmark\_2:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{574.400} & \scriptsize $\pm$ \texttt{969.535} \\ -\texttt{benchmark\_3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{417.571} & \scriptsize $\pm$ \texttt{362.814} \\ -\texttt{benchmark\_3:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{672.214} & \scriptsize $\pm$ \texttt{287.982} \\ -\texttt{benchmark\_3:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{560.143} & \scriptsize $\pm$ \texttt{289.800} \\ -\texttt{benchmark\_3:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{432.833} & \scriptsize $\pm$ \texttt{1036.758} \\ -\texttt{benchmark\_4} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{956.000} & \\ -\texttt{benchmark\_4:secondary1} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{688.000} & \\ -\texttt{benchmark\_4:secondary2} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{237.000} & \\ -\texttt{benchmark\_4:secondary3} & \texttt{value0} & \texttt{value1} & \texttt{value2} & \texttt{value3} & \texttt{value4} & \texttt{599.000} & \\ +\texttt{benchmark\_0} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{528.857} & \scriptsize $\pm$ \texttt{278.142} \\ +\texttt{benchmark\_0:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{549.714} & \scriptsize $\pm$ \texttt{320.227} \\ +\texttt{benchmark\_0:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{615.500} & \scriptsize $\pm$ \texttt{319.210} \\ +\texttt{benchmark\_0:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{246.000} & \scriptsize $\pm$ \texttt{847.566} \\ +\texttt{benchmark\_1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{439.000} & \\ +\texttt{benchmark\_1:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{953.000} & \\ +\texttt{benchmark\_1:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{367.000} & \\ +\texttt{benchmark\_2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{545.000} & \scriptsize $\pm$ \texttt{553.337} \\ +\texttt{benchmark\_2:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{434.444} & \scriptsize $\pm$ \texttt{465.183} \\ +\texttt{benchmark\_2:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{470.333} & \scriptsize $\pm$ \texttt{502.273} \\ +\texttt{benchmark\_2:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{574.400} & \scriptsize $\pm$ \texttt{969.535} \\ +\texttt{benchmark\_3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{417.571} & \scriptsize $\pm$ \texttt{362.814} \\ +\texttt{benchmark\_3:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{672.214} & \scriptsize $\pm$ \texttt{287.982} \\ +\texttt{benchmark\_3:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{560.143} & \scriptsize $\pm$ \texttt{289.800} \\ +\texttt{benchmark\_3:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{432.833} & \scriptsize $\pm$ \texttt{1036.758} \\ +\texttt{benchmark\_4} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{956.000} & \\ +\texttt{benchmark\_4:secondary1} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{688.000} & \\ +\texttt{benchmark\_4:secondary2} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{237.000} & \\ +\texttt{benchmark\_4:secondary3} & \texttt{value0} & \texttt{[value1]} & \texttt{\{value2\}} & \texttt{'value3'} & \texttt{"value4"} & \texttt{599.000} & \\ \end{tabular} \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.root b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.root index a937d595c..14663ba4e 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.root +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.root @@ -1,20 +1,20 @@ -"Benchmark";"Mode";"Threads";"Samples";"Score";"Score Error (99.9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4" -"benchmark_0";"thrpt";80;14;528.857143;278.141953;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_0:secondary1";"thrpt";80;14;549.714286;320.227488;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_0:secondary2";"thrpt";80;14;615.500000;319.209585;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_0:secondary3";"thrpt";80;5;246.000000;847.566004;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_1";"thrpt";900;1;439.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_1:secondary1";"thrpt";900;1;953.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_1:secondary2";"thrpt";900;1;367.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2";"thrpt";466;9;545.000000;553.336699;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2:secondary1";"thrpt";466;9;434.444444;465.182504;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2:secondary2";"thrpt";466;9;470.333333;502.273041;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2:secondary3";"thrpt";466;5;574.400000;969.535252;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3";"thrpt";968;14;417.571429;362.813967;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3:secondary1";"thrpt";968;14;672.214286;287.982211;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3:secondary2";"thrpt";968;14;560.142857;289.799961;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3:secondary3";"thrpt";968;6;432.833333;1036.758184;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4";"thrpt";739;1;956.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4:secondary1";"thrpt";739;1;688.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4:secondary2";"thrpt";739;1;237.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4:secondary3";"thrpt";739;1;599.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 +"Benchmark";"Mode";"Threads";"Samples";"Score";"Score Error (99.9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4" +"benchmark_0";"thrpt";80;14;528.857143;278.141953;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_0:secondary1";"thrpt";80;14;549.714286;320.227488;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_0:secondary2";"thrpt";80;14;615.500000;319.209585;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_0:secondary3";"thrpt";80;5;246.000000;847.566004;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_1";"thrpt";900;1;439.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_1:secondary1";"thrpt";900;1;953.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_1:secondary2";"thrpt";900;1;367.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2";"thrpt";466;9;545.000000;553.336699;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2:secondary1";"thrpt";466;9;434.444444;465.182504;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2:secondary2";"thrpt";466;9;470.333333;502.273041;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2:secondary3";"thrpt";466;5;574.400000;969.535252;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3";"thrpt";968;14;417.571429;362.813967;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3:secondary1";"thrpt";968;14;672.214286;287.982211;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3:secondary2";"thrpt";968;14;560.142857;289.799961;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3:secondary3";"thrpt";968;6;432.833333;1036.758184;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4";"thrpt";739;1;956.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4:secondary1";"thrpt";739;1;688.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4:secondary2";"thrpt";739;1;237.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4:secondary3";"thrpt";739;1;599.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.ru b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.ru index 75c7916d7..3db5bfd9d 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.ru +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.ru @@ -1,20 +1,20 @@ -"Benchmark";"Mode";"Threads";"Samples";"Score";"Score Error (99,9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4" -"benchmark_0";"thrpt";80;14;528,857143;278,141953;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_0:secondary1";"thrpt";80;14;549,714286;320,227488;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_0:secondary2";"thrpt";80;14;615,500000;319,209585;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_0:secondary3";"thrpt";80;5;246,000000;847,566004;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_1";"thrpt";900;1;439,000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_1:secondary1";"thrpt";900;1;953,000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_1:secondary2";"thrpt";900;1;367,000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2";"thrpt";466;9;545,000000;553,336699;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2:secondary1";"thrpt";466;9;434,444444;465,182504;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2:secondary2";"thrpt";466;9;470,333333;502,273041;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2:secondary3";"thrpt";466;5;574,400000;969,535252;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3";"thrpt";968;14;417,571429;362,813967;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3:secondary1";"thrpt";968;14;672,214286;287,982211;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3:secondary2";"thrpt";968;14;560,142857;289,799961;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3:secondary3";"thrpt";968;6;432,833333;1036,758184;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4";"thrpt";739;1;956,000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4:secondary1";"thrpt";739;1;688,000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4:secondary2";"thrpt";739;1;237,000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4:secondary3";"thrpt";739;1;599,000000;NaN;"ops/ms";value0;value1;value2;value3;value4 +"Benchmark";"Mode";"Threads";"Samples";"Score";"Score Error (99,9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4" +"benchmark_0";"thrpt";80;14;528,857143;278,141953;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_0:secondary1";"thrpt";80;14;549,714286;320,227488;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_0:secondary2";"thrpt";80;14;615,500000;319,209585;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_0:secondary3";"thrpt";80;5;246,000000;847,566004;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_1";"thrpt";900;1;439,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_1:secondary1";"thrpt";900;1;953,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_1:secondary2";"thrpt";900;1;367,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2";"thrpt";466;9;545,000000;553,336699;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2:secondary1";"thrpt";466;9;434,444444;465,182504;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2:secondary2";"thrpt";466;9;470,333333;502,273041;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2:secondary3";"thrpt";466;5;574,400000;969,535252;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3";"thrpt";968;14;417,571429;362,813967;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3:secondary1";"thrpt";968;14;672,214286;287,982211;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3:secondary2";"thrpt";968;14;560,142857;289,799961;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3:secondary3";"thrpt";968;6;432,833333;1036,758184;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4";"thrpt";739;1;956,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4:secondary1";"thrpt";739;1;688,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4:secondary2";"thrpt";739;1;237,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4:secondary3";"thrpt";739;1;599,000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.us b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.us index a937d595c..14663ba4e 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.us +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.scsv.us @@ -1,20 +1,20 @@ -"Benchmark";"Mode";"Threads";"Samples";"Score";"Score Error (99.9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4" -"benchmark_0";"thrpt";80;14;528.857143;278.141953;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_0:secondary1";"thrpt";80;14;549.714286;320.227488;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_0:secondary2";"thrpt";80;14;615.500000;319.209585;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_0:secondary3";"thrpt";80;5;246.000000;847.566004;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_1";"thrpt";900;1;439.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_1:secondary1";"thrpt";900;1;953.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_1:secondary2";"thrpt";900;1;367.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2";"thrpt";466;9;545.000000;553.336699;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2:secondary1";"thrpt";466;9;434.444444;465.182504;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2:secondary2";"thrpt";466;9;470.333333;502.273041;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_2:secondary3";"thrpt";466;5;574.400000;969.535252;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3";"thrpt";968;14;417.571429;362.813967;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3:secondary1";"thrpt";968;14;672.214286;287.982211;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3:secondary2";"thrpt";968;14;560.142857;289.799961;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_3:secondary3";"thrpt";968;6;432.833333;1036.758184;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4";"thrpt";739;1;956.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4:secondary1";"thrpt";739;1;688.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4:secondary2";"thrpt";739;1;237.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 -"benchmark_4:secondary3";"thrpt";739;1;599.000000;NaN;"ops/ms";value0;value1;value2;value3;value4 +"Benchmark";"Mode";"Threads";"Samples";"Score";"Score Error (99.9%)";"Unit";"Param: param0";"Param: param1";"Param: param2";"Param: param3";"Param: param4" +"benchmark_0";"thrpt";80;14;528.857143;278.141953;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_0:secondary1";"thrpt";80;14;549.714286;320.227488;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_0:secondary2";"thrpt";80;14;615.500000;319.209585;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_0:secondary3";"thrpt";80;5;246.000000;847.566004;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_1";"thrpt";900;1;439.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_1:secondary1";"thrpt";900;1;953.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_1:secondary2";"thrpt";900;1;367.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2";"thrpt";466;9;545.000000;553.336699;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2:secondary1";"thrpt";466;9;434.444444;465.182504;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2:secondary2";"thrpt";466;9;470.333333;502.273041;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_2:secondary3";"thrpt";466;5;574.400000;969.535252;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3";"thrpt";968;14;417.571429;362.813967;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3:secondary1";"thrpt";968;14;672.214286;287.982211;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3:secondary2";"thrpt";968;14;560.142857;289.799961;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_3:secondary3";"thrpt";968;6;432.833333;1036.758184;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4";"thrpt";739;1;956.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4:secondary1";"thrpt";739;1;688.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4:secondary2";"thrpt";739;1;237.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" +"benchmark_4:secondary3";"thrpt";739;1;599.000000;NaN;"ops/ms";value0;[value1];{value2};'value3';"""value4""" \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root index c32acef6d..59590f709 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.root @@ -1,20 +1,20 @@ Benchmark (param0) (param1) (param2) (param3) (param4) Mode Cnt Score Error Units -benchmark_0 value0 value1 value2 value3 value4 thrpt 14 528.857 ± 278.142 ops/ms -benchmark_0:secondary1 value0 value1 value2 value3 value4 thrpt 14 549.714 ± 320.227 ops/ms -benchmark_0:secondary2 value0 value1 value2 value3 value4 thrpt 14 615.500 ± 319.210 ops/ms -benchmark_0:secondary3 value0 value1 value2 value3 value4 thrpt 5 246.000 ± 847.566 ops/ms -benchmark_1 value0 value1 value2 value3 value4 thrpt 439.000 ops/ms -benchmark_1:secondary1 value0 value1 value2 value3 value4 thrpt 953.000 ops/ms -benchmark_1:secondary2 value0 value1 value2 value3 value4 thrpt 367.000 ops/ms -benchmark_2 value0 value1 value2 value3 value4 thrpt 9 545.000 ± 553.337 ops/ms -benchmark_2:secondary1 value0 value1 value2 value3 value4 thrpt 9 434.444 ± 465.183 ops/ms -benchmark_2:secondary2 value0 value1 value2 value3 value4 thrpt 9 470.333 ± 502.273 ops/ms -benchmark_2:secondary3 value0 value1 value2 value3 value4 thrpt 5 574.400 ± 969.535 ops/ms -benchmark_3 value0 value1 value2 value3 value4 thrpt 14 417.571 ± 362.814 ops/ms -benchmark_3:secondary1 value0 value1 value2 value3 value4 thrpt 14 672.214 ± 287.982 ops/ms -benchmark_3:secondary2 value0 value1 value2 value3 value4 thrpt 14 560.143 ± 289.800 ops/ms -benchmark_3:secondary3 value0 value1 value2 value3 value4 thrpt 6 432.833 ± 1036.758 ops/ms -benchmark_4 value0 value1 value2 value3 value4 thrpt 956.000 ops/ms -benchmark_4:secondary1 value0 value1 value2 value3 value4 thrpt 688.000 ops/ms -benchmark_4:secondary2 value0 value1 value2 value3 value4 thrpt 237.000 ops/ms -benchmark_4:secondary3 value0 value1 value2 value3 value4 thrpt 599.000 ops/ms +benchmark_0 value0 [value1] {value2} 'value3' "value4" thrpt 14 528.857 ± 278.142 ops/ms +benchmark_0:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 549.714 ± 320.227 ops/ms +benchmark_0:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 615.500 ± 319.210 ops/ms +benchmark_0:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 246.000 ± 847.566 ops/ms +benchmark_1 value0 [value1] {value2} 'value3' "value4" thrpt 439.000 ops/ms +benchmark_1:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 953.000 ops/ms +benchmark_1:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 367.000 ops/ms +benchmark_2 value0 [value1] {value2} 'value3' "value4" thrpt 9 545.000 ± 553.337 ops/ms +benchmark_2:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 9 434.444 ± 465.183 ops/ms +benchmark_2:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 9 470.333 ± 502.273 ops/ms +benchmark_2:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 574.400 ± 969.535 ops/ms +benchmark_3 value0 [value1] {value2} 'value3' "value4" thrpt 14 417.571 ± 362.814 ops/ms +benchmark_3:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 672.214 ± 287.982 ops/ms +benchmark_3:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 560.143 ± 289.800 ops/ms +benchmark_3:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 6 432.833 ± 1036.758 ops/ms +benchmark_4 value0 [value1] {value2} 'value3' "value4" thrpt 956.000 ops/ms +benchmark_4:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 688.000 ops/ms +benchmark_4:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 237.000 ops/ms +benchmark_4:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 599.000 ops/ms \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru index cbf54a714..7bc560eda 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.ru @@ -1,20 +1,20 @@ Benchmark (param0) (param1) (param2) (param3) (param4) Mode Cnt Score Error Units -benchmark_0 value0 value1 value2 value3 value4 thrpt 14 528,857 ± 278,142 ops/ms -benchmark_0:secondary1 value0 value1 value2 value3 value4 thrpt 14 549,714 ± 320,227 ops/ms -benchmark_0:secondary2 value0 value1 value2 value3 value4 thrpt 14 615,500 ± 319,210 ops/ms -benchmark_0:secondary3 value0 value1 value2 value3 value4 thrpt 5 246,000 ± 847,566 ops/ms -benchmark_1 value0 value1 value2 value3 value4 thrpt 439,000 ops/ms -benchmark_1:secondary1 value0 value1 value2 value3 value4 thrpt 953,000 ops/ms -benchmark_1:secondary2 value0 value1 value2 value3 value4 thrpt 367,000 ops/ms -benchmark_2 value0 value1 value2 value3 value4 thrpt 9 545,000 ± 553,337 ops/ms -benchmark_2:secondary1 value0 value1 value2 value3 value4 thrpt 9 434,444 ± 465,183 ops/ms -benchmark_2:secondary2 value0 value1 value2 value3 value4 thrpt 9 470,333 ± 502,273 ops/ms -benchmark_2:secondary3 value0 value1 value2 value3 value4 thrpt 5 574,400 ± 969,535 ops/ms -benchmark_3 value0 value1 value2 value3 value4 thrpt 14 417,571 ± 362,814 ops/ms -benchmark_3:secondary1 value0 value1 value2 value3 value4 thrpt 14 672,214 ± 287,982 ops/ms -benchmark_3:secondary2 value0 value1 value2 value3 value4 thrpt 14 560,143 ± 289,800 ops/ms -benchmark_3:secondary3 value0 value1 value2 value3 value4 thrpt 6 432,833 ± 1036,758 ops/ms -benchmark_4 value0 value1 value2 value3 value4 thrpt 956,000 ops/ms -benchmark_4:secondary1 value0 value1 value2 value3 value4 thrpt 688,000 ops/ms -benchmark_4:secondary2 value0 value1 value2 value3 value4 thrpt 237,000 ops/ms -benchmark_4:secondary3 value0 value1 value2 value3 value4 thrpt 599,000 ops/ms +benchmark_0 value0 [value1] {value2} 'value3' "value4" thrpt 14 528,857 ± 278,142 ops/ms +benchmark_0:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 549,714 ± 320,227 ops/ms +benchmark_0:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 615,500 ± 319,210 ops/ms +benchmark_0:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 246,000 ± 847,566 ops/ms +benchmark_1 value0 [value1] {value2} 'value3' "value4" thrpt 439,000 ops/ms +benchmark_1:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 953,000 ops/ms +benchmark_1:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 367,000 ops/ms +benchmark_2 value0 [value1] {value2} 'value3' "value4" thrpt 9 545,000 ± 553,337 ops/ms +benchmark_2:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 9 434,444 ± 465,183 ops/ms +benchmark_2:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 9 470,333 ± 502,273 ops/ms +benchmark_2:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 574,400 ± 969,535 ops/ms +benchmark_3 value0 [value1] {value2} 'value3' "value4" thrpt 14 417,571 ± 362,814 ops/ms +benchmark_3:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 672,214 ± 287,982 ops/ms +benchmark_3:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 560,143 ± 289,800 ops/ms +benchmark_3:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 6 432,833 ± 1036,758 ops/ms +benchmark_4 value0 [value1] {value2} 'value3' "value4" thrpt 956,000 ops/ms +benchmark_4:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 688,000 ops/ms +benchmark_4:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 237,000 ops/ms +benchmark_4:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 599,000 ops/ms \ No newline at end of file diff --git a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us index c32acef6d..59590f709 100644 --- a/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us +++ b/jmh-core/src/test/resources/org/openjdk/jmh/results/format/output-golden.text.us @@ -1,20 +1,20 @@ Benchmark (param0) (param1) (param2) (param3) (param4) Mode Cnt Score Error Units -benchmark_0 value0 value1 value2 value3 value4 thrpt 14 528.857 ± 278.142 ops/ms -benchmark_0:secondary1 value0 value1 value2 value3 value4 thrpt 14 549.714 ± 320.227 ops/ms -benchmark_0:secondary2 value0 value1 value2 value3 value4 thrpt 14 615.500 ± 319.210 ops/ms -benchmark_0:secondary3 value0 value1 value2 value3 value4 thrpt 5 246.000 ± 847.566 ops/ms -benchmark_1 value0 value1 value2 value3 value4 thrpt 439.000 ops/ms -benchmark_1:secondary1 value0 value1 value2 value3 value4 thrpt 953.000 ops/ms -benchmark_1:secondary2 value0 value1 value2 value3 value4 thrpt 367.000 ops/ms -benchmark_2 value0 value1 value2 value3 value4 thrpt 9 545.000 ± 553.337 ops/ms -benchmark_2:secondary1 value0 value1 value2 value3 value4 thrpt 9 434.444 ± 465.183 ops/ms -benchmark_2:secondary2 value0 value1 value2 value3 value4 thrpt 9 470.333 ± 502.273 ops/ms -benchmark_2:secondary3 value0 value1 value2 value3 value4 thrpt 5 574.400 ± 969.535 ops/ms -benchmark_3 value0 value1 value2 value3 value4 thrpt 14 417.571 ± 362.814 ops/ms -benchmark_3:secondary1 value0 value1 value2 value3 value4 thrpt 14 672.214 ± 287.982 ops/ms -benchmark_3:secondary2 value0 value1 value2 value3 value4 thrpt 14 560.143 ± 289.800 ops/ms -benchmark_3:secondary3 value0 value1 value2 value3 value4 thrpt 6 432.833 ± 1036.758 ops/ms -benchmark_4 value0 value1 value2 value3 value4 thrpt 956.000 ops/ms -benchmark_4:secondary1 value0 value1 value2 value3 value4 thrpt 688.000 ops/ms -benchmark_4:secondary2 value0 value1 value2 value3 value4 thrpt 237.000 ops/ms -benchmark_4:secondary3 value0 value1 value2 value3 value4 thrpt 599.000 ops/ms +benchmark_0 value0 [value1] {value2} 'value3' "value4" thrpt 14 528.857 ± 278.142 ops/ms +benchmark_0:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 549.714 ± 320.227 ops/ms +benchmark_0:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 615.500 ± 319.210 ops/ms +benchmark_0:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 246.000 ± 847.566 ops/ms +benchmark_1 value0 [value1] {value2} 'value3' "value4" thrpt 439.000 ops/ms +benchmark_1:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 953.000 ops/ms +benchmark_1:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 367.000 ops/ms +benchmark_2 value0 [value1] {value2} 'value3' "value4" thrpt 9 545.000 ± 553.337 ops/ms +benchmark_2:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 9 434.444 ± 465.183 ops/ms +benchmark_2:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 9 470.333 ± 502.273 ops/ms +benchmark_2:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 5 574.400 ± 969.535 ops/ms +benchmark_3 value0 [value1] {value2} 'value3' "value4" thrpt 14 417.571 ± 362.814 ops/ms +benchmark_3:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 14 672.214 ± 287.982 ops/ms +benchmark_3:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 14 560.143 ± 289.800 ops/ms +benchmark_3:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 6 432.833 ± 1036.758 ops/ms +benchmark_4 value0 [value1] {value2} 'value3' "value4" thrpt 956.000 ops/ms +benchmark_4:secondary1 value0 [value1] {value2} 'value3' "value4" thrpt 688.000 ops/ms +benchmark_4:secondary2 value0 [value1] {value2} 'value3' "value4" thrpt 237.000 ops/ms +benchmark_4:secondary3 value0 [value1] {value2} 'value3' "value4" thrpt 599.000 ops/ms \ No newline at end of file From d049a9c8890120131f4abe21afb4b890152f850b Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 17 Jan 2019 18:18:56 +0100 Subject: [PATCH 143/342] 7902363: JMH should use upgraded plugins to be compatible with JDK 11, 12, 13 --- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- .../src/main/resources/archetype-resources/pom.xml | 4 ++-- pom.xml | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index d3af47c98..02ae093ee 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -182,7 +182,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.0 \${javac.target} \${javac.target} @@ -198,7 +198,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-shade-plugin - 2.2 + 3.2.1 package diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index dc7dc9a6a..8b54157ae 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -83,7 +83,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.0 \${javac.target} \${javac.target} @@ -93,7 +93,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-shade-plugin - 2.2 + 3.2.1 package diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index be2cd12d1..dc344fb36 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -195,7 +195,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.0 \${javac.target} \${javac.target} @@ -211,7 +211,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-shade-plugin - 2.2 + 3.2.1 package diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 5cc00dd86..127a512c7 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -188,7 +188,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.0 \${javac.target} \${javac.target} @@ -204,7 +204,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.apache.maven.plugins maven-shade-plugin - 2.2 + 3.2.1 package diff --git a/pom.xml b/pom.xml index fb45afbdc..c2b8317f3 100644 --- a/pom.xml +++ b/pom.xml @@ -170,7 +170,7 @@ questions. org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.8.0 org.apache.maven.plugins @@ -180,7 +180,7 @@ questions. org.apache.maven.plugins maven-shade-plugin - 2.2 + 3.2.1 org.apache.maven.plugins @@ -195,7 +195,7 @@ questions. org.apache.maven.plugins maven-javadoc-plugin - 3.0.0-M1 + 3.0.1 org.apache.maven.plugins @@ -283,7 +283,7 @@ questions. - 3.0 + 3.2 From 506853aa41a15c21c09da537f51f150003ce80df Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 17 Jan 2019 19:04:43 +0100 Subject: [PATCH 144/342] 7902360: JMH should be buildable with JDK 11, 12, 13 --- .../main/java/org/openjdk/jmh/profile/ExternalProfiler.java | 1 + .../main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java | 3 --- jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java | 2 +- jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java | 1 + pom.xml | 1 + 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ExternalProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ExternalProfiler.java index 357e83486..001de6818 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ExternalProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ExternalProfiler.java @@ -69,6 +69,7 @@ public interface ExternalProfiler extends Profiler { * after benchmark JVM had stopped. * * @param br benchmark result that was the result of the trial + * @param pid pid that the forked JVM had * @param stdOut file containing the standard output from the benchmark JVM * @param stdErr file containing the standard error from the benchmark JVM * @return profiler results diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index c07ddbfb5..e8a2002d6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -78,9 +78,6 @@ public class WinPerfAsmProfiler extends AbstractPerfAsmProfiler { private OptionSpec optXperfProviders; private OptionSpec optSymbolDir; - /** - * Constructor. - */ public WinPerfAsmProfiler(String initLine) throws ProfilerException { super(initLine, "SampledProfile"); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 9a27ce251..b58924329 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -129,7 +129,7 @@ public void list() { /** * Print matching benchmarks with parameters into output. - * @param options + * @param options options to use. */ public void listWithParams(CommandLineOptions options) { Set benchmarks = list.find(out, options.getIncludes(), options.getExcludes()); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 5f47c6500..dffc2e40b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -546,6 +546,7 @@ public static Properties readPropertiesFromCommand(List cmd) { * Adapts Iterator for Iterable. * Can be iterated only once! * + * @param element type * @param it iterator * @return iterable for given iterator */ diff --git a/pom.xml b/pom.xml index c2b8317f3..0e0446638 100644 --- a/pom.xml +++ b/pom.xml @@ -122,6 +122,7 @@ questions. maven-javadoc-plugin true + 8 From 2c20708b9286691108abbc1d62a90684b521bc7e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 22 Jan 2019 16:22:42 +0100 Subject: [PATCH 145/342] 7902171: CompilerControlExcludeActualTest fails intermittently --- .../CompilerControlDontInlineActualTest.java | 13 ++++++++---- .../CompilerControlExcludeActualTest.java | 21 ++++++++++++------- .../CompilerControlInlineActualTest.java | 13 ++++++++---- .../jmh/it/ccontrol/CompilerControlUtils.java | 8 ++++--- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineActualTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineActualTest.java index 31026809e..61e0548fb 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineActualTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineActualTest.java @@ -37,6 +37,8 @@ import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; +import java.util.Collection; + public class CompilerControlDontInlineActualTest { @CompilerControl(CompilerControl.Mode.DONT_INLINE) @@ -64,18 +66,21 @@ public void testBenchmark() throws RunnerException { .mode(mode) .shouldFailOnError(true) .addProfiler(LogConsumeProfiler.class) - .measurementIterations(mode == Mode.SingleShotTime ? 10000 : 1) + .measurementIterations(mode == Mode.SingleShotTime ? 200000 : 1) .measurementTime(TimeValue.seconds(5)) .warmupIterations(0) .forks(1) + .jvmArgsPrepend("-XX:CICompilerCount=2") // need to serialize the output properly .build(); RunResult runResult = new Runner(opts).runSingle(); - if (CompilerControlUtils.check(runResult, "@", "callee")) { // Poor man's check -XX:+PrintInlining works + Collection log = CompilerControlUtils.getLog(runResult); + + if (CompilerControlUtils.check(log, "@", "callee")) { // Poor man's check -XX:+PrintInlining works Assert.assertTrue("Failed with " + mode, - CompilerControlUtils.check(runResult, this.getClass().getName() + "::compilerControlSpecimen", "disallowed by")); + CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "disallowed by")); Assert.assertTrue("Failed with " + mode, - CompilerControlUtils.check(runResult, this.getClass().getName() + "::strawMethod", "disallowed by")); + CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "disallowed by")); } } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeActualTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeActualTest.java index 12ca37d24..e7dcd2338 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeActualTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeActualTest.java @@ -37,6 +37,8 @@ import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; +import java.util.Collection; + public class CompilerControlExcludeActualTest { @CompilerControl(CompilerControl.Mode.EXCLUDE) @@ -64,23 +66,26 @@ public void testBenchmark() throws RunnerException { .mode(mode) .shouldFailOnError(true) .addProfiler(LogConsumeProfiler.class) - .measurementIterations(mode == Mode.SingleShotTime ? 10000 : 1) + .measurementIterations(mode == Mode.SingleShotTime ? 200000 : 1) .measurementTime(TimeValue.seconds(5)) .warmupIterations(0) .forks(1) + .jvmArgsPrepend("-XX:CICompilerCount=2") // need to serialize the output properly .build(); RunResult runResult = new Runner(opts).runSingle(); - if (CompilerControlUtils.check(runResult, "@", "callee")) { // Poor man's check -XX:+PrintInlining works + Collection log = CompilerControlUtils.getLog(runResult); + + if (CompilerControlUtils.check(log, "@", "callee")) { // Poor man's check -XX:+PrintInlining works Assert.assertTrue("Failed with " + mode, - CompilerControlUtils.check(runResult, this.getClass().getName() + "::compilerControlSpecimen", "excluded by") || - CompilerControlUtils.check(runResult, this.getClass().getName() + "::compilerControlSpecimen", "not compilable") || - CompilerControlUtils.check(runResult, this.getClass().getName() + "::compilerControlSpecimen", "disallowed by CompileCommand") + CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "excluded by") || + CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "not compilable") || + CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "disallowed by CompileCommand") ); Assert.assertTrue("Failed with " + mode, - CompilerControlUtils.check(runResult, this.getClass().getName() + "::strawMethod", "excluded by") || - CompilerControlUtils.check(runResult, this.getClass().getName() + "::strawMethod", "not compilable") || - CompilerControlUtils.check(runResult, this.getClass().getName() + "::strawMethod", "disallowed by CompileCommand") + CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "excluded by") || + CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "not compilable") || + CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "disallowed by CompileCommand") ); } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineActualTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineActualTest.java index 7da03ffb8..e2c8b6928 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineActualTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineActualTest.java @@ -37,6 +37,8 @@ import org.openjdk.jmh.runner.options.OptionsBuilder; import org.openjdk.jmh.runner.options.TimeValue; +import java.util.Collection; + public class CompilerControlInlineActualTest { @CompilerControl(CompilerControl.Mode.INLINE) @@ -64,18 +66,21 @@ public void testBenchmark() throws RunnerException { .mode(mode) .shouldFailOnError(true) .addProfiler(LogConsumeProfiler.class) - .measurementIterations(mode == Mode.SingleShotTime ? 10000 : 1) + .measurementIterations(mode == Mode.SingleShotTime ? 200000 : 1) .measurementTime(TimeValue.seconds(5)) .warmupIterations(0) .forks(1) + .jvmArgsPrepend("-XX:CICompilerCount=2") // need to serialize the output properly .build(); RunResult runResult = new Runner(opts).runSingle(); - if (CompilerControlUtils.check(runResult, "@", "callee")) { // Poor man's check -XX:+PrintInlining works + Collection log = CompilerControlUtils.getLog(runResult); + + if (CompilerControlUtils.check(log, "@", "callee")) { // Poor man's check -XX:+PrintInlining works Assert.assertTrue("Failed with " + mode, - CompilerControlUtils.check(runResult, this.getClass().getName() + "::compilerControlSpecimen", "force inline by")); + CompilerControlUtils.check(log, this.getClass().getName() + "::compilerControlSpecimen", "force inline by")); Assert.assertTrue("Failed with " + mode, - CompilerControlUtils.check(runResult, this.getClass().getName() + "::strawMethod", "force inline by")); + CompilerControlUtils.check(log, this.getClass().getName() + "::strawMethod", "force inline by")); } } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlUtils.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlUtils.java index c08097d7b..f6209bf01 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlUtils.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlUtils.java @@ -31,11 +31,13 @@ public class CompilerControlUtils { - public static boolean check(RunResult runResult, String... checkFor) { + public static Collection getLog(RunResult runResult) { LogConsumeProfiler.LogConsumeResult r = (LogConsumeProfiler.LogConsumeResult) runResult.getSecondaryResults().get("logout"); - Collection lines = r.getLines(); + return r.getLines(); + } - line: for (String line : lines) { + public static boolean check(Collection log, String... checkFor) { + line: for (String line : log) { System.out.println(line); for (String m : checkFor) { if (!line.contains(m)) continue line; From 768f996620d667bad224743e49ca9125f99cab2f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 22 Jan 2019 16:22:44 +0100 Subject: [PATCH 146/342] 7902370: {BatchSize,OpsPerInv}SanityTests fail intermittently --- .../jmh/it/batchsize/BatchSizeSanityTest.java | 48 +++++++----------- .../jmh/it/batchsize/OpsPerInvSanityTest.java | 49 ++++++++----------- 2 files changed, 38 insertions(+), 59 deletions(-) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java index 9a932ef66..734aa8b5f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java @@ -43,6 +43,8 @@ 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.openjdk.jmh.util.Statistics; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -50,28 +52,11 @@ @State(Scope.Thread) public class BatchSizeSanityTest { - private static final AtomicInteger invCount = new AtomicInteger(); - private static volatile long startTime; - private static volatile long stopTime; - - @Setup(Level.Iteration) - public void beforeIter() { - startTime = System.nanoTime(); - } - - @TearDown(Level.Iteration) - public void afterIter() { - stopTime = System.nanoTime(); - } + private static final int SLEEP_TIME_MS = 1; @Benchmark - @Fork(0) - @Warmup(iterations = 0) - @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS) - @OutputTimeUnit(TimeUnit.NANOSECONDS) public void test() throws InterruptedException { - TimeUnit.MILLISECONDS.sleep(1); - invCount.incrementAndGet(); + TimeUnit.MILLISECONDS.sleep(SLEEP_TIME_MS); } @Test @@ -85,11 +70,14 @@ public void invokeAPI() throws RunnerException { } private void doWith(Mode mode, int batchSize) throws RunnerException { - invCount.set(0); - Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) + .warmupIterations(0) + .measurementTime(TimeValue.seconds(1)) + .measurementIterations(5) + .forks(1) + .timeUnit(TimeUnit.MILLISECONDS) .measurementBatchSize(batchSize) .mode(mode) .build(); @@ -97,27 +85,27 @@ private void doWith(Mode mode, int batchSize) throws RunnerException { final double TOLERANCE = 0.30; - double expectedScore = 0.0; - - double time = stopTime - startTime; - double calls = invCount.get(); + double expectedScore; + double actualScore; + Statistics stats = run.getPrimaryResult().getStatistics(); switch (mode) { case Throughput: - expectedScore = (calls / batchSize) / time; + expectedScore = 1.0 / (1.0 * SLEEP_TIME_MS * batchSize); + actualScore = stats.getMax(); break; case AverageTime: case SampleTime: - expectedScore = time / (calls / batchSize); - break; case SingleShotTime: - expectedScore = time; + expectedScore = SLEEP_TIME_MS * batchSize; + actualScore = stats.getMin(); break; default: + expectedScore = Double.NaN; + actualScore = Double.NaN; Assert.fail("Unhandled mode: " + mode); } - double actualScore = run.getPrimaryResult().getScore(); Assert.assertTrue(mode + ", " + batchSize + ": " + expectedScore + " vs " + actualScore, Math.abs(1 - actualScore / expectedScore) < TOLERANCE); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java index 59542c94b..cb5feaceb 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java @@ -43,6 +43,8 @@ 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.openjdk.jmh.util.Statistics; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -50,28 +52,11 @@ @State(Scope.Thread) public class OpsPerInvSanityTest { - private static final AtomicInteger invCount = new AtomicInteger(); - private static volatile long startTime; - private static volatile long stopTime; - - @Setup(Level.Iteration) - public void beforeIter() { - startTime = System.nanoTime(); - } - - @TearDown(Level.Iteration) - public void afterIter() { - stopTime = System.nanoTime(); - } + private static final int SLEEP_TIME_MS = 5; @Benchmark - @Fork(0) - @Warmup(iterations = 0) - @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS) - @OutputTimeUnit(TimeUnit.NANOSECONDS) public void test() throws InterruptedException { - TimeUnit.MILLISECONDS.sleep(1); - invCount.incrementAndGet(); + TimeUnit.MILLISECONDS.sleep(SLEEP_TIME_MS); } @Test @@ -85,11 +70,14 @@ public void invokeAPI() throws RunnerException { } private void doWith(Mode mode, int opsPerInv) throws RunnerException { - invCount.set(0); - Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .shouldFailOnError(true) + .warmupIterations(0) + .measurementTime(TimeValue.seconds(1)) + .measurementIterations(5) + .forks(1) + .timeUnit(TimeUnit.MILLISECONDS) .operationsPerInvocation(opsPerInv) .mode(mode) .build(); @@ -97,27 +85,30 @@ private void doWith(Mode mode, int opsPerInv) throws RunnerException { final double TOLERANCE = 0.30; - double expectedScore = 0.0; - - double time = stopTime - startTime; - double calls = invCount.get(); + double expectedScore; + double actualScore; + Statistics statistics = run.getPrimaryResult().getStatistics(); switch (mode) { case Throughput: - expectedScore = (calls * opsPerInv) / time; + expectedScore = 1.0 * opsPerInv / SLEEP_TIME_MS; + actualScore = statistics.getMax(); break; case AverageTime: case SampleTime: - expectedScore = time / (calls * opsPerInv); + expectedScore = 1.0 * SLEEP_TIME_MS / opsPerInv; + actualScore = statistics.getMin(); break; case SingleShotTime: - expectedScore = time; + expectedScore = SLEEP_TIME_MS; + actualScore = statistics.getMin(); break; default: + expectedScore = Double.NaN; + actualScore = Double.NaN; Assert.fail("Unhandled mode: " + mode); } - double actualScore = run.getPrimaryResult().getScore(); Assert.assertTrue(mode + ", " + opsPerInv + ": " + expectedScore + " vs " + actualScore, Math.abs(1 - actualScore / expectedScore) < TOLERANCE); } From 55cb36bf8c2d75de3a68ce92f7700e901bc3a079 Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Thu, 18 Apr 2019 11:45:30 +0200 Subject: [PATCH 147/342] 7902452: Missing RFFieldInfo.toString --- .../org/openjdk/jmh/generators/reflection/RFFieldInfo.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFFieldInfo.java b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFFieldInfo.java index 5beac2d2f..532aba6f3 100644 --- a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFFieldInfo.java +++ b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFFieldInfo.java @@ -74,4 +74,9 @@ public boolean isStatic() { public boolean isFinal() { return Modifier.isFinal(f.getModifiers()); } + + @Override + public String toString() { + return declaringClass.getQualifiedName() + "." + f.getName(); + } } From 79b29f205d20c98ee127a23bc086c278a463fc57 Mon Sep 17 00:00:00 2001 From: Sergey Kuksenko Date: Fri, 17 May 2019 10:44:26 -0700 Subject: [PATCH 148/342] 7902450: perfasm should provide a way to merge all hot regions from the same method Reviewed-by: shade, ecaspole --- .../jmh/profile/AbstractPerfAsmProfiler.java | 62 ++++++++++++++++--- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 077c39f43..367de1033 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -46,6 +46,7 @@ public abstract class AbstractPerfAsmProfiler implements ExternalProfiler { private final int regionTooBigThreshold; private final int printMargin; private final int mergeMargin; + private final boolean mergeMethods; private final int delayMsec; private final int lengthMsec; @@ -113,6 +114,10 @@ protected AbstractPerfAsmProfiler(String initLine, String... events) throws Prof "Merge margin. The regions separated by less than the margin are merged.") .withRequiredArg().ofType(Integer.class).describedAs("lines").defaultsTo(32); + OptionSpec optMergeMethods = parser.accepts("mergeMethods", + "Merge all regions from the same method") + .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(false); + OptionSpec optDelay = parser.accepts("delay", "Delay collection for a given time, in milliseconds; -1 to detect automatically.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(-1); @@ -199,6 +204,7 @@ protected AbstractPerfAsmProfiler(String initLine, String... events) throws Prof regionTooBigThreshold = set.valueOf(optThreshold); printMargin = set.valueOf(optPrintMargin); mergeMargin = set.valueOf(optMergeMargin); + mergeMethods = set.valueOf(optMergeMethods); delayMsec = set.valueOf(optDelay); lengthMsec = set.valueOf(optLength); @@ -678,7 +684,7 @@ private List makeRegions(Assembly asms, PerfEvents events) { List regions = new ArrayList<>(); SortedSet allAddrs = events.getAllAddresses(); - for (Interval intv : figureHotIntervals(allAddrs)) { + for (Interval intv : figureHotIntervals(allAddrs, asms)) { SortedSet eventfulAddrs = allAddrs.subSet(intv.src, intv.dst + 1); List regionLines = asms.getLines(intv.src, intv.dst, printMargin); @@ -711,7 +717,7 @@ private List makeRegions(Assembly asms, PerfEvents events) { } - private List figureHotIntervals(SortedSet addrs) { + private List figureHotIntervals(SortedSet addrs, Assembly asms) { if (addrs.isEmpty()) { return Collections.emptyList(); } @@ -721,19 +727,34 @@ private List figureHotIntervals(SortedSet addrs) { long lastAddr = addrs.first(); for (long addr : addrs) { if (addr - lastAddr > mergeMargin) { - intervals.add(new Interval(begAddr, lastAddr)); + addInterval(intervals, begAddr, lastAddr, asms); begAddr = addr; } lastAddr = addr; } if (begAddr != lastAddr) { - intervals.add(new Interval(begAddr, lastAddr)); + addInterval(intervals, begAddr, lastAddr, asms); } return intervals; } + private void addInterval(List intervals, long begAddr, long lastAddr, Assembly asms) { + if (!mergeMethods || intervals.isEmpty()) { + intervals.add(new Interval(begAddr, lastAddr)); + } else { + Interval prev = intervals.get(intervals.size() - 1); + MethodDesc prevMethod = asms.getMethod(prev.src); + MethodDesc method = asms.getMethod(begAddr); + if (prevMethod == null || method == null || !prevMethod.equals(method)) { + intervals.add(new Interval(begAddr, lastAddr)); + } else { + intervals.set(intervals.size() - 1, new Interval(prev.src, lastAddr)); + } + } + } + private Collection> splitAssembly(File stdOut) { try (FileReader in = new FileReader(stdOut); BufferedReader br = new BufferedReader(in)) { @@ -994,6 +1015,33 @@ public int size() { return addressMap.size(); } + private boolean isSameMethod(MethodDesc method, int idx) { + ASMLine line = lines.get(idx); + Long addr = line != null ? line.addr : null; + MethodDesc m = addr != null ? getMethod(addr) : null; + return m == null ? true : Objects.equals(m, method); + // if can't find method for the line assume it equals + } + + private int adjustWindowForward(MethodDesc method, int beginIdx, int window) { + for (; beginIdx > 0 && window > 0; beginIdx--, window--) { + if (!isSameMethod(method, beginIdx - 1)) { + return beginIdx; + } + } + return beginIdx; + } + + private int adjustWindowBackward(MethodDesc method, int endIdx, int window) { + int size = lines.size(); + for (; endIdx < size && window > 0; endIdx++, window--) { + if (!isSameMethod(method, endIdx)) { + return endIdx; + } + } + return endIdx; + } + public List getLines(long begin, long end, int window) { SortedMap tailMap = addressMap.tailMap(begin); @@ -1016,9 +1064,9 @@ public List getLines(long begin, long end, int window) { } else { return Collections.emptyList(); } - - beginIdx = Math.max(0, beginIdx - window); - endIdx = Math.min(lines.size(), endIdx + 2 + window); + MethodDesc method = getMethod(begin); + beginIdx = adjustWindowForward(method, beginIdx, window); + endIdx = adjustWindowBackward(method, endIdx, 2 + window); // Compensate for minute discrepancies if (beginIdx < endIdx) { From 2abf5920a26546c952e0b34d677cae75a94f661c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 28 Oct 2019 13:55:00 +0100 Subject: [PATCH 149/342] 7902528: Reentrant BinaryLinkClient::pushFrame corrupts the stream --- .../jmh/runner/link/BinaryLinkClient.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkClient.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkClient.java index a88a04ac8..4152adf39 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkClient.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/link/BinaryLinkClient.java @@ -45,7 +45,9 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.net.Socket; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; public final class BinaryLinkClient { @@ -62,6 +64,8 @@ public final class BinaryLinkClient { private final OutputFormat outputFormat; private volatile boolean failed; private int resetToGo; + private final List delayedFrames; + private boolean inFrame; public BinaryLinkClient(String hostName, int hostPort) throws IOException { this.lock = new Object(); @@ -86,6 +90,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl } } ); + + this.delayedFrames = new ArrayList<>(); } private void pushFrame(Serializable frame) throws IOException { @@ -102,7 +108,18 @@ private void pushFrame(Serializable frame) throws IOException { // pushed something out. synchronized (lock) { + if (inFrame) { + // Something had produced this frame while we were writing another one. + // Most probably, stdout/stderr message was produced when serializing data. + // Delay this frame until the write is over, and let the original writer to + // pick it up later. + delayedFrames.add(frame); + return; + } + try { + inFrame = true; + if (resetToGo-- < 0) { oos.reset(); resetToGo = RESET_EACH; @@ -110,9 +127,22 @@ private void pushFrame(Serializable frame) throws IOException { oos.writeObject(frame); oos.flush(); + + // Do all delayed frames now. On the off-chance their writes produce more frames, + // drain them recursively. + while (!delayedFrames.isEmpty()) { + List frames = new ArrayList<>(delayedFrames); + delayedFrames.clear(); + for (Serializable f : frames) { + oos.writeObject(f); + } + oos.flush(); + } } catch (IOException e) { failed = true; throw e; + } finally { + inFrame = false; } } } From 117f1e89fcffe057301651425238485e6fd4e210 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 28 Oct 2019 16:51:28 +0100 Subject: [PATCH 150/342] 7902529: {perf,dtrace}asm profilers should not swallow IOExceptions --- .../java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java | 4 ---- .../main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java | 2 +- .../java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java | 2 +- .../main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 367de1033..6370c21a5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -968,10 +968,6 @@ protected static class PerfEvents { } } - public PerfEvents(Collection tracedEvents) { - this(tracedEvents, Collections.>emptyMap(), new IntervalMap()); - } - public boolean isEmpty() { return events.isEmpty(); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java index d3ee7189e..2c7ba302b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java @@ -205,7 +205,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { return new PerfEvents(this.events, allEvents, methodMap); } catch (IOException e) { - return new PerfEvents(events); + throw new RuntimeException(e); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index f6b5b6c36..d96262b87 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -267,7 +267,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { return new PerfEvents(this.events, events, methodMap); } catch (IOException e) { - return new PerfEvents(events); + throw new RuntimeException(e); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index e8a2002d6..7c6c4df74 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -257,7 +257,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { return new PerfEvents(this.events, events, methodMap); } catch (IOException e) { - return new PerfEvents(events); + throw new RuntimeException(e); } } From eec85816312beeef5010aefceb8d00cd61d6ba28 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 28 Oct 2019 19:45:49 +0100 Subject: [PATCH 151/342] 7902530: dtraceasm should protect from completely corrupted lines --- .../main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java index 2c7ba302b..b27cd66d3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java @@ -145,6 +145,11 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { line = line.trim(); line = line.substring(line.indexOf(":profile")); String[] splits = line.split(" ", 5); + if (splits.length < 2) { + // Suspect completely corrupted line, skip + continue; + } + String sampledPid = splits[1]; if (!sampledPid.equals(pid)) { From b82516a8c5fcd5640d3b93556a34174b94b18865 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 29 Oct 2019 10:42:40 +0100 Subject: [PATCH 152/342] 7902531: JMH archetypes should include ServicesResourceTransformer --- .../src/main/resources/archetype-resources/pom.xml | 1 + .../src/main/resources/archetype-resources/pom.xml | 1 + .../src/main/resources/archetype-resources/pom.xml | 1 + .../src/main/resources/archetype-resources/pom.xml | 1 + jmh-samples/pom.xml | 4 ++-- 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 02ae093ee..ebea8b381 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -211,6 +211,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh.Main + diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 8b54157ae..761842cc9 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -106,6 +106,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh.Main + diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index dc344fb36..b60991728 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -224,6 +224,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh.Main + diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index 127a512c7..2a040fbb6 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -217,6 +217,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh.Main + diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 84ff98107..dd72b461e 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -99,10 +99,10 @@ THE POSSIBILITY OF SUCH DAMAGE. ${uberjar.name} - + org.openjdk.jmh.Main + From 10cca516fde239658224cd87690535c0152c3bdb Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 29 Oct 2019 10:42:43 +0100 Subject: [PATCH 153/342] 7902532: Profiler Javadoc should be clear about SPI-related expectations --- .../src/main/java/org/openjdk/jmh/profile/Profiler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/Profiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/Profiler.java index 9d5313d46..0a1a6fa7d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/Profiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/Profiler.java @@ -36,6 +36,12 @@ * The message in {@link org.openjdk.jmh.profile.ProfilerException} should * clearly articulate the reason. * + *

    JMH will try to discover profiler implementations using the SPI mechanism. + * Note: discoverable implementations must provide a no-arg constructor + * for initial discovery; the instance created during discovery will be rejected. + * If implementation would have a constructor accepting the String option line, + * it would be preferred for subsequent instantiation over the no-arg constructor. + * *

    Profilers normally implement one of the subinterfaces.

    * @see org.openjdk.jmh.profile.ExternalProfiler * @see org.openjdk.jmh.profile.InternalProfiler From ae8292a47dd87de08bb6d76e64658fbd406762b0 Mon Sep 17 00:00:00 2001 From: Jorn Vernee Date: Thu, 31 Oct 2019 13:00:52 +0100 Subject: [PATCH 154/342] 7902533: xperfasm cannot parse output with commas in symbol names --- .../main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index 7c6c4df74..b52c57a15 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -193,7 +193,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { while ((line = reader.readLine()) != null) { line = line.trim(); - String[] elems = line.split(","); + String[] elems = line.split(",\\s+"); String evName = elems[0].trim(); From 258b27d1eb4594fbc17ab06de28e247036c74d11 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Wed, 30 Oct 2019 17:31:49 +0800 Subject: [PATCH 155/342] 7902477: perfasm fails with latest JDK 13 --- .../openjdk/jmh/profile/AbstractPerfAsmProfiler.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 6370c21a5..8faf4cb03 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -843,7 +843,17 @@ private Assembly readAssembly(File stdOut) { // invokehandle 233 invokehandle [0x00007f631d023100, 0x00007f631d0233c0] 704 bytes // StubRoutines::catch_exception [0x00007feb43fa7b27, 0x00007feb43fa7b46[ (31 bytes) - Pattern pattern = Pattern.compile("(.+)( +)\\[(.+), (.+)[\\]\\[](.*)"); + // JDK 13 adds another "-------" line after StubRoutines line, so we need to filter out + // mismatched lines that follow it. This is why regexp is anchored at the start of the line. + // Example: + // + // StubRoutines::updateBytesCRC32 [0x0000ffff6c819700, 0x0000ffff6c819870] (368 bytes) + // -------------------------------------------------------------------------------- + // 0x0000ffff6c819700: stp x29, x30, [sp, #-16]! <--- do not match this + // 0x0000ffff6c819704: mov x29, sp + // 0x0000ffff6c819708: mvn w0, w0 + + Pattern pattern = Pattern.compile("^(\\S.*)( +)\\[(.+), (.+)[\\]\\[](.*)"); Matcher matcher = pattern.matcher(line); if (matcher.matches()) { From 1fdceaf48d6b6fe71951bac110682d077570f26e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 1 Nov 2019 13:59:55 +0100 Subject: [PATCH 156/342] JMH v1.22 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 1d97463c0..621a7864e 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.22-SNAPSHOT + 1.22 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index fb57a31b9..899199c96 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.22-SNAPSHOT + 1.22 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 0bbef9e31..9b661359a 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.22-SNAPSHOT + 1.22 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index b155ccf52..77e3664e7 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.22-SNAPSHOT + 1.22 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index e7a5aa0e6..fb6c87f5d 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 457e24b42..0db75fd80 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 9bfd0eac4..104afb567 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 95f97518d..0f7477e9f 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 625ad8db1..76266ce61 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 7dd2b5611..e385b8689 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index a00fda4e8..c240a0da6 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index bf5f02d8a..457e46f42 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index d154b4492..d7d1059f6 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index dd72b461e..1036f6f72 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.22-SNAPSHOT + 1.22 JMH Samples diff --git a/pom.xml b/pom.xml index 0e0446638..0c6c5dbc9 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.22-SNAPSHOT + 1.22 Java Microbenchmark Harness Parent From 4056fcffe5c13836501bf63971d1b089ddde91db Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 1 Nov 2019 14:00:00 +0100 Subject: [PATCH 157/342] Added tag 1.22 for changeset 40c1cca654c1 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 424703282..2bc204206 100644 --- a/.hgtags +++ b/.hgtags @@ -90,3 +90,4 @@ d4a8ae32b9063cf17c699455ced1b0d718f4977a 1.17.3 b7dc6e851f12a5bf2086f6f5d963d939ea5bd509 1.19 bd52958ab68089093f8c21d0a7c4af2848b845f6 1.20 f25ae8584db1d6d4602af701688c2ccb90684396 1.21 +40c1cca654c119c1ac9097f38f934cf9e42b311e 1.22 From 30f86ca1d1407957c0eb57b94049167c0b2e56c0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 1 Nov 2019 14:00:17 +0100 Subject: [PATCH 158/342] Continue in 1.23-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 621a7864e..0c9a6967a 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.22 + 1.23-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 899199c96..a36339785 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.22 + 1.23-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 9b661359a..ac4433284 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.22 + 1.23-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 77e3664e7..409d805d5 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.22 + 1.23-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index fb6c87f5d..3853792d7 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 0db75fd80..c76ba767b 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 104afb567..289b34790 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 0f7477e9f..0aa198dfd 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 76266ce61..a82f52eb4 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index e385b8689..2102db1f8 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index c240a0da6..caeaf04aa 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 457e46f42..681c4fc0d 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index d7d1059f6..882cac4d3 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 1036f6f72..2f0b8b7a7 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.22 + 1.23-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 0c6c5dbc9..25e030f85 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.22 + 1.23-SNAPSHOT Java Microbenchmark Harness Parent From 6d8a6e8fafc42d0e81cf65159e0096f1a2ad8044 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 3 Jan 2020 16:11:26 +0100 Subject: [PATCH 159/342] 7902560: Race in indent generation code --- .../generators/core/BenchmarkGenerator.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 69ac73337..29b79ddc5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -1115,19 +1115,27 @@ private String emitCall(MethodInfo method, StateObjectHandler states) { } } - static String[] INDENTS = new String[0]; + static volatile String[] INDENTS; + static final Object INDENTS_LOCK = new Object(); static String ident(int tabs) { - final int TAB_SIZE = 4; - if (tabs >= INDENTS.length) { - INDENTS = new String[tabs + 1]; - for (int p = 0; p <= tabs; p++) { - char[] chars = new char[p * TAB_SIZE]; - Arrays.fill(chars, ' '); - INDENTS[p] = new String(chars); + String[] is = INDENTS; + if (is == null || tabs >= is.length) { + synchronized (INDENTS_LOCK) { + is = INDENTS; + if (is == null || tabs >= is.length) { + final int TAB_SIZE = 4; + is = new String[tabs + 1]; + for (int p = 0; p <= tabs; p++) { + char[] cs = new char[p * TAB_SIZE]; + Arrays.fill(cs, ' '); + is[p] = new String(cs); + } + INDENTS = is; + } } } - return INDENTS[tabs]; + return is[tabs]; } } From e7e3dd8c469147659c31c52442d1681bec5ee0f3 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 3 Jan 2020 16:36:20 +0100 Subject: [PATCH 160/342] Amend "7902560: Race in indent generation code" with test --- .../core/BenchmarkGeneratorTest.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 jmh-core/src/test/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorTest.java diff --git a/jmh-core/src/test/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorTest.java b/jmh-core/src/test/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorTest.java new file mode 100644 index 000000000..3107114ee --- /dev/null +++ b/jmh-core/src/test/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.generators.core; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.concurrent.ThreadLocalRandom; + +public class BenchmarkGeneratorTest { + + static final int TAB_SIZE = 4; + + @Test + public void testIndentsForward() { + for (int c = 0; c < 10; c++) { + BenchmarkGenerator.INDENTS = null; + Assert.assertEquals(c*TAB_SIZE, BenchmarkGenerator.ident(c).length()); + } + } + + @Test + public void testIndentsBackwards() { + for (int c = 10; c >= 0; c--) { + BenchmarkGenerator.INDENTS = null; + Assert.assertEquals(c*TAB_SIZE, BenchmarkGenerator.ident(c).length()); + } + } + + @Test + public void testIndentsRandom() { + for (int c = 0; c < 10; c++) { + BenchmarkGenerator.INDENTS = null; + int i = ThreadLocalRandom.current().nextInt(10); + Assert.assertEquals(i*TAB_SIZE, BenchmarkGenerator.ident(i).length()); + } + } + +} From aef7eb4717861de04b02476c93a6ddd244e6fb29 Mon Sep 17 00:00:00 2001 From: Jorn Vernee Date: Thu, 16 Jan 2020 20:16:07 +0100 Subject: [PATCH 161/342] 7902573: perfasm* should understand Intel syntax address literals --- .../jmh/profile/AbstractPerfAsmProfiler.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 8faf4cb03..0ef7f7107 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -822,12 +822,12 @@ private Assembly readAssembly(File stdOut) { if (elements.length > 1 && (drawInterJumps || drawIntraJumps)) { for (int c = 1; c < elements.length; c++) { - if (elements[c].startsWith("0x")) { + if (maybeAddress(elements[c])) { try { Long target = parseAddress(elements[c]); intervals.add(new Interval(addr, target)); } catch (NumberFormatException e) { - // nope + // Nope, not the address. } } } @@ -918,8 +918,18 @@ private Assembly readAssembly(File stdOut) { return new Assembly(lines, addressMap, methodMap, intervals); } + private boolean maybeAddress(String str) { + return str.startsWith("0x") || str.endsWith("h"); + } + private Long parseAddress(String address) { - return Long.valueOf(address.replace("0x", "").replace(":", ""), 16); + if (address.startsWith("0x")) { // AT&T + return Long.valueOf(address.replace("0x", "").replace(":", ""), 16); + } else if (address.endsWith("h")) { // Intel + return Long.valueOf(address.replace("h", ""), 16); + } else { + throw new NumberFormatException("Address format not recognized: " + address); + } } static class PerfResult extends Result { From 4264de9486c32b48da8161e3ac076a0187b4176f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 20 Jan 2020 14:02:39 +0100 Subject: [PATCH 162/342] 7902575: Various code cleanups --- .../jmh/it/profilers/GCProfilerTest.java | 6 - .../src/main/java/org/openjdk/jmh/Main.java | 2 +- .../core/BenchmarkGeneratorUtils.java | 2 +- .../jmh/generators/core/StateObject.java | 2 +- .../generators/core/StateObjectHandler.java | 18 +- .../openjdk/jmh/infra/IterationParams.java | 3 +- .../jmh/profile/AbstractPerfAsmProfiler.java | 28 +-- .../jmh/profile/DTraceAsmProfiler.java | 2 +- .../org/openjdk/jmh/profile/GCProfiler.java | 3 - .../jmh/profile/LinuxPerfAsmProfiler.java | 6 +- .../jmh/profile/WinPerfAsmProfiler.java | 4 +- .../org/openjdk/jmh/results/RunResult.java | 4 +- .../org/openjdk/jmh/runner/BaseRunner.java | 1 - .../openjdk/jmh/runner/BenchmarkHandler.java | 2 +- .../org/openjdk/jmh/runner/BenchmarkList.java | 15 +- .../jmh/runner/BenchmarkListEntry.java | 9 +- .../org/openjdk/jmh/runner/CompilerHints.java | 16 +- .../org/openjdk/jmh/runner/ForkedMain.java | 4 +- .../jmh/runner/OutputFormatAdapter.java | 2 +- .../org/openjdk/jmh/runner/VersionMain.java | 2 +- .../openjdk/jmh/runner/WorkloadParams.java | 14 +- .../jmh/runner/format/TextReportFormat.java | 2 +- .../jmh/runner/options/OptionsBuilder.java | 2 +- .../openjdk/jmh/runner/options/TimeValue.java | 2 +- .../java/org/openjdk/jmh/util/FileUtils.java | 2 - .../java/org/openjdk/jmh/util/Interval.java | 10 +- .../openjdk/jmh/util/NullOutputStream.java | 7 +- .../java/org/openjdk/jmh/util/Optional.java | 3 +- .../main/java/org/openjdk/jmh/util/Utils.java | 4 +- .../jmh/util/lines/TestLineReader.java | 4 +- .../jmh/results/TestAggregateResult.java | 4 +- .../openjdk/jmh/runner/TestBenchmarkList.java | 26 +-- .../jmh/runner/options/TestIncludes.java | 2 +- .../jmh/runner/options/TestOptions.java | 104 +++++------ .../jmh/runner/options/TestParentOptions.java | 162 +++++++++--------- .../openjdk/jmh/util/TestListStatistics.java | 4 +- .../jmh/util/TestMultisetStatistics.java | 5 +- .../jmh/util/TestSingletonStatistics.java | 2 +- .../annotations/APGeneratorSource.java | 4 +- .../asm/AnnotationInvocationHandler.java | 3 +- .../jmh/samples/JMHSample_12_Forking.java | 4 +- .../jmh/samples/JMHSample_32_BulkWarmup.java | 4 +- 42 files changed, 233 insertions(+), 272 deletions(-) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerTest.java index 00f88a722..47089c741 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerTest.java @@ -77,12 +77,6 @@ public Object allocateObjectSampleTime() { @Test public void testAllocationProfiler() throws RunnerException { - try { - new GCProfiler(); - } catch (ProfilerException e) { - // not supported - return; - } Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(GCProfiler.class) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/Main.java b/jmh-core/src/main/java/org/openjdk/jmh/Main.java index b52522b2c..acb6f374a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/Main.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/Main.java @@ -36,7 +36,7 @@ */ public class Main { - public static void main(String[] argv) throws RunnerException, IOException { + public static void main(String[] argv) throws IOException { try { CommandLineOptions cmdOptions = new CommandLineOptions(argv); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java index 3a4e6bc09..0e73d226a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGeneratorUtils.java @@ -287,7 +287,7 @@ private static String[] toParameterValues(FieldInfo fi) { + "Declare some constants or remove the @" + Param.class.getSimpleName() + ".", fi); } - return enumConstants.toArray(new String[enumConstants.size()]); + return enumConstants.toArray(new String[0]); } else { return annotatedValues; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java index a2da23782..54ab0cbdf 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java @@ -77,7 +77,7 @@ public boolean equals(Object o) { if (!fieldIdentifier.equals(that.fieldIdentifier)) return false; if (scope != that.scope) return false; - if (type != null ? !type.equals(that.type) : that.type != null) return false; + if (!Objects.equals(type, that.type)) return false; return true; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 20705a179..7aba87048 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -441,9 +441,10 @@ private boolean isParamValueConforming(FieldInfo fi, String val, ClassInfo type) } if (typeName.equals("byte") || typeName.equals("java.lang.Byte")) { try { - Byte.valueOf(val); + Byte.parseByte(val); return true; } catch (NumberFormatException nfe) { + return false; } } if (typeName.equals("char") || typeName.equals("java.lang.Character")) { @@ -451,37 +452,42 @@ private boolean isParamValueConforming(FieldInfo fi, String val, ClassInfo type) } if (typeName.equals("short") || typeName.equals("java.lang.Short")) { try { - Short.valueOf(val); + Short.parseShort(val); return true; } catch (NumberFormatException nfe) { + return false; } } if (typeName.equals("int") || typeName.equals("java.lang.Integer")) { try { - Integer.valueOf(val); + Integer.parseInt(val); return true; } catch (NumberFormatException nfe) { + return false; } } if (typeName.equals("float") || typeName.equals("java.lang.Float")) { try { - Float.valueOf(val); + Float.parseFloat(val); return true; } catch (NumberFormatException nfe) { + return false; } } if (typeName.equals("long") || typeName.equals("java.lang.Long")) { try { - Long.valueOf(val); + Long.parseLong(val); return true; } catch (NumberFormatException nfe) { + return false; } } if (typeName.equals("double") || typeName.equals("java.lang.Double")) { try { - Double.valueOf(val); + Double.parseDouble(val); return true; } catch (NumberFormatException nfe) { + return false; } } return false; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/IterationParams.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/IterationParams.java index f64218028..7c32ee3a2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/IterationParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/IterationParams.java @@ -29,6 +29,7 @@ import org.openjdk.jmh.util.Utils; import java.io.Serializable; +import java.util.Objects; /** * Iteration parameters. @@ -184,7 +185,7 @@ public boolean equals(Object o) { if (count != that.count) return false; if (batchSize != that.batchSize) return false; - if (timeValue != null ? !timeValue.equals(that.timeValue) : that.timeValue != null) return false; + if (!Objects.equals(timeValue, that.timeValue)) return false; return true; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index 0ef7f7107..3e27d97d9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -747,7 +747,7 @@ private void addInterval(List intervals, long begAddr, long lastAddr, Interval prev = intervals.get(intervals.size() - 1); MethodDesc prevMethod = asms.getMethod(prev.src); MethodDesc method = asms.getMethod(begAddr); - if (prevMethod == null || method == null || !prevMethod.equals(method)) { + if (prevMethod == null || !prevMethod.equals(method)) { intervals.add(new Interval(begAddr, lastAddr)); } else { intervals.set(intervals.size() - 1, new Interval(prev.src, lastAddr)); @@ -759,7 +759,7 @@ private Collection> splitAssembly(File stdOut) { try (FileReader in = new FileReader(stdOut); BufferedReader br = new BufferedReader(in)) { Multimap writerToLines = new HashMultimap<>(); - Long writerId = -1L; + long writerId = -1L; Pattern pWriterThread = Pattern.compile("(.*)(.*)"); String line; @@ -771,7 +771,7 @@ private Collection> splitAssembly(File stdOut) { Matcher m = pWriterThread.matcher(line); if (m.matches()) { try { - writerId = Long.valueOf(m.group(2)); + writerId = Long.parseLong(m.group(2)); } catch (NumberFormatException e) { // something is wrong, try to recover } @@ -814,7 +814,7 @@ private Assembly readAssembly(File stdOut) { if (trim.startsWith("0x")) { // Seems to be line with address. try { - Long addr = parseAddress(elements[0]); + long addr = parseAddress(elements[0]); int idx = lines.size(); addressMap.put(addr, idx); @@ -824,7 +824,7 @@ private Assembly readAssembly(File stdOut) { for (int c = 1; c < elements.length; c++) { if (maybeAddress(elements[c])) { try { - Long target = parseAddress(elements[c]); + long target = parseAddress(elements[c]); intervals.add(new Interval(addr, target)); } catch (NumberFormatException e) { // Nope, not the address. @@ -857,8 +857,8 @@ private Assembly readAssembly(File stdOut) { Matcher matcher = pattern.matcher(line); if (matcher.matches()) { - Long startAddr = parseAddress(matcher.group(3)); - Long endAddr = parseAddress(matcher.group(4)); + long startAddr = parseAddress(matcher.group(3)); + long endAddr = parseAddress(matcher.group(4)); if (line.contains("StubRoutines::")) { stubs.add(MethodDesc.runtimeStub(matcher.group(1)), startAddr, endAddr); @@ -894,12 +894,12 @@ private Assembly readAssembly(File stdOut) { } // Record the starting address for the method - Long addr = parseAddress(map.get("entry")); + long addr = parseAddress(map.get("entry")); javaMethods.add( MethodDesc.javaMethod(map.get("method"), map.get("compiler"), map.get("level"), map.get("compile_id")), addr, - addr + Long.valueOf(map.get("size")) + addr + Long.parseLong(map.get("size")) ); } } @@ -922,11 +922,11 @@ private boolean maybeAddress(String str) { return str.startsWith("0x") || str.endsWith("h"); } - private Long parseAddress(String address) { + private long parseAddress(String address) { if (address.startsWith("0x")) { // AT&T - return Long.valueOf(address.replace("0x", "").replace(":", ""), 16); + return Long.parseLong(address.replace("0x", "").replace(":", ""), 16); } else if (address.endsWith("h")) { // Intel - return Long.valueOf(address.replace("h", ""), 16); + return Long.parseLong(address.replace("h", ""), 16); } else { throw new NumberFormatException("Address format not recognized: " + address); } @@ -1035,8 +1035,8 @@ private boolean isSameMethod(MethodDesc method, int idx) { ASMLine line = lines.get(idx); Long addr = line != null ? line.addr : null; MethodDesc m = addr != null ? getMethod(addr) : null; - return m == null ? true : Objects.equals(m, method); - // if can't find method for the line assume it equals + // If we cannot find a method for the line, assume it "equals" + return (m == null) || Objects.equals(m, method); } private int adjustWindowForward(MethodDesc method, int beginIdx, int window) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java index b27cd66d3..9221cc3cf 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java @@ -161,7 +161,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { continue; } - long timestamp = Long.valueOf(splits[3]); + long timestamp = Long.parseLong(splits[3]); if (dtraceTimestampBase == 0) { // Use first event timestamp as base for time comparison dtraceTimestampBase = timestamp; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java index 2ad3d787d..62ba1d570 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java @@ -48,9 +48,6 @@ public class GCProfiler implements InternalProfiler { private long beforeGCTime; private HotspotAllocationSnapshot beforeAllocated; - public GCProfiler() throws ProfilerException { - } - @Override public String getDescription() { return "GC profiling via standard MBeans"; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index d96262b87..cf2eb1a55 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -126,7 +126,7 @@ static PerfLine parsePerfLine(String line) { double time; try { - time = Double.valueOf(strTime); + time = Double.parseDouble(strTime); } catch (NumberFormatException e) { return null; } @@ -135,7 +135,7 @@ static PerfLine parsePerfLine(String line) { int libIdx = line.lastIndexOf(" ("); if (libIdx == -1) return null; String lib = line.substring(libIdx); - lib = lib.substring(lib.lastIndexOf("/") + 1, lib.length()).replace("(", "").replace(")", ""); + lib = lib.substring(lib.lastIndexOf("/") + 1).replace("(", "").replace(")", ""); line = line.substring(0, libIdx); // Chomp the event name: @@ -159,7 +159,7 @@ static PerfLine parsePerfLine(String line) { // If that fails as well, then address is unresolvable. long addr; try { - addr = Long.valueOf(strAddr, 16); + addr = Long.parseLong(strAddr, 16); } catch (NumberFormatException e) { try { addr = new BigInteger(strAddr, 16).longValue(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index b52c57a15..da4f2d6c2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -218,7 +218,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { // Check timestamp String timeStr = elems[1].trim(); - double time = Double.valueOf(timeStr) / 1000000; + double time = Double.parseDouble(timeStr) / 1000000; if (time < readFrom) continue; @@ -239,7 +239,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { assert evs != null; try { - Long addr = Long.valueOf(addrStr, 16); + Long addr = Long.parseLong(addrStr, 16); evs.add(addr); methods.put(dedup.dedup(MethodDesc.nativeMethod(symbol, lib)), addr); } catch (NumberFormatException e) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/RunResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/RunResult.java index 68bcb8c52..64efcab55 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/RunResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/RunResult.java @@ -73,9 +73,7 @@ public BenchmarkResult getAggregatedResult() { Collection results = new ArrayList<>(); for (BenchmarkResult r : benchmarkResults) { - for (IterationResult ir : r.getIterationResults()) { - results.add(ir); - } + results.addAll(r.getIterationResults()); } BenchmarkResult result = new BenchmarkResult(params, results); for (BenchmarkResult br : benchmarkResults) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java index 63023be06..0f2642a05 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java @@ -35,7 +35,6 @@ import org.openjdk.jmh.util.Multimap; import org.openjdk.jmh.util.TreeMultimap; import org.openjdk.jmh.util.Utils; -import org.openjdk.jmh.util.Version; import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index 4280d4a2d..b79a0b93a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -211,7 +211,7 @@ ExecutorService createExecutor(int maxThreads, String prefix) { */ FJP { @Override - ExecutorService createExecutor(int maxThreads, String prefix) throws Exception { + ExecutorService createExecutor(int maxThreads, String prefix) { return new ForkJoinPool(maxThreads); } }, diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java index 79a45572b..b06658613 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java @@ -67,7 +67,7 @@ public static Collection readBenchmarkList(InputStream strea } } - public static void writeBenchmarkList(OutputStream stream, Collection entries) throws IOException { + public static void writeBenchmarkList(OutputStream stream, Collection entries) { try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8))) { for (BenchmarkListEntry entry : entries) { writer.println(entry.toLine()); @@ -120,10 +120,7 @@ public SortedSet find(OutputFormat out, List include SortedSet result = new TreeSet<>(); try { for (Reader r : getReaders()) { - BufferedReader reader = null; - try { - reader = new BufferedReader(r); - + try (BufferedReader reader = new BufferedReader(r)) { for (String line = reader.readLine(); line != null; line = reader.readLine()) { if (line.startsWith("#")) { continue; @@ -158,14 +155,6 @@ public SortedSet find(OutputFormat out, List include } } } - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - // ignore - } - } } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java index 642d3210e..3fd0ef98a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkListEntry.java @@ -33,6 +33,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Map; +import java.util.Objects; import java.util.concurrent.TimeUnit; public class BenchmarkListEntry implements Comparable { @@ -216,9 +217,9 @@ public boolean equals(Object o) { BenchmarkListEntry record = (BenchmarkListEntry) o; if (mode != record.mode) return false; - if (workloadParams != null ? !workloadParams.equals(record.workloadParams) : record.workloadParams != null) return false; - if (userClassQName != null ? !userClassQName.equals(record.userClassQName) : record.userClassQName != null) return false; - if (method != null ? !method.equals(record.method) : record.method != null) return false; + if (!Objects.equals(workloadParams, record.workloadParams)) return false; + if (!Objects.equals(userClassQName, record.userClassQName)) return false; + if (!Objects.equals(method, record.method)) return false; return true; } @@ -258,7 +259,7 @@ public Optional> getThreadGroupLabels() { @Override public String toString() { - return "{\'" + userClassQName + "." + method + "\', " + mode + ", " + workloadParams + "}"; + return "{'" + userClassQName + "." + method + "', " + mode + ", " + workloadParams + "}"; } public Optional getWarmupTime() { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java index d32fed2e8..3e7db5939 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java @@ -106,9 +106,9 @@ private static boolean isHintCompatibleVM() { try { // get the version digits String[] versionDigits = version.substring(version.indexOf('_') + 1).split("\\."); - if (Integer.valueOf(versionDigits[0]) > 5) { + if (Integer.parseInt(versionDigits[0]) > 5) { return true; - } else if (Integer.valueOf(versionDigits[0]) == 5 && Integer.valueOf(versionDigits[1]) >= 10) { + } else if (Integer.parseInt(versionDigits[0]) == 5 && Integer.parseInt(versionDigits[1]) >= 10) { return true; } } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { @@ -128,9 +128,7 @@ private Set read() { try { for (Reader r : getReaders()) { - BufferedReader reader = null; - try { - reader = new BufferedReader(r); + try (BufferedReader reader = new BufferedReader(r)) { for (String line = reader.readLine(); line != null; line = reader.readLine()) { if (line.startsWith("#")) { continue; @@ -142,14 +140,6 @@ private Set read() { result.add(line); } - } finally { - try { - if (reader != null) { - reader.close(); - } - } catch (IOException e) { - // ignore - } } } } catch (IOException ex) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java index a5c6f11a6..e15b76130 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java @@ -51,7 +51,7 @@ class ForkedMain { * * @param argv Command line arguments */ - public static void main(String[] argv) throws Exception { + public static void main(String[] argv) { if (argv.length != 2) { throw new IllegalArgumentException("Expected two arguments for forked VM"); } else { @@ -66,7 +66,7 @@ public static void main(String[] argv) throws Exception { // 1) host name to back-connect // 2) host port to back-connect String hostName = argv[0]; - int hostPort = Integer.valueOf(argv[1]); + int hostPort = Integer.parseInt(argv[1]); // establish the link to host VM and pull the options BinaryLinkClient link = new BinaryLinkClient(hostName, hostPort); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/OutputFormatAdapter.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/OutputFormatAdapter.java index 8c458159e..884640202 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/OutputFormatAdapter.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/OutputFormatAdapter.java @@ -37,7 +37,7 @@ public OutputFormatAdapter(OutputFormat out) { } @Override - public void write(int b) throws IOException { + public void write(int b) { out.write(b); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/VersionMain.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/VersionMain.java index b06392f11..24a8135c9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/VersionMain.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/VersionMain.java @@ -34,7 +34,7 @@ class VersionMain { /** * @param argv Command line arguments */ - public static void main(String[] argv) throws Exception { + public static void main(String[] argv) { System.err.println(Utils.getCurrentJvmVersion()); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java index 170ca1b94..79a0d90ba 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/WorkloadParams.java @@ -25,10 +25,7 @@ package org.openjdk.jmh.runner; import java.io.Serializable; -import java.util.Collection; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; +import java.util.*; public class WorkloadParams implements Comparable, Serializable { private static final long serialVersionUID = 780563934988950196L; @@ -82,10 +79,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; WorkloadParams that = (WorkloadParams) o; - - if (params != null ? !params.equals(that.params) : that.params != null) return false; - - return true; + return Objects.equals(params, that.params); } @Override @@ -133,9 +127,7 @@ public boolean equals(Object o) { Value value1 = (Value) o; - if (value != null ? !value.equals(value1.value) : value1.value != null) return false; - - return true; + return Objects.equals(value, value1.value); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index 6bbf76c03..44c45ba6c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -236,7 +236,7 @@ public void endRun(Collection runResults) { out.println("experiments, perform baseline and negative tests that provide experimental control, make sure"); out.println("the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts."); out.println("Do not assume the numbers tell you what you want them to tell."); - out.println(""); + out.println(); ResultFormatFactory.getInstance(ResultFormatType.TEXT, out).writeOut(runResults); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java index 6b33067a4..33822c3a3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/OptionsBuilder.java @@ -669,7 +669,7 @@ public Optional> getJvmArgsPrepend() { @Override public ChainedOptionsBuilder detectJvmArgs() { List inputArguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); - return jvmArgs(inputArguments.toArray(new String[inputArguments.size()])); + return jvmArgs(inputArguments.toArray(new String[0])); } // --------------------------------------------------------------------------- diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/TimeValue.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/TimeValue.java index 75d97cc3e..ef81f9a5e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/TimeValue.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/TimeValue.java @@ -120,7 +120,7 @@ public String toString() { if (time == 0) { return "single-shot"; } else { - return String.valueOf(time) + " " + tuToString(timeUnit); + return time + " " + tuToString(timeUnit); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java index 5597d6999..b5ff9c3f3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java @@ -160,7 +160,6 @@ public static void writeLines(File file, Collection lines) throws IOExce for (String line : lines) { pw.println(line); } - pw.close(); } } @@ -212,7 +211,6 @@ public static void copy(String src, String dst) throws IOException { fos.write(buf, 0, read); } - fos.close(); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Interval.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Interval.java index d06cb50fa..f0ba04236 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Interval.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Interval.java @@ -55,13 +55,11 @@ public int hashCode() { @Override public int compareTo(Interval o) { - if (src < o.src) { - return -1; - } else if (src > o.src) { - return 1; - } else { - return (dst < o.dst) ? -1 : ((dst == o.dst) ? 0 : 1); + int c1 = Long.compare(src, o.src); + if (c1 != 0) { + return c1; } + return Long.compare(dst, o.dst); } @Override diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/NullOutputStream.java b/jmh-core/src/main/java/org/openjdk/jmh/util/NullOutputStream.java index ea2f6e7e8..9489c2b5c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/NullOutputStream.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/NullOutputStream.java @@ -24,23 +24,22 @@ */ package org.openjdk.jmh.util; -import java.io.IOException; import java.io.OutputStream; public class NullOutputStream extends OutputStream { @Override - public void write(byte[] b) throws IOException { + public void write(byte[] b) { // drop } @Override - public void write(byte[] b, int off, int len) throws IOException { + public void write(byte[] b, int off, int len) { // drop } @Override - public void write(int b) throws IOException { + public void write(int b) { // drop } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java index 530571566..4f43750c8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Optional.java @@ -25,6 +25,7 @@ package org.openjdk.jmh.util; import java.io.Serializable; +import java.util.Objects; /** * Option class @@ -107,7 +108,7 @@ public boolean equals(Object o) { Optional optional = (Optional) o; - if (val != null ? !val.equals(optional.val) : optional.val != null) return false; + if (!Objects.equals(val, optional.val)) return false; return true; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index dffc2e40b..9ee05f904 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -170,7 +170,7 @@ public static int[] unmarshalIntArray(String src) { int[] arr = new int[ss.length]; int cnt = 0; for (String s : ss) { - arr[cnt] = Integer.valueOf(s.trim()); + arr[cnt] = Integer.parseInt(s.trim()); cnt++; } return arr; @@ -407,7 +407,7 @@ public static long getPid() { if (idx != -1) { String str = name.substring(0, name.indexOf(DELIM)); try { - return Long.valueOf(str); + return Long.parseLong(str); } catch (NumberFormatException nfe) { throw new IllegalStateException("Process PID is not a number: " + str); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java index c6d0a8104..50406ff97 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/lines/TestLineReader.java @@ -56,7 +56,7 @@ private int readLen() { c = line.charAt(cursor); } cursor++; - return Integer.valueOf(sb.toString()); + return Integer.parseInt(sb.toString()); } private String readString() { @@ -155,7 +155,7 @@ public int[] nextIntArray() { int len = readLen(); int[] rs = new int[len]; for (int c = 0; c < len; c++) { - rs[c] = Integer.valueOf(readString()); + rs[c] = Integer.parseInt(readString()); } return rs; } else { diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java index 4ca2c27ef..773f6fa50 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAggregateResult.java @@ -68,12 +68,12 @@ public static void setupClass() { } @Test - public void testScore() throws Exception { + public void testScore() { assertEquals(15.0, result.getPrimaryResult().getScore(), 0.00001); } @Test - public void testScoreUnit() throws Exception { + public void testScoreUnit() { assertEquals((new ThroughputResult(ResultRole.PRIMARY, "test1", 1, 1, TimeUnit.MILLISECONDS)).getScoreUnit(), result.getScoreUnit()); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java index 280c7a9a1..272d50b99 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkList.java @@ -79,7 +79,7 @@ private static void stub(StringBuilder sb, String userClassQName, String generat } @BeforeClass - public static void setUpClass() throws Exception { + public static void setUpClass() { StringBuilder sb = new StringBuilder(); stub(sb, @@ -207,7 +207,7 @@ public static void setUpClass() throws Exception { } @Test - public void testListGetNothing() throws Exception { + public void testListGetNothing() { // make sure we get nothing List excludes = Collections.singletonList(".*"); Set micros = list.getAll(out, excludes); @@ -215,7 +215,7 @@ public void testListGetNothing() throws Exception { } @Test - public void testListGetAll() throws Exception { + public void testListGetAll() { // make sure we get em all List excludes = Collections.emptyList(); Set micros = list.getAll(out, excludes); @@ -223,7 +223,7 @@ public void testListGetAll() throws Exception { } @Test - public void testListFindSingleByPattern() throws Exception { + public void testListFindSingleByPattern() { // check find without excludes List includes = Collections.singletonList(".*Hash.*"); List excludes = Collections.emptyList(); @@ -232,7 +232,7 @@ public void testListFindSingleByPattern() throws Exception { } @Test - public void testListFindSingleBySubstring() throws Exception { + public void testListFindSingleBySubstring() { // check find without excludes List includes = Collections.singletonList("Hash"); List excludes = Collections.emptyList(); @@ -241,7 +241,7 @@ public void testListFindSingleBySubstring() throws Exception { } @Test - public void testListFindSingleByTypical() throws Exception { + public void testListFindSingleByTypical() { // check find without excludes // this would be a typical partial pattern with . abuse case List includes = Collections.singletonList("jbb05.GeneratedSPECjbb2005HashMap"); @@ -251,7 +251,7 @@ public void testListFindSingleByTypical() throws Exception { } @Test - public void testListFindAnchored() throws Exception { + public void testListFindAnchored() { // check find without excludes // matches only: org.openjdk.jmh.runner.TestMicro.dummy List includes = Collections.singletonList("^org\\.openjdk.*\\.dummy$"); @@ -261,7 +261,7 @@ public void testListFindAnchored() throws Exception { } @Test - public void testListFindSingleWithExcludes() throws Exception { + public void testListFindSingleWithExcludes() { // check find with excludes List includes = Collections.singletonList(".*Hash.*"); List excludes = Collections.singletonList(".*Int.*"); @@ -270,7 +270,7 @@ public void testListFindSingleWithExcludes() throws Exception { } @Test - public void testListFindAllWithSubstringExclude() throws Exception { + public void testListFindAllWithSubstringExclude() { // check find with excludes List includes = Collections.singletonList(""); List excludes = Collections.singletonList("oracle"); @@ -279,7 +279,7 @@ public void testListFindAllWithSubstringExclude() throws Exception { } @Test - public void testListFindAllWithEmpty() throws Exception { + public void testListFindAllWithEmpty() { List includes = Collections.emptyList(); List excludes = Collections.emptyList(); Set micros = list.find(out, includes, excludes); @@ -287,7 +287,7 @@ public void testListFindAllWithEmpty() throws Exception { } @Test - public void testListFindIncludeList() throws Exception { + public void testListFindIncludeList() { // check find with excludes List includes = Arrays.asList("^oracle", ".*openjmh.*"); List excludes = Collections.emptyList(); @@ -296,7 +296,7 @@ public void testListFindIncludeList() throws Exception { } @Test - public void testListFindWithIncludesAndExcludes() throws Exception { + public void testListFindWithIncludesAndExcludes() { List includes = Collections.singletonList(".*Concurrent.*"); List excludes = Collections.singletonList(".*Int.*"); Set micros = list.find(out, includes, excludes); @@ -304,7 +304,7 @@ public void testListFindWithIncludesAndExcludes() throws Exception { } @Test - public void testListIsSorted() throws Exception { + public void testListIsSorted() { // micros should be sorted List includes = Collections.singletonList(".*Hash.*"); List excludes = Collections.singletonList(".*Int.*"); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestIncludes.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestIncludes.java index 27531cece..e5ae28f9a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestIncludes.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestIncludes.java @@ -40,7 +40,7 @@ public void testCmdLine_OptBuilder() throws CommandLineOptionException { } @Test - public void testOptBuilder_OptBuilder() throws CommandLineOptionException { + public void testOptBuilder_OptBuilder() { Options opts = new OptionsBuilder() .parent(new OptionsBuilder().build()) .include(".*boo.*") diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java index df28a52b4..c3f8f97dc 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java @@ -70,7 +70,7 @@ public void testIncludes() throws Exception { } @Test - public void testIncludes_Default() throws Exception { + public void testIncludes_Default() { Assert.assertEquals(EMPTY_BUILDER.getIncludes(), EMPTY_CMDLINE.getIncludes()); } @@ -82,7 +82,7 @@ public void testExcludes() throws Exception { } @Test - public void testExcludes_Default() throws Exception { + public void testExcludes_Default() { Assert.assertEquals(EMPTY_BUILDER.getExcludes(), EMPTY_CMDLINE.getExcludes()); } @@ -94,7 +94,7 @@ public void testOutput() throws Exception { } @Test - public void testOutput_Default() throws Exception { + public void testOutput_Default() { Assert.assertEquals(EMPTY_BUILDER.getOutput(), EMPTY_CMDLINE.getOutput()); } @@ -126,7 +126,7 @@ public void testResultFormats_LC() throws Exception { } @Test - public void testResultFormats_Default() throws Exception { + public void testResultFormats_Default() { Assert.assertEquals(EMPTY_BUILDER.getResultFormat(), EMPTY_CMDLINE.getResultFormat()); } @@ -138,7 +138,7 @@ public void testResult() throws Exception { } @Test - public void testResult_Default() throws Exception { + public void testResult_Default() { Assert.assertEquals(EMPTY_BUILDER.getResult(), EMPTY_CMDLINE.getResult()); } @@ -157,7 +157,7 @@ public void testGC_False() throws Exception { } @Test - public void testGC_Default() throws Exception { + public void testGC_Default() { Assert.assertEquals(EMPTY_BUILDER.shouldDoGC(), EMPTY_CMDLINE.shouldDoGC()); } @@ -169,7 +169,7 @@ public void testProfilers() throws Exception { } @Test - public void testProfilers_Default() throws Exception { + public void testProfilers_Default() { Assert.assertEquals(EMPTY_BUILDER.getProfilers(), EMPTY_CMDLINE.getProfilers()); } @@ -201,7 +201,7 @@ public void testVerbose_UC() throws Exception { } @Test - public void testVerbose_Default() throws Exception { + public void testVerbose_Default() { Assert.assertEquals(EMPTY_BUILDER.verbosity(), EMPTY_CMDLINE.verbosity()); } @@ -220,7 +220,7 @@ public void testSFOE_False() throws Exception { } @Test - public void testSFOE_Default() throws Exception { + public void testSFOE_Default() { Assert.assertEquals(EMPTY_BUILDER.shouldFailOnError(), EMPTY_CMDLINE.shouldFailOnError()); } @@ -239,7 +239,7 @@ public void testThreads_Max() throws Exception { } @Test - public void testThreads_Zero() throws Exception { + public void testThreads_Zero() { try { new CommandLineOptions("-t", "0"); Assert.fail(); @@ -249,7 +249,7 @@ public void testThreads_Zero() throws Exception { } @Test - public void testThreads_Zero_OptionsBuilder() throws Exception { + public void testThreads_Zero_OptionsBuilder() { try { new OptionsBuilder().threads(0); Assert.fail(); @@ -259,7 +259,7 @@ public void testThreads_Zero_OptionsBuilder() throws Exception { } @Test - public void testThreads_MinusOne() throws Exception { + public void testThreads_MinusOne() { try { new CommandLineOptions("-t", "-1"); Assert.fail(); @@ -269,7 +269,7 @@ public void testThreads_MinusOne() throws Exception { } @Test - public void testThreads_Minus42() throws Exception { + public void testThreads_Minus42() { try { new CommandLineOptions("-t", "-42"); Assert.fail(); @@ -279,7 +279,7 @@ public void testThreads_Minus42() throws Exception { } @Test - public void testThreads_Minus42_OptionsBuilder() throws Exception { + public void testThreads_Minus42_OptionsBuilder() { try { new OptionsBuilder().threads(-42); } catch (IllegalArgumentException e) { @@ -288,7 +288,7 @@ public void testThreads_Minus42_OptionsBuilder() throws Exception { } @Test - public void testThreads_Default() throws Exception { + public void testThreads_Default() { Assert.assertEquals(EMPTY_BUILDER.getThreads(), EMPTY_CMDLINE.getThreads()); } @@ -300,7 +300,7 @@ public void testThreadGroups() throws Exception { } @Test - public void testThreadGroups_Default() throws Exception { + public void testThreadGroups_Default() { Assert.assertEquals(EMPTY_BUILDER.getThreadGroups(), EMPTY_CMDLINE.getThreadGroups()); } @@ -312,7 +312,7 @@ public void testThreadGroups_WithZero() throws Exception { } @Test - public void testThreadGroups_AllZero() throws Exception { + public void testThreadGroups_AllZero() { try { new CommandLineOptions("-tg", "0,0,0"); Assert.fail(); @@ -322,7 +322,7 @@ public void testThreadGroups_AllZero() throws Exception { } @Test - public void testThreadGroups_AllZero_OptionsBuilder() throws Exception { + public void testThreadGroups_AllZero_OptionsBuilder() { try { new OptionsBuilder().threadGroups(0, 0, 0); Assert.fail(); @@ -332,7 +332,7 @@ public void testThreadGroups_AllZero_OptionsBuilder() throws Exception { } @Test - public void testThreadGroups_WithNegative() throws Exception { + public void testThreadGroups_WithNegative() { try { new CommandLineOptions("-tg", "-1,-2"); Assert.fail(); @@ -342,7 +342,7 @@ public void testThreadGroups_WithNegative() throws Exception { } @Test - public void testThreadGroups_WithNegative_OptionsBuilder() throws Exception { + public void testThreadGroups_WithNegative_OptionsBuilder() { try { new OptionsBuilder().threadGroups(-1,-2); Assert.fail(); @@ -366,7 +366,7 @@ public void testSynchIterations_False() throws Exception { } @Test - public void testSynchIterations_Default() throws Exception { + public void testSynchIterations_Default() { Assert.assertEquals(EMPTY_BUILDER.shouldSyncIterations(), EMPTY_CMDLINE.shouldSyncIterations()); } @@ -378,7 +378,7 @@ public void testWarmupIterations() throws Exception { } @Test - public void testWarmupIterations_Default() throws Exception { + public void testWarmupIterations_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupIterations(), EMPTY_CMDLINE.getWarmupIterations()); } @@ -390,7 +390,7 @@ public void testWarmupIterations_Zero() throws Exception { } @Test - public void testWarmupIterations_MinusOne() throws Exception { + public void testWarmupIterations_MinusOne() { try { new CommandLineOptions("-wi", "-1"); Assert.fail(); @@ -400,7 +400,7 @@ public void testWarmupIterations_MinusOne() throws Exception { } @Test - public void testWarmupIterations_MinusOne_OptionsBuilder() throws Exception { + public void testWarmupIterations_MinusOne_OptionsBuilder() { try { new OptionsBuilder().warmupIterations(-1); Assert.fail(); @@ -417,7 +417,7 @@ public void testWarmupTime() throws Exception { } @Test - public void testWarmupTime_Default() throws Exception { + public void testWarmupTime_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupTime(), EMPTY_CMDLINE.getWarmupTime()); } @@ -429,12 +429,12 @@ public void testRuntimeIterations() throws Exception { } @Test - public void testRuntimeIterations_Default() throws Exception { + public void testRuntimeIterations_Default() { Assert.assertEquals(EMPTY_BUILDER.getMeasurementIterations(), EMPTY_CMDLINE.getMeasurementIterations()); } @Test - public void testRuntimeIterations_Zero() throws Exception { + public void testRuntimeIterations_Zero() { try { new CommandLineOptions("-i", "0"); Assert.fail(); @@ -444,7 +444,7 @@ public void testRuntimeIterations_Zero() throws Exception { } @Test - public void testRuntimeIterations_Zero_OptionsBuilder() throws Exception { + public void testRuntimeIterations_Zero_OptionsBuilder() { try { new OptionsBuilder().measurementIterations(0); Assert.fail(); @@ -461,7 +461,7 @@ public void testRuntime() throws Exception { } @Test - public void testRuntime_Default() throws Exception { + public void testRuntime_Default() { Assert.assertEquals(EMPTY_BUILDER.getMeasurementTime(), EMPTY_CMDLINE.getMeasurementTime()); } @@ -473,7 +473,7 @@ public void testWarmupMicros() throws Exception { } @Test - public void testWarmupMicros_Default() throws Exception { + public void testWarmupMicros_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupIncludes(), EMPTY_CMDLINE.getWarmupIncludes()); } @@ -486,7 +486,7 @@ public void testBenchModes() throws Exception { } @Test - public void testBenchModes_Default() throws Exception { + public void testBenchModes_Default() { Assert.assertEquals(EMPTY_BUILDER.getBenchModes(), EMPTY_CMDLINE.getBenchModes()); } @@ -498,7 +498,7 @@ public void testTimeunit() throws Exception { } @Test - public void testTimeunit_Default() throws Exception { + public void testTimeunit_Default() { Assert.assertEquals(EMPTY_BUILDER.getTimeUnit(), EMPTY_CMDLINE.getTimeUnit()); } @@ -510,7 +510,7 @@ public void testOPI() throws Exception { } @Test - public void testOPI_Zero() throws Exception { + public void testOPI_Zero() { try { new CommandLineOptions("-opi", "0"); Assert.fail(); @@ -520,7 +520,7 @@ public void testOPI_Zero() throws Exception { } @Test - public void testOPI_Zero_OptionsBuilder() throws Exception { + public void testOPI_Zero_OptionsBuilder() { try { new OptionsBuilder().operationsPerInvocation(0); Assert.fail(); @@ -530,7 +530,7 @@ public void testOPI_Zero_OptionsBuilder() throws Exception { } @Test - public void testOPI_Default() throws Exception { + public void testOPI_Default() { Assert.assertEquals(EMPTY_BUILDER.getOperationsPerInvocation(), EMPTY_CMDLINE.getOperationsPerInvocation()); } @@ -549,12 +549,12 @@ public void testFork_1() throws Exception { } @Test - public void testFork_Default() throws Exception { + public void testFork_Default() { Assert.assertEquals(EMPTY_BUILDER.getForkCount(), EMPTY_CMDLINE.getForkCount()); } @Test - public void testFork_MinusOne() throws Exception { + public void testFork_MinusOne() { try { new CommandLineOptions("-f", "-1"); Assert.fail(); @@ -564,7 +564,7 @@ public void testFork_MinusOne() throws Exception { } @Test - public void testFork__MinusOne_OptionsBuilder() throws Exception { + public void testFork__MinusOne_OptionsBuilder() { try { new OptionsBuilder().forks(-1); Assert.fail(); @@ -588,12 +588,12 @@ public void testWarmupFork_1() throws Exception { } @Test - public void testWarmupFork_Default() throws Exception { + public void testWarmupFork_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupForkCount(), EMPTY_CMDLINE.getWarmupForkCount()); } @Test - public void testWarmupFork_MinusOne() throws Exception { + public void testWarmupFork_MinusOne() { try { new CommandLineOptions("-wf", "-1"); Assert.fail(); @@ -603,7 +603,7 @@ public void testWarmupFork_MinusOne() throws Exception { } @Test - public void testWarmupFork_MinusOne_OptionsBuilder() throws Exception { + public void testWarmupFork_MinusOne_OptionsBuilder() { try { new OptionsBuilder().warmupForks(-1); Assert.fail(); @@ -620,7 +620,7 @@ public void testJvm() throws Exception { } @Test - public void testJvm_Default() throws Exception { + public void testJvm_Default() { Assert.assertEquals(EMPTY_BUILDER.getJvm(), EMPTY_CMDLINE.getJvm()); } @@ -632,7 +632,7 @@ public void testJvmArgs() throws Exception { } @Test - public void testJvmArgs_Default() throws Exception { + public void testJvmArgs_Default() { Assert.assertEquals(EMPTY_BUILDER.getJvmArgs(), EMPTY_CMDLINE.getJvmArgs()); } @@ -644,7 +644,7 @@ public void testJvmArgsAppend() throws Exception { } @Test - public void testJvmArgsAppend_Default() throws Exception { + public void testJvmArgsAppend_Default() { Assert.assertEquals(EMPTY_BUILDER.getJvmArgsAppend(), EMPTY_CMDLINE.getJvmArgsAppend()); } @@ -656,7 +656,7 @@ public void testJvmArgsPrepend() throws Exception { } @Test - public void testJvmArgsPrepend_Default() throws Exception { + public void testJvmArgsPrepend_Default() { Assert.assertEquals(EMPTY_BUILDER.getJvmArgsPrepend(), EMPTY_CMDLINE.getJvmArgsPrepend()); } @@ -668,12 +668,12 @@ public void testBatchSize() throws Exception { } @Test - public void testBatchSize_Default() throws Exception { + public void testBatchSize_Default() { Assert.assertEquals(EMPTY_BUILDER.getMeasurementBatchSize(), EMPTY_CMDLINE.getMeasurementBatchSize()); } @Test - public void testBatchSize_Zero() throws Exception { + public void testBatchSize_Zero() { try { new CommandLineOptions("-bs", "0"); Assert.fail(); @@ -683,7 +683,7 @@ public void testBatchSize_Zero() throws Exception { } @Test - public void testBatchSize_Zero_OptionsBuilder() throws Exception { + public void testBatchSize_Zero_OptionsBuilder() { try { new OptionsBuilder().measurementBatchSize(0); Assert.fail(); @@ -700,12 +700,12 @@ public void testWarmupBatchSize() throws Exception { } @Test - public void testWarmupBatchSize_Default() throws Exception { + public void testWarmupBatchSize_Default() { Assert.assertEquals(EMPTY_BUILDER.getWarmupBatchSize(), EMPTY_CMDLINE.getWarmupBatchSize()); } @Test - public void testWarmupBatchSize_Zero() throws Exception { + public void testWarmupBatchSize_Zero() { try { new CommandLineOptions("-wbs", "0"); Assert.fail(); @@ -715,7 +715,7 @@ public void testWarmupBatchSize_Zero() throws Exception { } @Test - public void testWarmupBatchSize_Zero_OptionsBuilder() throws Exception { + public void testWarmupBatchSize_Zero_OptionsBuilder() { try { new OptionsBuilder().warmupBatchSize(0); Assert.fail(); @@ -769,7 +769,7 @@ public void testTimeout() throws Exception { } @Test - public void testTimeout_Default() throws Exception { + public void testTimeout_Default() { Assert.assertEquals(EMPTY_BUILDER.getTimeout(), EMPTY_CMDLINE.getTimeout()); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestParentOptions.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestParentOptions.java index c2ed6ad1a..b4a12a197 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestParentOptions.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestParentOptions.java @@ -38,56 +38,56 @@ public class TestParentOptions { @Test - public void testIncludes_Empty() throws Exception { + public void testIncludes_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getIncludes().isEmpty()); } @Test - public void testIncludes_Parent() throws Exception { + public void testIncludes_Parent() { Options parent = new OptionsBuilder().include(".*").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Collections.singletonList(".*"), builder.getIncludes()); } @Test - public void testIncludes_Merge() throws Exception { + public void testIncludes_Merge() { Options parent = new OptionsBuilder().include(".*").build(); Options builder = new OptionsBuilder().parent(parent).include(".*test.*").build(); Assert.assertEquals(Arrays.asList(".*test.*", ".*"), builder.getIncludes()); } @Test - public void testExcludes_Empty() throws Exception { + public void testExcludes_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getExcludes().isEmpty()); } @Test - public void testExcludes_Parent() throws Exception { + public void testExcludes_Parent() { Options parent = new OptionsBuilder().include(".*").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Collections.singletonList(".*"), builder.getIncludes()); } @Test - public void testExcludes_Merge() throws Exception { + public void testExcludes_Merge() { Options parent = new OptionsBuilder().exclude(".*").build(); Options builder = new OptionsBuilder().parent(parent).exclude(".*test.*").build(); Assert.assertEquals(Arrays.asList(".*test.*", ".*"), builder.getExcludes()); } @Test - public void testProfiler_Empty() throws Exception { + public void testProfiler_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getProfilers().isEmpty()); } @Test - public void testProfiler_Parent() throws Exception { + public void testProfiler_Parent() { Options parent = new OptionsBuilder().addProfiler("cl").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getProfilers().size() == 1); @@ -95,7 +95,7 @@ public void testProfiler_Parent() throws Exception { } @Test - public void testProfiler_Merge() throws Exception { + public void testProfiler_Merge() { Options parent = new OptionsBuilder().addProfiler("cl").build(); Options builder = new OptionsBuilder().parent(parent).addProfiler("comp").build(); Assert.assertTrue(builder.getProfilers().size() == 2); @@ -104,483 +104,483 @@ public void testProfiler_Merge() throws Exception { } @Test - public void testBenchModes_Empty() throws Exception { + public void testBenchModes_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getBenchModes().isEmpty()); } @Test - public void testBenchModes_Parent() throws Exception { + public void testBenchModes_Parent() { Options parent = new OptionsBuilder().mode(Mode.AverageTime).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(EnumSet.of(Mode.AverageTime), builder.getBenchModes()); } @Test - public void testBenchModes_Merge() throws Exception { + public void testBenchModes_Merge() { Options parent = new OptionsBuilder().mode(Mode.AverageTime).build(); Options builder = new OptionsBuilder().parent(parent).mode(Mode.SingleShotTime).build(); Assert.assertEquals(EnumSet.of(Mode.SingleShotTime), builder.getBenchModes()); } @Test - public void testForks_Empty() throws Exception { + public void testForks_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getForkCount().hasValue()); } @Test - public void testForks_Parent() throws Exception { + public void testForks_Parent() { Options parent = new OptionsBuilder().forks(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getForkCount().get()); } @Test - public void testForks_Merge() throws Exception { + public void testForks_Merge() { Options parent = new OptionsBuilder().forks(42).build(); Options builder = new OptionsBuilder().parent(parent).forks(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getForkCount().get()); } @Test - public void testGC_Empty() throws Exception { + public void testGC_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.shouldDoGC().hasValue()); } @Test - public void testGC_Parent() throws Exception { + public void testGC_Parent() { Options parent = new OptionsBuilder().shouldDoGC(true).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(true, builder.shouldDoGC().get()); } @Test - public void testGC_Merge() throws Exception { + public void testGC_Merge() { Options parent = new OptionsBuilder().shouldDoGC(true).build(); Options builder = new OptionsBuilder().parent(parent).shouldDoGC(false).build(); Assert.assertEquals(false, builder.shouldDoGC().get()); } @Test - public void testJVM_Empty() throws Exception { + public void testJVM_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getJvm().hasValue()); } @Test - public void testJVM_Parent() throws Exception { + public void testJVM_Parent() { Options parent = new OptionsBuilder().jvm("path").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals("path", builder.getJvm().get()); } @Test - public void testJVM_Merge() throws Exception { + public void testJVM_Merge() { Options parent = new OptionsBuilder().jvm("path").build(); Options builder = new OptionsBuilder().parent(parent).jvm("path2").build(); Assert.assertEquals("path2", builder.getJvm().get()); } @Test - public void testJVMArgs_Empty() throws Exception { + public void testJVMArgs_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getJvmArgs().hasValue()); } @Test - public void testJVMArgs_Parent() throws Exception { + public void testJVMArgs_Parent() { Options parent = new OptionsBuilder().jvmArgs("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Arrays.asList("opt1", "opt2"), builder.getJvmArgs().get()); } @Test - public void testJVMArgs_Merge() throws Exception { + public void testJVMArgs_Merge() { Options parent = new OptionsBuilder().jvmArgs("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).jvmArgs("opt3", "opt4").build(); Assert.assertEquals(Arrays.asList("opt3", "opt4"), builder.getJvmArgs().get()); } @Test - public void testJVMArgsAppend_Empty() throws Exception { + public void testJVMArgsAppend_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getJvmArgsAppend().hasValue()); } @Test - public void testJVMArgsAppend_Parent() throws Exception { + public void testJVMArgsAppend_Parent() { Options parent = new OptionsBuilder().jvmArgsAppend("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Arrays.asList("opt1", "opt2"), builder.getJvmArgsAppend().get()); } @Test - public void testJVMArgsAppend_Merge() throws Exception { + public void testJVMArgsAppend_Merge() { Options parent = new OptionsBuilder().jvmArgsAppend("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).jvmArgsAppend("opt3", "opt4").build(); Assert.assertEquals(Arrays.asList("opt3", "opt4"), builder.getJvmArgsAppend().get()); } @Test - public void testJVMArgsPrepend_Empty() throws Exception { + public void testJVMArgsPrepend_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getJvmArgsPrepend().hasValue()); } @Test - public void testJVMArgsPrepend_Parent() throws Exception { + public void testJVMArgsPrepend_Parent() { Options parent = new OptionsBuilder().jvmArgsPrepend("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Arrays.asList("opt1", "opt2"), builder.getJvmArgsPrepend().get()); } @Test - public void testJVMArgsPrepend_Merge() throws Exception { + public void testJVMArgsPrepend_Merge() { Options parent = new OptionsBuilder().jvmArgsPrepend("opt1", "opt2").build(); Options builder = new OptionsBuilder().parent(parent).jvmArgsPrepend("opt3", "opt4").build(); Assert.assertEquals(Arrays.asList("opt3", "opt4"), builder.getJvmArgsPrepend().get()); } @Test - public void testOutput_Empty() throws Exception { + public void testOutput_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getOutput().hasValue()); } @Test - public void testOutput_Parent() throws Exception { + public void testOutput_Parent() { Options parent = new OptionsBuilder().output("out1").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals("out1", builder.getOutput().get()); } @Test - public void testOutput_Merged() throws Exception { + public void testOutput_Merged() { Options parent = new OptionsBuilder().output("out1").build(); Options builder = new OptionsBuilder().parent(parent).output("out2").build(); Assert.assertEquals("out2", builder.getOutput().get()); } @Test - public void testResult_Empty() throws Exception { + public void testResult_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getResult().hasValue()); } @Test - public void testResult_Parent() throws Exception { + public void testResult_Parent() { Options parent = new OptionsBuilder().result("out1").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals("out1", builder.getResult().get()); } @Test - public void testResult_Merged() throws Exception { + public void testResult_Merged() { Options parent = new OptionsBuilder().result("out1").build(); Options builder = new OptionsBuilder().parent(parent).result("out2").build(); Assert.assertEquals("out2", builder.getResult().get()); } @Test - public void testResultFormat_Empty() throws Exception { + public void testResultFormat_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getResultFormat().hasValue()); } @Test - public void testResultFormat_Parent() throws Exception { + public void testResultFormat_Parent() { Options parent = new OptionsBuilder().resultFormat(ResultFormatType.JSON).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(ResultFormatType.JSON, builder.getResultFormat().get()); } @Test - public void testResultFormat_Merged() throws Exception { + public void testResultFormat_Merged() { Options parent = new OptionsBuilder().resultFormat(ResultFormatType.JSON).build(); Options builder = new OptionsBuilder().parent(parent).resultFormat(ResultFormatType.SCSV).build(); Assert.assertEquals(ResultFormatType.SCSV, builder.getResultFormat().get()); } @Test - public void testRuntime_Empty() throws Exception { + public void testRuntime_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getMeasurementTime().hasValue()); } @Test - public void testRuntime_Parent() throws Exception { + public void testRuntime_Parent() { Options parent = new OptionsBuilder().measurementTime(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(TimeValue.hours(42), builder.getMeasurementTime().get()); } @Test - public void testRuntime_Merged() throws Exception { + public void testRuntime_Merged() { Options parent = new OptionsBuilder().measurementTime(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).measurementTime(TimeValue.days(42)).build(); Assert.assertEquals(TimeValue.days(42), builder.getMeasurementTime().get()); } @Test - public void testMeasureIters_Empty() throws Exception { + public void testMeasureIters_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getMeasurementIterations().hasValue()); } @Test - public void testMeasureIters_Parent() throws Exception { + public void testMeasureIters_Parent() { Options parent = new OptionsBuilder().measurementIterations(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getMeasurementIterations().get()); } @Test - public void testMeasureIters_Merged() throws Exception { + public void testMeasureIters_Merged() { Options parent = new OptionsBuilder().measurementIterations(42).build(); Options builder = new OptionsBuilder().parent(parent).measurementIterations(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getMeasurementIterations().get()); } @Test - public void testSFOE_Empty() throws Exception { + public void testSFOE_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.shouldFailOnError().hasValue()); } @Test - public void testSFOE_Parent() throws Exception { + public void testSFOE_Parent() { Options parent = new OptionsBuilder().shouldFailOnError(true).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(true, builder.shouldFailOnError().get()); } @Test - public void testSFOE_Merged() throws Exception { + public void testSFOE_Merged() { Options parent = new OptionsBuilder().shouldFailOnError(true).build(); Options builder = new OptionsBuilder().parent(parent).shouldFailOnError(false).build(); Assert.assertEquals(false, builder.shouldFailOnError().get()); } @Test - public void testSyncIters_Empty() throws Exception { + public void testSyncIters_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.shouldSyncIterations().hasValue()); } @Test - public void testSyncIters_Parent() throws Exception { + public void testSyncIters_Parent() { Options parent = new OptionsBuilder().syncIterations(true).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(true, builder.shouldSyncIterations().get()); } @Test - public void testSyncIters_Merged() throws Exception { + public void testSyncIters_Merged() { Options parent = new OptionsBuilder().syncIterations(true).build(); Options builder = new OptionsBuilder().parent(parent).syncIterations(false).build(); Assert.assertEquals(false, builder.shouldSyncIterations().get()); } @Test - public void testThreadGroups_Empty() throws Exception { + public void testThreadGroups_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getThreadGroups().hasValue()); } @Test - public void testThreadGroups_Parent() throws Exception { + public void testThreadGroups_Parent() { Options parent = new OptionsBuilder().threadGroups(1, 2).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertArrayEquals(new int[]{1, 2}, builder.getThreadGroups().get()); } @Test - public void testThreadGroups_Merged() throws Exception { + public void testThreadGroups_Merged() { Options parent = new OptionsBuilder().threadGroups(1, 2).build(); Options builder = new OptionsBuilder().parent(parent).threadGroups(3, 4).build(); Assert.assertArrayEquals(new int[]{3, 4}, builder.getThreadGroups().get()); } @Test - public void testThreads_Empty() throws Exception { + public void testThreads_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getThreads().hasValue()); } @Test - public void testThreads_Parent() throws Exception { + public void testThreads_Parent() { Options parent = new OptionsBuilder().threads(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getThreads().get()); } @Test - public void testThreads_Merged() throws Exception { + public void testThreads_Merged() { Options parent = new OptionsBuilder().threads(42).build(); Options builder = new OptionsBuilder().parent(parent).threads(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getThreads().get()); } @Test - public void testTimeUnit_Empty() throws Exception { + public void testTimeUnit_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getTimeUnit().hasValue()); } @Test - public void testTimeUnit_Parent() throws Exception { + public void testTimeUnit_Parent() { Options parent = new OptionsBuilder().timeUnit(TimeUnit.DAYS).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(TimeUnit.DAYS, builder.getTimeUnit().get()); } @Test - public void testTimeUnit_Merged() throws Exception { + public void testTimeUnit_Merged() { Options parent = new OptionsBuilder().timeUnit(TimeUnit.DAYS).build(); Options builder = new OptionsBuilder().parent(parent).timeUnit(TimeUnit.HOURS).build(); Assert.assertEquals(TimeUnit.HOURS, builder.getTimeUnit().get()); } @Test - public void testOPI_Empty() throws Exception { + public void testOPI_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getOperationsPerInvocation().hasValue()); } @Test - public void testOPI_Parent() throws Exception { + public void testOPI_Parent() { Options parent = new OptionsBuilder().operationsPerInvocation(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getOperationsPerInvocation().get()); } @Test - public void testOPI_Merged() throws Exception { + public void testOPI_Merged() { Options parent = new OptionsBuilder().operationsPerInvocation(42).build(); Options builder = new OptionsBuilder().parent(parent).operationsPerInvocation(43).build(); Assert.assertEquals(Integer.valueOf(43), builder.getOperationsPerInvocation().get()); } @Test - public void testVerbose_Empty() throws Exception { + public void testVerbose_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.verbosity().hasValue()); } @Test - public void testVerbose_Parent() throws Exception { + public void testVerbose_Parent() { Options parent = new OptionsBuilder().verbosity(VerboseMode.EXTRA).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(VerboseMode.EXTRA, builder.verbosity().get()); } @Test - public void testVerbose_Merged() throws Exception { + public void testVerbose_Merged() { Options parent = new OptionsBuilder().verbosity(VerboseMode.EXTRA).build(); Options builder = new OptionsBuilder().parent(parent).verbosity(VerboseMode.SILENT).build(); Assert.assertEquals(VerboseMode.SILENT, builder.verbosity().get()); } @Test - public void testWarmupForks_Empty() throws Exception { + public void testWarmupForks_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getWarmupForkCount().hasValue()); } @Test - public void testWarmupForks_Parent() throws Exception { + public void testWarmupForks_Parent() { Options parent = new OptionsBuilder().warmupForks(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getWarmupForkCount().get()); } @Test - public void testWarmupForks_Merge() throws Exception { + public void testWarmupForks_Merge() { Options parent = new OptionsBuilder().warmupForks(42).build(); Options builder = new OptionsBuilder().parent(parent).warmupForks(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getWarmupForkCount().get()); } @Test - public void testWarmupIters_Empty() throws Exception { + public void testWarmupIters_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getWarmupIterations().hasValue()); } @Test - public void testWarmupIters_Parent() throws Exception { + public void testWarmupIters_Parent() { Options parent = new OptionsBuilder().warmupIterations(42).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Integer.valueOf(42), builder.getWarmupIterations().get()); } @Test - public void testWarmupIters_Merged() throws Exception { + public void testWarmupIters_Merged() { Options parent = new OptionsBuilder().warmupIterations(42).build(); Options builder = new OptionsBuilder().parent(parent).warmupIterations(84).build(); Assert.assertEquals(Integer.valueOf(84), builder.getWarmupIterations().get()); } @Test - public void testWarmupTime_Empty() throws Exception { + public void testWarmupTime_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getWarmupTime().hasValue()); } @Test - public void testWarmupTime_Parent() throws Exception { + public void testWarmupTime_Parent() { Options parent = new OptionsBuilder().warmupTime(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(TimeValue.hours(42), builder.getWarmupTime().get()); } @Test - public void testWarmupTime_Merged() throws Exception { + public void testWarmupTime_Merged() { Options parent = new OptionsBuilder().warmupTime(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).warmupTime(TimeValue.days(42)).build(); Assert.assertEquals(TimeValue.days(42), builder.getWarmupTime().get()); } @Test - public void testWarmupMicros_Empty() throws Exception { + public void testWarmupMicros_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertTrue(builder.getWarmupIncludes().isEmpty()); } @Test - public void testWarmupMicros_Parent() throws Exception { + public void testWarmupMicros_Parent() { Options parent = new OptionsBuilder().includeWarmup(".*").build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(Collections.singletonList(".*"), builder.getWarmupIncludes()); } @Test - public void testWarmupMicros_Merged() throws Exception { + public void testWarmupMicros_Merged() { Options parent = new OptionsBuilder().includeWarmup(".*").build(); Options builder = new OptionsBuilder().parent(parent).includeWarmup(".*test.*").build(); Assert.assertEquals(Arrays.asList(".*test.*", ".*"), builder.getWarmupIncludes()); @@ -616,21 +616,21 @@ public void testParameters_Merged() { } @Test - public void testTimeout_Empty() throws Exception { + public void testTimeout_Empty() { Options parent = new OptionsBuilder().build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertFalse(builder.getTimeout().hasValue()); } @Test - public void testTimeout_Parent() throws Exception { + public void testTimeout_Parent() { Options parent = new OptionsBuilder().timeout(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).build(); Assert.assertEquals(TimeValue.hours(42), builder.getTimeout().get()); } @Test - public void testTimeout_Merged() throws Exception { + public void testTimeout_Merged() { Options parent = new OptionsBuilder().timeout(TimeValue.hours(42)).build(); Options builder = new OptionsBuilder().parent(parent).timeout(TimeValue.days(42)).build(); Assert.assertEquals(TimeValue.days(42), builder.getTimeout().get()); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java index 2242b4e7a..6add7c7d4 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java @@ -49,7 +49,7 @@ public class TestListStatistics { private static final ListStatistics instance = new ListStatistics(); @BeforeClass - public static void setUpClass() throws Exception { + public static void setUpClass() { for (double value : VALUES) { instance.addValue(value); } @@ -76,7 +76,7 @@ public strictfp void testAdd_double() { */ @Test public strictfp void testGetN() { - assertEquals((long) VALUES.length, instance.getN()); + assertEquals(VALUES.length, instance.getN()); } /** diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java index 161a5764e..a9b600796 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java @@ -48,7 +48,7 @@ public class TestMultisetStatistics { private static final MultisetStatistics instance = new MultisetStatistics(); @BeforeClass - public static void setUpClass() throws Exception { + public static void setUpClass() { for (double value : VALUES) { instance.addValue(value, 1); } @@ -75,7 +75,7 @@ public strictfp void testAdd_double() { */ @Test public strictfp void testGetN() { - assertEquals((long) VALUES.length, instance.getN()); + assertEquals(VALUES.length, instance.getN()); } /** @@ -405,6 +405,7 @@ public strictfp void testRawDataIterator_no_duplicates() { for (double value : VALUES) { if (Double.compare(value, key) == 0) { keyIsPresent = true; + break; } } Assert.assertTrue("Value from iterator is not present in source collection", keyIsPresent); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java index a96bf985a..145dba5be 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java @@ -44,7 +44,7 @@ public class TestSingletonStatistics { private static final SingletonStatistics singStats = new SingletonStatistics(VALUE); @BeforeClass - public static void setUpClass() throws Exception { + public static void setUpClass() { listStats.addValue(VALUE); } diff --git a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorSource.java b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorSource.java index 1d4ad999e..b301015b6 100644 --- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorSource.java +++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorSource.java @@ -83,9 +83,7 @@ public int compare(TypeElement o1, TypeElement o2) { try { TypeElement walk = (TypeElement) e; do { - for (TypeElement nested : ElementFilter.typesIn(walk.getEnclosedElements())) { - newClasses.add(nested); - } + newClasses.addAll(ElementFilter.typesIn(walk.getEnclosedElements())); } while ((walk = (TypeElement) processingEnv.getTypeUtils().asElement(walk.getSuperclass())) != null); } catch (Exception t) { diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/AnnotationInvocationHandler.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/AnnotationInvocationHandler.java index 4fc262784..db4ccb6e4 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/AnnotationInvocationHandler.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/AnnotationInvocationHandler.java @@ -102,8 +102,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl } else if (componentType.isAssignableFrom(String.class)) { // Dealing with String[]: - return vs.toArray(new String[vs.size()]); - + return vs.toArray(new String[0]); } else { // "Dealing" with primitive array: // We do not have any primitive-array-valued annotations yet, so we don't bother to implement this. diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java index 94ce21cfb..f2401f095 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java @@ -62,7 +62,7 @@ public interface Counter { int inc(); } - public class Counter1 implements Counter { + public static class Counter1 implements Counter { private int x; @Override @@ -71,7 +71,7 @@ public int inc() { } } - public class Counter2 implements Counter { + public static class Counter2 implements Counter { private int x; @Override diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java index e4da01ce4..90e585a78 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java @@ -72,7 +72,7 @@ public interface Counter { int inc(); } - public class Counter1 implements Counter { + public static class Counter1 implements Counter { private int x; @Override @@ -81,7 +81,7 @@ public int inc() { } } - public class Counter2 implements Counter { + public static class Counter2 implements Counter { private int x; @Override From db1bc365abaf9a00c1bb0882fabff646d306d0be Mon Sep 17 00:00:00 2001 From: Dmitry Chuyko Date: Mon, 20 Jan 2020 15:47:57 +0100 Subject: [PATCH 163/342] 7902576: Lazy query for current JVM args in Runner --- .../main/java/org/openjdk/jmh/runner/Runner.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index b58924329..57b92c4f1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -484,8 +484,15 @@ private BenchmarkParams newBenchmarkParams(BenchmarkListEntry benchmark, ActionM jvmArgs.addAll(options.getJvmArgsPrepend().orElse( benchmark.getJvmArgsPrepend().orElse(Collections.emptyList()))); - jvmArgs.addAll(options.getJvmArgs().orElse( - benchmark.getJvmArgs().orElse(ManagementFactory.getRuntimeMXBean().getInputArguments()))); + // We want to be extra lazy when accessing ManagementFactory, because security manager + // may prevent us doing so. When JMH upgrades to Java 8, replaces this with proper Optional + // and lazy Supplier. + Optional> jvmArgsMid = options.getJvmArgs().orAnother(benchmark.getJvmArgs()); + if (jvmArgsMid.hasValue()) { + jvmArgs.addAll(jvmArgsMid.get()); + } else { + jvmArgs.addAll(ManagementFactory.getRuntimeMXBean().getInputArguments()); + } jvmArgs.addAll(options.getJvmArgsAppend().orElse( benchmark.getJvmArgsAppend().orElse(Collections.emptyList()))); From 28d15e9b53c08d99c007f9c7e59e1f238d94b3d4 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 21 Jan 2020 09:43:25 +0100 Subject: [PATCH 164/342] 7902578: Use underscores in long integer literals --- .../jmh/benchmarks/BlackholeBench.java | 2 +- .../jmh/benchmarks/ScoreStabilityBench.java | 2 +- .../jmh/benchmarks/ThermalRundownBench.java | 2 +- .../jmh/benchmarks/ThreadScalingBench.java | 2 +- .../tests/BlackholeConsumeCPUTest.java | 4 +- .../tests/BlackholePipelinedTest.java | 2 +- .../CompilerControlDontInlineActualTest.java | 2 +- .../CompilerControlExcludeActualTest.java | 2 +- .../CompilerControlInlineActualTest.java | 2 +- .../jmh/it/footprint/ForkedFootprintTest.java | 2 +- .../jmh/profile/LinuxPerfNormProfiler.java | 2 +- .../openjdk/jmh/profile/PausesProfiler.java | 4 +- .../jmh/profile/SafepointsProfiler.java | 2 +- .../jmh/profile/WinPerfAsmProfiler.java | 2 +- .../java/org/openjdk/jmh/BlackholeTest.java | 2 +- .../jmh/results/ResultAggregationTest.java | 100 +++++++++--------- .../jmh/results/TestAverageTimeResult.java | 16 +-- .../jmh/results/TestThroughputResult.java | 64 +++++------ .../jmh/samples/JMHSample_11_Loops.java | 12 +-- 19 files changed, 113 insertions(+), 113 deletions(-) diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeBench.java index 6e266906c..b4dfba6c4 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeBench.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeBench.java @@ -42,7 +42,7 @@ public class BlackholeBench { public void makeGarbage() { // make some garbage to evict blackhole from the TLAB/eden strs = new ArrayList<>(); - for (int i = 0; i < 100000; i++) { + for (int i = 0; i < 100_000; i++) { strs.add("str" + i); } } diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ScoreStabilityBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ScoreStabilityBench.java index 3c03c7322..8d0110358 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ScoreStabilityBench.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ScoreStabilityBench.java @@ -47,7 +47,7 @@ public void sleep() throws InterruptedException { @Benchmark public void test() { - Blackhole.consumeCPU(1000000); + Blackhole.consumeCPU(1_000_000); } } diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThermalRundownBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThermalRundownBench.java index e9c08f7c7..1b0069c81 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThermalRundownBench.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThermalRundownBench.java @@ -36,7 +36,7 @@ public class ThermalRundownBench { @Benchmark public void test() { - Blackhole.consumeCPU(1000000); + Blackhole.consumeCPU(1_000_000); } } diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThreadScalingBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThreadScalingBench.java index de7219ac4..31bf5e708 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThreadScalingBench.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ThreadScalingBench.java @@ -36,7 +36,7 @@ public class ThreadScalingBench { @Benchmark public void test() { - Blackhole.consumeCPU(1000000); + Blackhole.consumeCPU(1_000_000); } } diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsumeCPUTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsumeCPUTest.java index 18269b2b8..550f806dc 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsumeCPUTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsumeCPUTest.java @@ -55,8 +55,8 @@ public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.printf("%20s%n", "#Tokens: "); for (int delay : new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 20, 30, 40, 50, 60, 70, 80, 90, 100, 500, 1000, - 5000, 10000, 50000, 100000, 500000, 1000000, 5000000, 10000000}) { + 20, 30, 40, 50, 60, 70, 80, 90, 100, 500, 1_000, + 5_000, 10_000, 50_000, 100_000, 500_000, 1_000_000, 5_000_000, 10_000_000}) { Options opts = new OptionsBuilder() .parent(parent) .include(BlackholeConsumeCPUBench.class.getCanonicalName()) diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholePipelinedTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholePipelinedTest.java index c77f5ac01..070d7b424 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholePipelinedTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholePipelinedTest.java @@ -81,7 +81,7 @@ public void runWith(PrintWriter pw, Options parent) throws RunnerException { "Array", }; - int[] ss = {1, 10, 100, 1000, 10000}; + int[] ss = {1, 10, 100, 1_000, 10_000}; pw.println(" Scores are nanoseconds per (normalized) benchmark op."); pw.println(" Trying loops with " + Arrays.toString(ss) + " iterations."); diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineActualTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineActualTest.java index 61e0548fb..902116ad3 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineActualTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineActualTest.java @@ -66,7 +66,7 @@ public void testBenchmark() throws RunnerException { .mode(mode) .shouldFailOnError(true) .addProfiler(LogConsumeProfiler.class) - .measurementIterations(mode == Mode.SingleShotTime ? 200000 : 1) + .measurementIterations(mode == Mode.SingleShotTime ? 200_000 : 1) .measurementTime(TimeValue.seconds(5)) .warmupIterations(0) .forks(1) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeActualTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeActualTest.java index e7dcd2338..427a17fc9 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeActualTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeActualTest.java @@ -66,7 +66,7 @@ public void testBenchmark() throws RunnerException { .mode(mode) .shouldFailOnError(true) .addProfiler(LogConsumeProfiler.class) - .measurementIterations(mode == Mode.SingleShotTime ? 200000 : 1) + .measurementIterations(mode == Mode.SingleShotTime ? 200_000 : 1) .measurementTime(TimeValue.seconds(5)) .warmupIterations(0) .forks(1) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineActualTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineActualTest.java index e2c8b6928..26d3ccbbd 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineActualTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineActualTest.java @@ -66,7 +66,7 @@ public void testBenchmark() throws RunnerException { .mode(mode) .shouldFailOnError(true) .addProfiler(LogConsumeProfiler.class) - .measurementIterations(mode == Mode.SingleShotTime ? 200000 : 1) + .measurementIterations(mode == Mode.SingleShotTime ? 200_000 : 1) .measurementTime(TimeValue.seconds(5)) .warmupIterations(0) .forks(1) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/footprint/ForkedFootprintTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/footprint/ForkedFootprintTest.java index cd45b992a..5e95ab3b2 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/footprint/ForkedFootprintTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/footprint/ForkedFootprintTest.java @@ -50,7 +50,7 @@ public void testBenchmark() throws RunnerException { .include(Fixtures.getTestMask(this.getClass())) .mode(mode) .shouldFailOnError(true) - .measurementIterations(mode == Mode.SingleShotTime ? 500000 : 1000) + .measurementIterations(mode == Mode.SingleShotTime ? 500_000 : 1_000) .measurementTime(TimeValue.milliseconds(5)) .warmupIterations(0) .forks(1) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index 5dccd36df..89a1d645e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -89,7 +89,7 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { OptionSpec optHighPassFilter = parser.accepts("highPassFilter", "Ignore event increments larger that this.") - .withRequiredArg().ofType(Long.class).describedAs("#").defaultsTo(100000000000L); + .withRequiredArg().ofType(Long.class).describedAs("#").defaultsTo(100_000_000_000L); OptionSpec optDefaultStat = parser.accepts("useDefaultStat", "Use \"perf stat -d -d -d\" instead of explicit counter list.") diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java index cfffb9a4a..207720342 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java @@ -102,7 +102,7 @@ private long calibrate() { SampleBuffer buf = new SampleBuffer(); long lastTime = System.nanoTime(); - for (int c = 0; c < 10000; c++) { + for (int c = 0; c < 10_000; c++) { LockSupport.parkNanos(expectedNs); long time = System.nanoTime(); @@ -153,7 +153,7 @@ static class PausesProfilerResult extends Result { private final SampleBuffer buffer; public PausesProfilerResult(SampleBuffer buffer) { - super(ResultRole.SECONDARY, Defaults.PREFIX + "pauses", buffer.getStatistics(1D / 1000000), "ms", AggregationPolicy.SUM); + super(ResultRole.SECONDARY, Defaults.PREFIX + "pauses", buffer.getStatistics(1D / 1_000_000), "ms", AggregationPolicy.SUM); this.buffer = buffer; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java index 486897fa9..34286b1a2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -146,7 +146,7 @@ static class SafepointProfilerResult extends Result { private final SampleBuffer buffer; public SafepointProfilerResult(String suffix, SampleBuffer buffer) { - super(ResultRole.SECONDARY, Defaults.PREFIX + "safepoints." + suffix, buffer.getStatistics(1D / 1000000), "ms", AggregationPolicy.SUM); + super(ResultRole.SECONDARY, Defaults.PREFIX + "safepoints." + suffix, buffer.getStatistics(1D / 1_000_000), "ms", AggregationPolicy.SUM); this.suffix = suffix; this.buffer = buffer; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index da4f2d6c2..7334e2304 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -218,7 +218,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { // Check timestamp String timeStr = elems[1].trim(); - double time = Double.parseDouble(timeStr) / 1000000; + double time = Double.parseDouble(timeStr) / 1_000_000; if (time < readFrom) continue; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java b/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java index ff61b97de..15bddd844 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java @@ -34,7 +34,7 @@ public class BlackholeTest { public void test() { int tlr = 1; int tlrMask = 2; - for (int t = 0; t < 1000000000; t++) { + for (int t = 0; t < 1_000_000_000; t++) { tlr = (tlr * 48271); if ((tlr & tlrMask) == 0) { // SHOULD ALMOST NEVER HAPPEN IN MEASUREMENT diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/ResultAggregationTest.java b/jmh-core/src/test/java/org/openjdk/jmh/results/ResultAggregationTest.java index 929283bda..555e89d8f 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/ResultAggregationTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/ResultAggregationTest.java @@ -36,31 +36,31 @@ public class ResultAggregationTest { @Test public void testThroughput() { IterationResult ir = new IterationResult(null, null, null); - ir.addResult(new ThroughputResult(ResultRole.PRIMARY, "", 10000, 1, TimeUnit.NANOSECONDS)); - ir.addResult(new ThroughputResult(ResultRole.PRIMARY, "", 10000, 1, TimeUnit.NANOSECONDS)); - ir.addResult(new ThroughputResult(ResultRole.SECONDARY, "sec", 5000, 1, TimeUnit.NANOSECONDS)); - ir.addResult(new ThroughputResult(ResultRole.SECONDARY, "sec", 5000, 1, TimeUnit.NANOSECONDS)); - Assert.assertEquals(20000.0, ir.getPrimaryResult().getScore()); - Assert.assertEquals(10000.0, ir.getSecondaryResults().get("sec").getScore()); + ir.addResult(new ThroughputResult(ResultRole.PRIMARY, "", 10_000, 1, TimeUnit.NANOSECONDS)); + ir.addResult(new ThroughputResult(ResultRole.PRIMARY, "", 10_000, 1, TimeUnit.NANOSECONDS)); + ir.addResult(new ThroughputResult(ResultRole.SECONDARY, "sec", 5_000, 1, TimeUnit.NANOSECONDS)); + ir.addResult(new ThroughputResult(ResultRole.SECONDARY, "sec", 5_000, 1, TimeUnit.NANOSECONDS)); + Assert.assertEquals(20_000.0, ir.getPrimaryResult().getScore()); + Assert.assertEquals(10_000.0, ir.getSecondaryResults().get("sec").getScore()); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); Assert.assertEquals(2, ir.getRawSecondaryResults().get("sec").size()); BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); - br.addBenchmarkResult(new ThroughputResult(ResultRole.SECONDARY, "bench", 3000, 1, TimeUnit.NANOSECONDS)); - Assert.assertEquals(20000.0, br.getPrimaryResult().getScore()); - Assert.assertEquals(10000.0, br.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3000.0, br.getSecondaryResults().get("bench").getScore()); + br.addBenchmarkResult(new ThroughputResult(ResultRole.SECONDARY, "bench", 3_000, 1, TimeUnit.NANOSECONDS)); + Assert.assertEquals(20_000.0, br.getPrimaryResult().getScore()); + Assert.assertEquals(10_000.0, br.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore()); Assert.assertEquals(2, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); - Assert.assertEquals(20000.0, rr.getPrimaryResult().getScore()); - Assert.assertEquals(10000.0, rr.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3000.0, rr.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(20_000.0, rr.getPrimaryResult().getScore()); + Assert.assertEquals(10_000.0, rr.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore()); Assert.assertEquals(4, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); @@ -70,31 +70,31 @@ public void testThroughput() { @Test public void testAverageTime() { IterationResult ir = new IterationResult(null, null, null); - ir.addResult(new AverageTimeResult(ResultRole.PRIMARY, "", 1, 10000, TimeUnit.NANOSECONDS)); - ir.addResult(new AverageTimeResult(ResultRole.PRIMARY, "", 1, 10000, TimeUnit.NANOSECONDS)); - ir.addResult(new AverageTimeResult(ResultRole.SECONDARY, "sec", 1, 5000, TimeUnit.NANOSECONDS)); - ir.addResult(new AverageTimeResult(ResultRole.SECONDARY, "sec", 1, 5000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10000.0, ir.getPrimaryResult().getScore()); - Assert.assertEquals(5000.0, ir.getSecondaryResults().get("sec").getScore()); + ir.addResult(new AverageTimeResult(ResultRole.PRIMARY, "", 1, 10_000, TimeUnit.NANOSECONDS)); + ir.addResult(new AverageTimeResult(ResultRole.PRIMARY, "", 1, 10_000, TimeUnit.NANOSECONDS)); + ir.addResult(new AverageTimeResult(ResultRole.SECONDARY, "sec", 1, 5_000, TimeUnit.NANOSECONDS)); + ir.addResult(new AverageTimeResult(ResultRole.SECONDARY, "sec", 1, 5_000, TimeUnit.NANOSECONDS)); + Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore()); + Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore()); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); Assert.assertEquals(2, ir.getRawSecondaryResults().get("sec").size()); BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); - br.addBenchmarkResult(new AverageTimeResult(ResultRole.SECONDARY, "bench", 1, 3000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10000.0, br.getPrimaryResult().getScore()); - Assert.assertEquals(5000.0, br.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3000.0, br.getSecondaryResults().get("bench").getScore()); + br.addBenchmarkResult(new AverageTimeResult(ResultRole.SECONDARY, "bench", 1, 3_000, TimeUnit.NANOSECONDS)); + Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore()); + Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore()); Assert.assertEquals(2, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); - Assert.assertEquals(10000.0, rr.getPrimaryResult().getScore()); - Assert.assertEquals(5000.0, rr.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3000.0, rr.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore()); + Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore()); Assert.assertEquals(4, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); @@ -104,21 +104,21 @@ public void testAverageTime() { @Test public void testSampleTime() { SampleBuffer sb10000 = new SampleBuffer(); - sb10000.add(10000); + sb10000.add(10_000); SampleBuffer sb5000 = new SampleBuffer(); - sb5000.add(5000); + sb5000.add(5_000); SampleBuffer sb3000 = new SampleBuffer(); - sb3000.add(3000); + sb3000.add(3_000); IterationResult ir = new IterationResult(null, null, null); ir.addResult(new SampleTimeResult(ResultRole.PRIMARY, "", sb10000, TimeUnit.NANOSECONDS)); ir.addResult(new SampleTimeResult(ResultRole.PRIMARY, "", sb10000, TimeUnit.NANOSECONDS)); ir.addResult(new SampleTimeResult(ResultRole.SECONDARY, "sec", sb5000, TimeUnit.NANOSECONDS)); ir.addResult(new SampleTimeResult(ResultRole.SECONDARY, "sec", sb5000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10000.0, ir.getPrimaryResult().getScore()); - Assert.assertEquals(5000.0, ir.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore()); + Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); Assert.assertEquals(2, ir.getRawSecondaryResults().get("sec").size()); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); @@ -126,18 +126,18 @@ public void testSampleTime() { BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); br.addBenchmarkResult(new SampleTimeResult(ResultRole.SECONDARY, "bench", sb3000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10000.0, br.getPrimaryResult().getScore()); - Assert.assertEquals(5000.0, br.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3000.0, br.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore()); + Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore()); Assert.assertEquals(4, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); - Assert.assertEquals(10000.0, rr.getPrimaryResult().getScore()); - Assert.assertEquals(5000.0, rr.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3000.0, rr.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore()); + Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore()); Assert.assertEquals(8, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(8, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); @@ -147,31 +147,31 @@ public void testSampleTime() { @Test public void testSingleShot() { IterationResult ir = new IterationResult(null, null, null); - ir.addResult(new SingleShotResult(ResultRole.PRIMARY, "", 10000, TimeUnit.NANOSECONDS)); - ir.addResult(new SingleShotResult(ResultRole.PRIMARY, "", 10000, TimeUnit.NANOSECONDS)); - ir.addResult(new SingleShotResult(ResultRole.SECONDARY, "sec", 5000, TimeUnit.NANOSECONDS)); - ir.addResult(new SingleShotResult(ResultRole.SECONDARY, "sec", 5000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10000.0, ir.getPrimaryResult().getScore()); - Assert.assertEquals(5000.0, ir.getSecondaryResults().get("sec").getScore()); + ir.addResult(new SingleShotResult(ResultRole.PRIMARY, "", 10_000, TimeUnit.NANOSECONDS)); + ir.addResult(new SingleShotResult(ResultRole.PRIMARY, "", 10_000, TimeUnit.NANOSECONDS)); + ir.addResult(new SingleShotResult(ResultRole.SECONDARY, "sec", 5_000, TimeUnit.NANOSECONDS)); + ir.addResult(new SingleShotResult(ResultRole.SECONDARY, "sec", 5_000, TimeUnit.NANOSECONDS)); + Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore()); + Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore()); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); Assert.assertEquals(2, ir.getRawSecondaryResults().get("sec").size()); BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); - br.addBenchmarkResult(new SingleShotResult(ResultRole.SECONDARY, "bench", 3000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10000.0, br.getPrimaryResult().getScore()); - Assert.assertEquals(5000.0, br.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3000.0, br.getSecondaryResults().get("bench").getScore()); + br.addBenchmarkResult(new SingleShotResult(ResultRole.SECONDARY, "bench", 3_000, TimeUnit.NANOSECONDS)); + Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore()); + Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore()); Assert.assertEquals(2, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); - Assert.assertEquals(10000.0, rr.getPrimaryResult().getScore()); - Assert.assertEquals(5000.0, rr.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3000.0, rr.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore()); + Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore()); Assert.assertEquals(4, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAverageTimeResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAverageTimeResult.java index 655753bef..1fc1f6aa1 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAverageTimeResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAverageTimeResult.java @@ -35,8 +35,8 @@ public class TestAverageTimeResult { @Test public void testIterationAggregator1() { - AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MICROSECONDS); - AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1000L, 2000000L, TimeUnit.MICROSECONDS); + AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); + AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 2_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.5, result.getScore()); @@ -45,8 +45,8 @@ public void testIterationAggregator1() { @Test public void testIterationAggregator2() { - AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MICROSECONDS); - AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MICROSECONDS); + AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); + AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.0, result.getScore()); @@ -55,8 +55,8 @@ public void testIterationAggregator2() { @Test public void testThreadAggregator1() { - AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MICROSECONDS); - AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MICROSECONDS); + AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); + AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.0, result.getScore()); @@ -65,8 +65,8 @@ public void testThreadAggregator1() { @Test public void testThreadAggregator2() { - AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MICROSECONDS); - AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1000L, 2000000L, TimeUnit.MICROSECONDS); + AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); + AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 2_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(1.5, result.getScore()); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestThroughputResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestThroughputResult.java index c21388ca0..d7647916e 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestThroughputResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestThroughputResult.java @@ -38,49 +38,49 @@ public class TestThroughputResult { */ @Test public void testGetScore() { - ThroughputResult instance = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MILLISECONDS); - assertEquals(1000, instance.getScore(), 0.0); - ThroughputResult instance2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.SECONDS); - assertEquals(1000000, instance2.getScore(), 0.0); - ThroughputResult instance3 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000L, TimeUnit.MILLISECONDS); - assertEquals(1000 / (1000 / (double) 1000000), instance3.getScore(), 0.0); + ThroughputResult instance = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MILLISECONDS); + assertEquals(1_000, instance.getScore(), 0.0); + ThroughputResult instance2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.SECONDS); + assertEquals(1_000_000, instance2.getScore(), 0.0); + ThroughputResult instance3 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000L, TimeUnit.MILLISECONDS); + assertEquals(1_000 / (1_000 / (double) 1_000_000), instance3.getScore(), 0.0); } @Test public void testTimeUnits() { - ThroughputResult instanced = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.DAYS); - assertEquals(86400000000D, instanced.getScore(), 0.0); + ThroughputResult instanced = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.DAYS); + assertEquals(86_400_000_000D, instanced.getScore(), 0.0); assertEquals("ops/day", instanced.getScoreUnit()); - ThroughputResult instanceh = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.HOURS); - assertEquals(3600000000D, instanceh.getScore(), 0.0); + ThroughputResult instanceh = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.HOURS); + assertEquals(3_600_000_000D, instanceh.getScore(), 0.0); assertEquals("ops/hr", instanceh.getScoreUnit()); - ThroughputResult instancem = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MINUTES); - assertEquals(60000000, instancem.getScore(), 0.0); + ThroughputResult instancem = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MINUTES); + assertEquals(60_000_000, instancem.getScore(), 0.0); assertEquals("ops/min", instancem.getScoreUnit()); - ThroughputResult instance = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.SECONDS); - assertEquals(1000000, instance.getScore(), 0.0); + ThroughputResult instance = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.SECONDS); + assertEquals(1_000_000, instance.getScore(), 0.0); assertEquals("ops/s", instance.getScoreUnit()); - ThroughputResult instance2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MILLISECONDS); - assertEquals(1000, instance2.getScore(), 0.0); + ThroughputResult instance2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MILLISECONDS); + assertEquals(1_000, instance2.getScore(), 0.0); assertEquals("ops/ms", instance2.getScoreUnit()); - ThroughputResult instance3 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.MICROSECONDS); + ThroughputResult instance3 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); assertEquals(1, instance3.getScore(), 0.0); assertEquals("ops/us", instance3.getScoreUnit()); - ThroughputResult instance4 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 1000000L, TimeUnit.NANOSECONDS); + ThroughputResult instance4 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.NANOSECONDS); assertEquals(0.001, instance4.getScore(), 0.0); assertEquals("ops/ns", instance4.getScoreUnit()); } @Test public void testRunAggregator1() { - ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 10000000L, TimeUnit.MILLISECONDS); - ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2000L, 10000000L, TimeUnit.MILLISECONDS); + ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 10_000_000L, TimeUnit.MILLISECONDS); + ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 10_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(150.0, result.getScore()); @@ -89,8 +89,8 @@ public void testRunAggregator1() { @Test public void testRunAggregator2() { - ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 10000000L, TimeUnit.MILLISECONDS); - ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2000L, 20000000L, TimeUnit.MILLISECONDS); + ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 10_000_000L, TimeUnit.MILLISECONDS); + ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals(100.0, result.getScore()); @@ -99,18 +99,18 @@ public void testRunAggregator2() { @Test // regression test, check for overflow public void testIterationAggregator3() { - ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000000000L, 10000000L, TimeUnit.MILLISECONDS); - ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2000000000L, 20000000L, TimeUnit.MILLISECONDS); + ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000_000_000L, 10_000_000L, TimeUnit.MILLISECONDS); + ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000_000_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(100000000.0, result.getScore()); + assertEquals(100_000_000.0, result.getScore()); assertEquals("ops/ms", result.getScoreUnit()); } @Test public void testThreadAggregator1() { - ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 10000000L, TimeUnit.MILLISECONDS); - ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2000L, 10000000L, TimeUnit.MILLISECONDS); + ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 10_000_000L, TimeUnit.MILLISECONDS); + ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 10_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals("ops/ms", result.getScoreUnit()); @@ -119,8 +119,8 @@ public void testThreadAggregator1() { @Test public void testThreadAggregator2() { - ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000L, 10000000L, TimeUnit.MILLISECONDS); - ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2000L, 20000000L, TimeUnit.MILLISECONDS); + ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000L, 10_000_000L, TimeUnit.MILLISECONDS); + ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals("ops/ms", result.getScoreUnit()); @@ -129,11 +129,11 @@ public void testThreadAggregator2() { @Test // regression test, check for overflow public void testThreadAggregator3() { - ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1000000000L, 10000000L, TimeUnit.MILLISECONDS); - ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2000000000L, 20000000L, TimeUnit.MILLISECONDS); + ThroughputResult r1 = new ThroughputResult(ResultRole.PRIMARY, "test1", 1_000_000_000L, 10_000_000L, TimeUnit.MILLISECONDS); + ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000_000_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals("ops/ms", result.getScoreUnit()); - assertEquals(200000000.0, result.getScore()); + assertEquals(200_000_000.0, result.getScore()); } } diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java index 3deb01e3d..927d4f51a 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java @@ -106,21 +106,21 @@ public int measureWrong_100() { } @Benchmark - @OperationsPerInvocation(1000) + @OperationsPerInvocation(1_000) public int measureWrong_1000() { - return reps(1000); + return reps(1_000); } @Benchmark - @OperationsPerInvocation(10000) + @OperationsPerInvocation(10_000) public int measureWrong_10000() { - return reps(10000); + return reps(10_000); } @Benchmark - @OperationsPerInvocation(100000) + @OperationsPerInvocation(100_000) public int measureWrong_100000() { - return reps(100000); + return reps(100_000); } /* From 50863088e13ba671484fa9cd2cd492c497023126 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 22 Jan 2020 08:50:11 +0100 Subject: [PATCH 165/342] JMH v1.23 --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java | 1 + jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 16 files changed, 16 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 0c9a6967a..e8ac2f39e 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.23-SNAPSHOT + 1.23 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index a36339785..b47da90da 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.23-SNAPSHOT + 1.23 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index ac4433284..446de4854 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.23-SNAPSHOT + 1.23 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 409d805d5..5ef7fdc62 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.23-SNAPSHOT + 1.23 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 3853792d7..512597889 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index c76ba767b..c2a94c7dd 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 289b34790..66ec100e8 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 0aa198dfd..55589b036 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index a82f52eb4..d1f3f4d55 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Core diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java index b5ff9c3f3..137fdba56 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java @@ -25,6 +25,7 @@ package org.openjdk.jmh.util; import java.io.*; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 2102db1f8..02d9cee52 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index caeaf04aa..e62588cc2 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 681c4fc0d..3599c1fdb 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 882cac4d3..014ef5785 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 2f0b8b7a7..ce8b3c26f 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.23-SNAPSHOT + 1.23 JMH Samples diff --git a/pom.xml b/pom.xml index 25e030f85..fbfccacac 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.23-SNAPSHOT + 1.23 Java Microbenchmark Harness Parent From c983fac2009bfe1c2ac9f52a9aa87dbdc2168b48 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 22 Jan 2020 11:28:04 +0100 Subject: [PATCH 166/342] Added tag 1.23 for changeset 24b3c89b5332 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 2bc204206..b56cf4d88 100644 --- a/.hgtags +++ b/.hgtags @@ -91,3 +91,4 @@ b7dc6e851f12a5bf2086f6f5d963d939ea5bd509 1.19 bd52958ab68089093f8c21d0a7c4af2848b845f6 1.20 f25ae8584db1d6d4602af701688c2ccb90684396 1.21 40c1cca654c119c1ac9097f38f934cf9e42b311e 1.22 +24b3c89b53322f9e55852a2c0195a4027aa54c12 1.23 From 1505ad0cef0648bd7e8114d040cf538eee15b5f5 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 22 Jan 2020 11:28:18 +0100 Subject: [PATCH 167/342] Continue in 1.24-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index e8ac2f39e..b54d7967a 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.23 + 1.24-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index b47da90da..6f60b392b 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.23 + 1.24-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 446de4854..1026e35b9 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.23 + 1.24-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 5ef7fdc62..a04abf283 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.23 + 1.24-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 512597889..29c380ab6 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index c2a94c7dd..b4445b605 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 66ec100e8..345fbe0f8 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 55589b036..73667c625 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index d1f3f4d55..4b105741a 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 02d9cee52..a24e6c394 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index e62588cc2..49ebba1f2 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 3599c1fdb..a311cb28c 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 014ef5785..1f9bbc4a5 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index ce8b3c26f..e83dbbf64 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.23 + 1.24-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index fbfccacac..189eaf4ce 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.23 + 1.24-SNAPSHOT Java Microbenchmark Harness Parent From 7591fa89e5929f78fa1df6239709f3bb1d35721f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 13 Feb 2020 11:05:17 +0100 Subject: [PATCH 168/342] 7902607: Rename generated package from "generated" to "jmh_generated" --- .../openjdk/jmh/generators/core/BenchmarkGenerator.java | 8 +++++--- .../java/org/openjdk/jmh/generators/core/StateObject.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 29b79ddc5..e459d76f5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -49,6 +49,8 @@ public class BenchmarkGenerator { private static final String JMH_STUB_SUFFIX = "_jmhStub"; + private static final String JMH_TESTCLASS_SUFFIX = "_jmhTest"; + protected static final String JMH_GENERATED_SUBPACKAGE = "jmh_generated"; private final Set benchmarkInfos; private final CompilerControlPlugin compilerControl; @@ -203,7 +205,7 @@ private Multimap buildAnnotatedSet(GeneratorSource source Multimap result = new HashMultimap<>(); for (ClassInfo currentClass : source.getClasses()) { - if (currentClass.getQualifiedName().contains("generated")) continue; + if (currentClass.getQualifiedName().contains(JMH_GENERATED_SUBPACKAGE)) continue; if (currentClass.isAbstract()) continue; ClassInfo walk = currentClass; @@ -422,8 +424,8 @@ private Collection makeBenchmarkInfo(ClassInfo clazz, Collection< Collection benchmarks = new ArrayList<>(); for (MethodGroup group : result.values()) { String sourcePackage = clazz.getPackageName(); - String generatedPackageName = sourcePackage + ".generated"; - String generatedClassName = BenchmarkGeneratorUtils.getGeneratedName(clazz) + "_" + group.getName() + "_jmhTest"; + String generatedPackageName = sourcePackage + "." + JMH_GENERATED_SUBPACKAGE; + String generatedClassName = BenchmarkGeneratorUtils.getGeneratedName(clazz) + "_" + group.getName() + JMH_TESTCLASS_SUFFIX; BenchmarkInfo info = new BenchmarkInfo(clazz.getQualifiedName(), generatedPackageName, generatedClassName, group); validateBenchmarkInfo(info); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java index 54ab0cbdf..7ddc69a9a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObject.java @@ -52,7 +52,7 @@ public int compare(StateObject o1, StateObject o2) { public final List depends; public StateObject(Identifiers identifiers, ClassInfo info, Scope scope) { - this.packageName = info.getPackageName() + ".generated"; + this.packageName = info.getPackageName() + "." + BenchmarkGenerator.JMH_GENERATED_SUBPACKAGE; this.userType = info.getQualifiedName(); this.type = identifiers.getJMHtype(info); this.scope = scope; From 7de311155d87beca066d1b071444d6ee44393b0c Mon Sep 17 00:00:00 2001 From: Dmitry Chuyko Date: Fri, 14 Feb 2020 09:42:04 +0100 Subject: [PATCH 169/342] 7902609: Some serializable classes in jmh-core don't have serialVersionUID --- jmh-core/pom.xml | 9 +++++++-- .../java/org/openjdk/jmh/profile/PausesProfiler.java | 5 ++++- .../java/org/openjdk/jmh/profile/ProfilerException.java | 5 ++++- .../java/org/openjdk/jmh/profile/SafepointsProfiler.java | 5 ++++- .../org/openjdk/jmh/results/BenchmarkResultMetaData.java | 4 +++- .../org/openjdk/jmh/results/IterationResultMetaData.java | 4 +++- .../org/openjdk/jmh/runner/FailureAssistException.java | 3 ++- .../main/java/org/openjdk/jmh/runner/ForkedRunner.java | 5 ++++- .../org/openjdk/jmh/runner/options/ProfilerConfig.java | 4 +++- 9 files changed, 34 insertions(+), 10 deletions(-) diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 4b105741a..47e996130 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -1,5 +1,5 @@ -Djmh.ignoreLock=true -Xms256m -Xmx256m -Djmh.core.it.profile=${jmh.core.it.profile} 1C - true + + false true From 095c5d45887e71bbafbc51400faa425f56997367 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 9 Oct 2020 11:09:52 +0200 Subject: [PATCH 219/342] 7902782: JMH separate classpath JAR generation fails when file cannot be read through the relativized path --- .../src/main/java/org/openjdk/jmh/runner/Runner.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 798b1b467..3488b0377 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -45,6 +45,7 @@ import java.nio.channels.FileChannel; import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; @@ -891,7 +892,12 @@ private void addClasspath(List command) { throw new IOException("Cannot relativize: " + cpPath + " and " + tmpFileDir + " have different roots."); } - String rel = tmpFileDir.relativize(cpPath).toString(); + Path relPath = tmpFileDir.relativize(cpPath); + if (!Files.isReadable(tmpFileDir.resolve(relPath))) { + throw new IOException("Cannot read through the relativized path: " + relPath); + } + + String rel = relPath.toString(); sb.append(rel.replace('\\', '/').replace(" ", "%20")); if (!cp.endsWith(".jar")) { sb.append('/'); @@ -910,6 +916,7 @@ private void addClasspath(List command) { } out.verbosePrintln("Using separate classpath JAR: " + tmpFile); + out.verbosePrintln(" Class-Path: " + classPath); } catch (IOException ex) { // Something is wrong in file generation, give up and fall-through to usual thing out.verbosePrintln("Caught IOException when building separate classpath JAR: " + From 896794b3ebaa95b7ee844c3e82e124458e2b0506 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 9 Oct 2020 12:37:42 +0200 Subject: [PATCH 220/342] JMH Pre-Integration Tests workflow (#5) --- .github/workflows/pre-integration.yml | 36 +++++++++++++++++++++++++++ README.md | 3 +++ 2 files changed, 39 insertions(+) create mode 100644 .github/workflows/pre-integration.yml diff --git a/.github/workflows/pre-integration.yml b/.github/workflows/pre-integration.yml new file mode 100644 index 000000000..c0c8856de --- /dev/null +++ b/.github/workflows/pre-integration.yml @@ -0,0 +1,36 @@ +name: JMH Pre-Integration Tests + +on: + pull_request: + types: [opened, reopened, ready_for_review, synchronize] + workflow_dispatch: + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + java: [7, 8, 11, 15, 16-ea] + os: [ubuntu-18.04, windows-2019, macos-10.15] + profile: [default, reflection, asm] + fail-fast: false + name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}, ${{ matrix.profile }} + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '.github/workflows/pre-integration.yml') }} + restore-keys: ${{ runner.os }}-maven + - name: Run build with tests + run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml + if: (runner.os == 'Linux') || (matrix.profile == 'default') + - name: Run build without tests + run: mvn clean install -DskipTests -P ${{ matrix.profile }} -B --file pom.xml + if: (runner.os != 'Linux') && (matrix.profile != 'default') diff --git a/README.md b/README.md index 7f5171a0b..8d05a4b57 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,9 @@ Short instructions to build, test bleeding-edge JMH, and install its JAR to loca If you already have the benchmark project, then it is enough to change JMH dependencies version to the latest `SNAPSHOT` version (look up the actual latest version in [root `pom.xml`](https://github.com/openjdk/jmh/blob/9f5b990334bbcb27856740d6330ba2d0c928d2f1/pom.xml#L33)). If not, create the JMH benchmark project and change the version there. +GitHub workflow "JMH Pre-Integration Tests" should pass on the changes. It would be triggered +for PRs. You can also trigger it manually for your branch. + ## Related projects These projects are supported by community, not by OpenJDK/JMH developers. From 319a92a2331d24371546e331f1b5e74d13bb7fff Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 9 Oct 2020 12:56:06 +0200 Subject: [PATCH 221/342] JMH v1.26. --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index d07b04a73..c478a21d3 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.26-SNAPSHOT + 1.26 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 7298db69f..4abc07eb3 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.26-SNAPSHOT + 1.26 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 6fa9297ef..57118dbbd 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.26-SNAPSHOT + 1.26 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 9a9883bba..ee8f412cb 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.26-SNAPSHOT + 1.26 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index a13cd9cdb..de882a8d1 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 7d7ef1613..d9a0cef0f 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index ebd5d2755..a7e12afd2 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index d22aa0908..c58362b62 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 1d576d1dc..11f2497f3 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index ebecd62c7..3af94e46e 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index c57f136e9..b3203ce8a 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index e6b686c16..d2a663fc6 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 06d8cefa9..a871e6aec 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 843797286..dd214807e 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.26-SNAPSHOT + 1.26 JMH Samples diff --git a/pom.xml b/pom.xml index 4778f6573..7b4dbdb18 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.26-SNAPSHOT + 1.26 Java Microbenchmark Harness Parent From 352098cd64022a3bb77287d8d1802c4c74be5c01 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 9 Oct 2020 12:56:33 +0200 Subject: [PATCH 222/342] Continue in 1.27-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index c478a21d3..126951a7a 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.26 + 1.27-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 4abc07eb3..10806fe52 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.26 + 1.27-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 57118dbbd..1a122f9da 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.26 + 1.27-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index ee8f412cb..489733eeb 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.26 + 1.27-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index de882a8d1..046461c1f 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index d9a0cef0f..174190040 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index a7e12afd2..f233abfcf 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index c58362b62..b734960e4 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 11f2497f3..3c8076f65 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 3af94e46e..762e19624 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index b3203ce8a..5da696fad 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index d2a663fc6..f8ab68029 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index a871e6aec..e1832cd9a 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index dd214807e..77d771226 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.26 + 1.27-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 7b4dbdb18..a4a53ee27 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.26 + 1.27-SNAPSHOT Java Microbenchmark Harness Parent From c15983e8b6950ad453164468be54ffd1bc5e2fc0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 9 Oct 2020 19:00:16 +0200 Subject: [PATCH 223/342] Remove obsolete .hgignore and .hgtags --- .hgignore | 6 ---- .hgtags | 98 ------------------------------------------------------- 2 files changed, 104 deletions(-) delete mode 100644 .hgignore delete mode 100644 .hgtags diff --git a/.hgignore b/.hgignore deleted file mode 100644 index a812d8780..000000000 --- a/.hgignore +++ /dev/null @@ -1,6 +0,0 @@ -syntax: glob -.idea/ -*.iml -target/ -jmh-ant-sample/build/ -jmh-ant-sample/dist/ diff --git a/.hgtags b/.hgtags deleted file mode 100644 index 34ff4ada8..000000000 --- a/.hgtags +++ /dev/null @@ -1,98 +0,0 @@ -34c700cd00fe604469e3622127827be279ae97dd 0.1 -34c700cd00fe604469e3622127827be279ae97dd 0.1 -0000000000000000000000000000000000000000 0.1 -0000000000000000000000000000000000000000 0.1 -0d2def06660981673202f2e7cf9b8d72aa1a8bdd 0.1 -0d2def06660981673202f2e7cf9b8d72aa1a8bdd 0.1 -0000000000000000000000000000000000000000 0.1 -0000000000000000000000000000000000000000 0.1 -1e59f0d249dcc634d43b2da9358a2d1945a7175c 0.1 -c8c44a6b144bd8f98d74919dbb162eef1a7ce90a 0.2 -85b2d2cf695547541818adc309832f563b19e505 0.2.1 -0d32511839fe24246b3563d2fd584c93e9d0a9cf 0.3 -e8c286b688399710e6ecea7d9456b968fd03b046 0.3.1 -8a73dfe4bd9ef276789097d60743258308c259c5 0.3.2 -ab9be19b4646a04480944146d3d0c1b4a9a0159f 0.4 -5b8de0f72c4fc9e79c55dd5c6de4c5dd36a3b8c4 0.4.1 -79b00b6dbc75177f7b1fb2302a34941e75889671 0.4.2 -ef89a50c286c38d13768d44227d4b67522de1c52 0.5 -3e0a08bcfe2c10a467a64401ae9f9391c663befb 0.5.1 -2767984ca172532e210aae01cc0f7e8e47dc742f 0.5.2 -813992b1d95c29cd5088a4cbc0e412247ccc751b 0.5.3 -3ae98ec58b633e0c79e5568e0be80a2fe0d98311 0.5.4 -194c452d2c2a61ce73534b8347bbbfbcbf60ac1d 0.5.5 -6c5ecbc1c4911c2214f64524658b21ebd4c1d724 0.5.6 -f52021e4db498f2adb5ab2f8a94ea0fa03015d29 0.5.7 -77ec2ed6b3ad21d16b4fef29d3bac32bf7610b42 0.6 -b768c14f0c4211108bd429b21eaefaa6d8729912 0.7 -ae152e4fe48fcc51a4c7d147a1d10775d6db98be 0.7.1 -50b1117dbfdf9145555d1eeb09ea3d439bc2c9c5 0.7.2 -34edbbad35db1da3d6ba989c1597caf761bcee22 0.7.3 -a4dd7f8336e6c3371b5942383e4309b4c4bd59e4 0.8 -d985a0e68548eb37475986f70dd732d55b327062 0.9 -0060fbb99146490f40467452ccc96cfffda8c9b2 0.9.1 -64f90d19810508906e5c6d67b3f7cbccd5cb84aa 0.9.2 -2e167775cc75fbfad719552c902c1e99bfad94d8 0.9.3 -2cc1cd54a14fdeb2b99eff8f92697fcbc7250f06 0.9.4 -6d8faaf6b3fcfdd3903d60a23e73f103044aa436 0.9.5 -a275f55bcea01f6454e7e15c681cef613f14418d 0.9.6 -6e702a334f2e431118de06beb522593c3dc7442a 0.9.7 -9a19d4380a950e8d42f62f3b10cc196afa35bafc 0.9.8 -7257b0afa007e5c23821d67c8dd43547b4c9b346 1.0 -0d45525aa63e36caec2a6fad7eebd8b3ab2ebc13 1.0.1 -9b4287ecb19c9c044aa4612605d5aa2fba44e093 1.1 -42c0ba005980a6f4a1fadfc2f9556ffb2821d48e 1.1.1 -8ea7f1d0b2027f737e3adbfa1dbafd989711ec00 1.2 -42438fd5f38abb2cad133f7a7e438abd15f5d04e 1.3 -ce0549e576c18c207c19a39eb0e565520472de99 1.3.1 -81cf94290ce02d7b1c0b9fdb4a982a04f7d6af72 1.3.2 -23dfeb5ab9262be3e508a64eafd4975a79daa63a 1.3.3 -86754261b8bb4df658e62a16d2b4f6da98dd65a6 1.3.4 -6af8778e554e6f241c01709e3f3f39dbeee519bb 1.4 -553ca596316703c77169347ab5e95ce03e248de5 1.4.1 -d3693264151183186a23fbf4f40814f2de931537 1.4.2 -549ed28104afb05792cf65b2d29a3e3c52d5207b 1.5 -c91c58440dd06333f692b64bf35c8800374d2d55 1.5.1 -751e57ec521f793947ec05d5e2a3eb3eff6d3849 1.5.2 -6275d42f1bc34eefa09f559dd9b85ee9eb5191b2 1.6 -59dd39168ec67e9ce4fd1c1a601104498a67c6aa 1.6.1 -43167efb0a9041a57b598872c3c5368b1568b7c3 1.6.2 -68c86695196a506214e8ba0a1dd1a01110be8dfd 1.6.3 -96a2892f41a9e355cce1b369fbb814b47e4c1d39 1.7 -3d5bb9a657a5ae1aae33a6cf729c8a2a456aacc9 1.7.1 -43fd19824f3f9c1c39463a64a75da9b2b048f16c 1.8 -08f4588be2f3d447a448f00cc56ce82268b45427 1.9 -8a84b4f1822a03689955df27dd01b9393715fe98 1.9.1 -bcc6091c8eee3d1bc42a825e79d2148c278fe7d9 1.9.2 -7bc786c51b21ecdb733c40cef57718e79b7da787 1.9.3 -665a832d5061769d3833d2b5340f34efa7a2b23b 1.10 -d79c787a80c0ddaf70fc66a05019b8777b1cbfb1 1.10.1 -168a630204920a4015a9e795b599f4b7f7466222 1.10.3 -65fdc5d5f65d76046ca0383149f17b6436db7ab7 1.10.4 -a2a2d218a5cec6155b5123fbb65ab4a077b6d104 1.10.5 -c5a34103cbb32c8aee3d6b3a151f15819a4ea664 1.11 -48dbd05547e85e52017d1cbefe895ad744dbdefc 1.11.1 -4778686520db8eae8a26f78f4df48fcf2710515b 1.11.2 -534d83d9137f2231b889188f6bff02e541d1e7bd 1.11.3 -eb41bdab96cf7579db48fc39a9fa423b54bf4786 1.12 -7ff584954008f5dc877c590df5d902a0022f7456 1.13 -b9ea316668ae3e6510bf6ebe21625218f966c15a 1.14 -eaf181b4eac282ae20f9cb43ad221cf404a951c0 1.14.1 -318b0c31563430446b42e63095d90bc922fc62ee 1.15 -90e9bafa6cd05172901b336416856561c40d1247 1.16 -9df177c239d0962ecdaebebc00d650e52a2f32df 1.17 -bf7249ffbfd24a703f18ea90bff379de16182979 1.17.1 -d548e3fb7337d8116767e4f669f5a0c901de758b 1.17.2 -d4a8ae32b9063cf17c699455ced1b0d718f4977a 1.17.3 -3b9b9cd865e38cf19d08687754ff99eb982e662f 1.17.4 -5e3781c05e283dd4f5a71503e7cd7b9b151e5484 1.17.5 -6eb89dc11810e824b1f5416033cb1cf1f5f30f63 1.18 -b7dc6e851f12a5bf2086f6f5d963d939ea5bd509 1.19 -bd52958ab68089093f8c21d0a7c4af2848b845f6 1.20 -f25ae8584db1d6d4602af701688c2ccb90684396 1.21 -40c1cca654c119c1ac9097f38f934cf9e42b311e 1.22 -24b3c89b53322f9e55852a2c0195a4027aa54c12 1.23 -9a731f238a4d28b7610293580a728f898734d7da 1.24 -0b6b9a1f570af20fb55e6090935be50b93d68386 1.25 -849ac4e3078dc1aa0d235a677d662e70e1b00e58 1.25.1 -e87669c676c427d69ff599164eb49badb15b116b 1.25.2 From 007589a378539824ef9c3fd459108e66e9440961 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 13 Oct 2020 08:26:01 +0200 Subject: [PATCH 224/342] Full link to JMH bug tracker --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d05a4b57..cf434ab79 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ If all these did not help, you are welcome to report the issue. ### Reporting Harness and Test Bugs -If you have the access to [JDK Bug System](https://bugs.openjdk.java.net/), please submit the bug there: +If you have the access to [JDK Bug System](https://bugs.openjdk.java.net/browse/CODETOOLS-7902762?jql=project%20%3D%20CODETOOLS%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20tools%20AND%20Subcomponent%20%3D%20jmh), please submit the bug there: * Project: CODETOOLS * Component: tools * Sub-component: jmh From 57bb8c87c757266c02e32aa83d2c44df0a8c247c Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Wed, 21 Oct 2020 09:09:03 +0000 Subject: [PATCH 225/342] Runner: if -Djmh.ignoreLock=true then skip jmh.lock creation Reviewed-by: shade --- .../java/org/openjdk/jmh/runner/Runner.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 3488b0377..102bd0c67 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -181,6 +181,10 @@ public RunResult runSingle() throws RunnerException { * @throws org.openjdk.jmh.runner.RunnerException if something goes wrong */ public Collection run() throws RunnerException { + if (JMH_LOCK_IGNORE) { + out.println("# WARNING: JMH lock is ignored by user request, make sure no other JMH instances are running"); + return internalRun(); + } FileChannel channel = null; FileLock lock = null; try { @@ -199,23 +203,12 @@ public Collection run() throws RunnerException { } if (lock == null) { - String msg = "Unable to acquire the JMH lock (" + JMH_LOCK_FILE + "): already taken by another JMH instance"; - if (JMH_LOCK_IGNORE) { - out.println("# WARNING: " + msg + ", ignored by user's request."); - } else { - throw new RunnerException("ERROR: " + msg + ", exiting. Use -Djmh.ignoreLock=true to forcefully continue."); - } + throw new RunnerException("ERROR: Unable to acquire the JMH lock (" + JMH_LOCK_FILE + "): already taken by another JMH instance, exiting. Use -Djmh.ignoreLock=true to forcefully continue."); } return internalRun(); } catch (IOException e) { - String msg = "Exception while trying to acquire the JMH lock (" + JMH_LOCK_FILE + "): " + e.getMessage(); - if (JMH_LOCK_IGNORE) { - out.println("# WARNING: " + msg + ", ignored by user's request."); - return internalRun(); - } else { - throw new RunnerException("ERROR: " + msg + ", exiting. Use -Djmh.ignoreLock=true to forcefully continue."); - } + throw new RunnerException("ERROR: Exception while trying to acquire the JMH lock (" + JMH_LOCK_FILE + "), exiting. Use -Djmh.ignoreLock=true to forcefully continue.", e); } finally { try { if (lock != null) { From 620036ec27db3503fa2dee476036b3219c9a38bc Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Mon, 26 Oct 2020 08:58:51 +0000 Subject: [PATCH 226/342] StateObjectHandler.validateState(): fix typo and optimize Reviewed-by: shade --- .../openjdk/jmh/generators/core/StateObjectHandler.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 8926457b6..2bd35102b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -89,7 +89,7 @@ public static void validateState(ClassInfo state) { if (state.isFinal()) { throw new GenerationException("The instantiated @" + State.class.getSimpleName() + - " annotation does not support final classes. This class is not " , state); + " annotation does not support final classes." , state); } if (state.isInner()) { @@ -104,7 +104,10 @@ public static void validateState(ClassInfo state) { boolean hasDefaultConstructor = false; for (MethodInfo constructor : state.getConstructors()) { - hasDefaultConstructor |= (constructor.getParameters().isEmpty() && constructor.isPublic()); + if (constructor.getParameters().isEmpty()) { + hasDefaultConstructor = constructor.isPublic(); + break; + } } // These classes use the special init sequence: From 7b6ca46be957ac724f0038d38d24e3e4a1ae471c Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 1 Dec 2020 07:13:04 +0000 Subject: [PATCH 227/342] Upgrade ASM to 9.0 Reviewed-by: shade --- .../main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java index c7b85a12a..f435d353c 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java @@ -109,7 +109,7 @@ public AnnotationVisitor visitAnnotation(final String desc, boolean visible) { @Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { - ClassInfo type = classInfos.get(Type.getReturnType(desc).getClassName()); + ClassInfo type = classInfos.get(Type.getType(desc).getClassName()); FieldVisitor fv = super.visitField(access, name, desc, signature, value); ASMFieldInfo fi = new ASMFieldInfo(fv, this, access, name, type); fields.add(fi); diff --git a/pom.xml b/pom.xml index a4a53ee27..3d0945324 100644 --- a/pom.xml +++ b/pom.xml @@ -281,7 +281,7 @@ questions. org.ow2.asm asm - 5.0.3 + 9.0 From 75e24edf6ae1c1ed05808b68138c50a4a0c606f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Mon, 7 Dec 2020 12:55:11 +0100 Subject: [PATCH 228/342] 7902804: -prof async help messages should mention DYLD_LIBRARY_PATH for Mac OS users (#11) --- .../main/java/org/openjdk/jmh/profile/AsyncProfiler.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java index 5049e9308..4c294201c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java @@ -87,8 +87,8 @@ public AsyncProfiler(String initLine) throws ProfilerException { OptionSpec optLibPath = parser.accepts("libPath", "Location of asyncProfiler library. If not specified, System.loadLibrary will be used " + - "and the library must be made available to the forked JVM in an entry of -Djava.library.path " + - "or LD_LIBRARY_PATH.") + "and the library must be made available to the forked JVM in an entry of -Djava.library.path, " + + "LD_LIBRARY_PATH (Linux), or DYLD_LIBRARY_PATH (Mac OS).") .withRequiredArg().ofType(String.class).describedAs("path"); OptionSpec optEvent = parser.accepts("event", @@ -233,7 +233,8 @@ public AsyncProfiler(String initLine) throws ProfilerException { } } catch (UnsatisfiedLinkError e) { throw new ProfilerException("Unable to load async-profiler. Ensure asyncProfiler library " + - "is on LD_LIBRARY_PATH, -Djava.library.path or libPath=", e); + "is on LD_LIBRARY_PATH (Linux), DYLD_LIBRARY_PATH (Mac OS), or -Djava.library.path. " + + "Alternatively, point to explicit library location with -prof async:libPath=.", e); } this.direction = optDirection.value(set); this.output = optOutput.values(set); From f4550c4893f0d6449db22b4fa867ac55c00b4b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 8 Dec 2020 19:13:02 +0100 Subject: [PATCH 229/342] 7902808: Batch size tests still fail due to numerical and timing issues (#13) --- .../jmh/it/batchsize/BatchSizeSanityTest.java | 33 ++++++++++++++----- .../jmh/it/batchsize/OpsPerInvSanityTest.java | 31 +++++++++++++---- .../generators/core/BenchmarkGenerator.java | 8 ++--- .../org/openjdk/jmh/results/RawResults.java | 4 +-- 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java index 56e0eb1e9..8427eea4d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java @@ -39,25 +39,39 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -@State(Scope.Thread) +@State(Scope.Benchmark) public class BatchSizeSanityTest { - private static final int SLEEP_TIME_MS = 1; + private static final int SLEEP_TIME_MS = 50; @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) - public static class RawCounter { + public static class TimeCounter { public long time; + } + + @AuxCounters(AuxCounters.Type.EVENTS) + @State(Scope.Thread) + public static class OpsCounter { public int ops; } + private long startTime; + + @Setup(Level.Iteration) + public void setup() { + startTime = System.nanoTime(); + } + + @TearDown(Level.Iteration) + public void tearDown(TimeCounter cnt) { + cnt.time = System.nanoTime() - startTime; + } + @Benchmark - public void test(RawCounter cnt) throws InterruptedException { - long start = System.nanoTime(); + public void test(OpsCounter cnt) throws InterruptedException { TimeUnit.MILLISECONDS.sleep(SLEEP_TIME_MS); - long stop = System.nanoTime(); cnt.ops++; - cnt.time += (stop - start); } @Test @@ -113,7 +127,10 @@ private void doWith(Mode mode, int batchSize) throws RunnerException { Assert.fail("Unhandled mode: " + mode); } - Assert.assertTrue(mode + ", " + batchSize + ": " + expectedScore + " vs " + actualScore, + Assert.assertTrue( + String.format("mode = %s, batch size = %d, expected score = %e, actual score = %e; real time = %.5f, real ops = %.5f", + mode, batchSize, expectedScore, actualScore, + realTime, realOps), Math.abs(1 - actualScore / expectedScore) < TOLERANCE); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java index b49a55aac..cedc2876d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java @@ -42,22 +42,36 @@ @State(Scope.Thread) public class OpsPerInvSanityTest { - private static final int SLEEP_TIME_MS = 5; + private static final int SLEEP_TIME_MS = 50; @AuxCounters(AuxCounters.Type.EVENTS) @State(Scope.Thread) - public static class RawCounter { + public static class TimeCounter { public long time; + } + + @AuxCounters(AuxCounters.Type.EVENTS) + @State(Scope.Thread) + public static class OpsCounter { public int ops; } + private long startTime; + + @Setup(Level.Iteration) + public void setup() { + startTime = System.nanoTime(); + } + + @TearDown(Level.Iteration) + public void tearDown(TimeCounter cnt) { + cnt.time = System.nanoTime() - startTime; + } + @Benchmark - public void test(RawCounter cnt) throws InterruptedException { - long start = System.nanoTime(); + public void test(OpsCounter cnt) throws InterruptedException { TimeUnit.MILLISECONDS.sleep(SLEEP_TIME_MS); - long stop = System.nanoTime(); cnt.ops++; - cnt.time += (stop - start); } @Test @@ -115,7 +129,10 @@ private void doWith(Mode mode, int opsPerInv) throws RunnerException { Assert.fail("Unhandled mode: " + mode); } - Assert.assertTrue(mode + ", " + opsPerInv + ": " + expectedScore + " vs " + actualScore, + Assert.assertTrue( + String.format("mode = %s, ops per inv = %d, expected score = %e, actual score = %e; real time = %.5f, real ops = %.5f", + mode, opsPerInv, expectedScore, actualScore, + realTime, realOps), Math.abs(1 - actualScore / expectedScore) < TOLERANCE); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 1380a8b0d..72b1ddcdd 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -624,7 +624,7 @@ private void generateThroughput(PrintWriter writer, Mode benchmarkKind, MethodGr writer.println(ident(3) + "res.measuredOps *= opsPerInv;"); writer.println(ident(3) + "res.measuredOps /= batchSize;"); - writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);"); + writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);"); if (isSingleMethod) { writer.println(ident(3) + "results.add(new ThroughputResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } else { @@ -756,7 +756,7 @@ private void generateAverageTime(PrintWriter writer, Mode benchmarkKind, MethodG writer.println(ident(3) + "res.measuredOps *= opsPerInv;"); writer.println(ident(3) + "res.measuredOps /= batchSize;"); - writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);"); + writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);"); if (isSingleMethod) { writer.println(ident(3) + "results.add(new AverageTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.measuredOps, res.getTime(), benchmarkParams.getTimeUnit()));"); } else { @@ -913,7 +913,7 @@ private void generateSampleTime(PrintWriter writer, Mode benchmarkKind, MethodGr writer.println(ident(3) + "res.allOps /= batchSize;"); writer.println(ident(3) + "res.measuredOps *= opsPerInv;"); - writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(res.allOps, res.measuredOps);"); + writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult((long)res.allOps, (long)res.measuredOps);"); if (isSingleMethod) { writer.println(ident(3) + "results.add(new SampleTimeResult(ResultRole.PRIMARY, \"" + method.getName() + "\", buffer, benchmarkParams.getTimeUnit()));"); } else { @@ -1022,7 +1022,7 @@ private void generateSingleShotTime(PrintWriter writer, Mode benchmarkKind, Meth writer.println(ident(3) + "int opsPerInv = control.benchmarkParams.getOpsPerInvocation();"); writer.println(ident(3) + "long totalOps = opsPerInv;"); - writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);"); + writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult((long)totalOps, (long)totalOps);"); if (isSingleMethod) { writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); } else { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/RawResults.java b/jmh-core/src/main/java/org/openjdk/jmh/results/RawResults.java index cd6550600..ab0481267 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/RawResults.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/RawResults.java @@ -26,8 +26,8 @@ public class RawResults { - public long allOps; - public long measuredOps; + public double allOps; + public double measuredOps; public long realTime; public long startTime; public long stopTime; From 3b45b0098344d084cdf6cb97459b5f0b838526af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 8 Dec 2020 19:47:00 +0100 Subject: [PATCH 230/342] 7902807: JMH is unable to compile the benchmark with multiple referenced Benchmark states (#12) --- .../states/dag/doublets/BenchmarkBenchmarkTest.java | 11 ++++++----- .../ct/states/dag/doublets/BenchmarkThreadTest.java | 11 ++++++----- .../ct/states/dag/doublets/ThreadBenchmarkTest.java | 11 ++++++----- .../jmh/ct/states/dag/doublets/ThreadThreadTest.java | 11 ++++++----- .../jmh/generators/core/StateObjectHandler.java | 8 ++++---- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java index 5a8324def..eb3ea76a3 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkBenchmarkTest.java @@ -25,10 +25,7 @@ package org.openjdk.jmh.ct.states.dag.doublets; import org.junit.Test; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class BenchmarkBenchmarkTest { @@ -41,7 +38,11 @@ public static class L { @State(Scope.Benchmark) public static class G { @Setup - public void setup(L l1) { + public void setup(L l1, L l2) { + + } + @TearDown + public void teardown(L l1, L l2) { } } diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java index 48985b940..d7449ffac 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/BenchmarkThreadTest.java @@ -25,10 +25,7 @@ package org.openjdk.jmh.ct.states.dag.doublets; import org.junit.Test; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class BenchmarkThreadTest { @@ -41,7 +38,11 @@ public static class L { @State(Scope.Thread) public static class G { @Setup - public void setup(L l1) { + public void setup(L l1, L l2) { + + } + @TearDown + public void teardown(L l1, L l2) { } } diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java index 0e04ec36e..a2de924bf 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadBenchmarkTest.java @@ -25,10 +25,7 @@ package org.openjdk.jmh.ct.states.dag.doublets; import org.junit.Test; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class ThreadBenchmarkTest { @@ -41,7 +38,11 @@ public static class L { @State(Scope.Benchmark) public static class G { @Setup - public void setup(L l1) { + public void setup(L l1, L l2) { + + } + @TearDown + public void teardown(L l1, L l2) { } } diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java index d53b65b56..280b71615 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/doublets/ThreadThreadTest.java @@ -25,10 +25,7 @@ package org.openjdk.jmh.ct.states.dag.doublets; import org.junit.Test; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.ct.CompileTest; public class ThreadThreadTest { @@ -41,7 +38,11 @@ public static class L { @State(Scope.Thread) public static class G { @Setup - public void setup(L l1) { + public void setup(L l1, L l2) { + + } + @TearDown + public void teardown(L l1, L l2) { } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 2bd35102b..0aa24cde3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -267,12 +267,12 @@ private void resolveDependencies(MethodInfo method, ClassInfo pci, StateObject p specials.put(mi.getQualifiedName(), ci); } else { StateObject so = new StateObject(identifiers, ci, getState(ci, pi).value()); + stateObjects.add(so); - if (!pso.helperArgs.get(mi.getQualifiedName()).contains(so.toLocal())) { - stateObjects.add(so); - pso.depends.add(so); - pso.helperArgs.put(mi.getQualifiedName(), so.toLocal()); + pso.helperArgs.put(mi.getQualifiedName(), so.toLocal()); + if (!pso.depends.contains(so)) { + pso.depends.add(so); bindState(method, so, ci); resolveDependencies(method, ci, so); } From 74685c8bcdb194152dd05ce4fe26e9267a898cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 8 Dec 2020 20:11:09 +0100 Subject: [PATCH 231/342] 7902809: Remove prerequisites tag in favor of maven-enforcer-plugin (#14) --- pom.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 3d0945324..b00e0436d 100644 --- a/pom.xml +++ b/pom.xml @@ -157,7 +157,7 @@ questions. - 3.0 + 3.2 @@ -286,10 +286,6 @@ questions. - - 3.2 - - jmh-core jmh-core-it From 2d041779966daa5a1e0d4dfca3821b1fc746940a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 8 Dec 2020 20:49:14 +0100 Subject: [PATCH 232/342] 7902805: State cycle validation should be more resilient (#15) --- .../cycles/NoDoubleUseCycleBenchmarkTest.java | 59 ++++++++++++++++ .../cycles/NoDoubleUseCycleThreadTest.java | 59 ++++++++++++++++ .../generators/core/StateObjectHandler.java | 67 +++++++++++++------ 3 files changed, 166 insertions(+), 19 deletions(-) create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/NoDoubleUseCycleBenchmarkTest.java create mode 100644 jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/NoDoubleUseCycleThreadTest.java diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/NoDoubleUseCycleBenchmarkTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/NoDoubleUseCycleBenchmarkTest.java new file mode 100644 index 000000000..df00b6343 --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/NoDoubleUseCycleBenchmarkTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.cycles; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.ct.CompileTest; + +public class NoDoubleUseCycleBenchmarkTest { + + @State(Scope.Benchmark) + public static class B { + } + + @State(Scope.Benchmark) + public static class A { + @Setup + public void setup(B b1, B b2) { + + } + @TearDown + public void teardown(B b1, B b2) { + + } + } + + @Benchmark + public void test(A a1, A a2) { + + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/NoDoubleUseCycleThreadTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/NoDoubleUseCycleThreadTest.java new file mode 100644 index 000000000..51d96952a --- /dev/null +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/states/dag/cycles/NoDoubleUseCycleThreadTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.ct.states.dag.cycles; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.ct.CompileTest; + +public class NoDoubleUseCycleThreadTest { + + @State(Scope.Thread) + public static class B { + } + + @State(Scope.Thread) + public static class A { + @Setup + public void setup(B b1, B b2) { + + } + @TearDown + public void teardown(B b1, B b2) { + + } + } + + @Benchmark + public void test(A a1, A a2) { + + } + + @Test + public void compileTest() { + CompileTest.assertOK(this.getClass()); + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 0aa24cde3..86b0edf34 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -219,39 +219,68 @@ public void bindMethods(ClassInfo holder, MethodGroup mg) { } public static void validateNoCycles(MethodInfo method) { - try { - validateNoCyclesStep(Collections.emptyList(), method, true); - } catch (StackOverflowError e) { - // "YOLO Engineering" - throw new GenerationException("@" + State.class.getSimpleName() + - " dependency cycle is detected.", method); - } + validateNoCyclesStep(Collections.emptySet(), method, true); } - private static void validateNoCyclesStep(List states, MethodInfo method, boolean includeHolder) { - List stratum = new ArrayList<>(); + private static void validateNoCyclesStep(Set alreadySeen, MethodInfo method, boolean includeHolder) { + // Collect and check outgoing edges + Set outgoing = new HashSet<>(); if (includeHolder) { - stratum.add(method.getDeclaringClass()); + outgoing.add(new ClassQName(method.getDeclaringClass())); } for (ParameterInfo ppi : method.getParameters()) { - stratum.add(ppi.getType()); + outgoing.add(new ClassQName(ppi.getType())); } - - List newStates = new ArrayList<>(); - newStates.addAll(states); - for (ClassInfo ci : stratum) { - newStates.add(ci.getQualifiedName()); + if (outgoing.isEmpty()) { + // No outgoing edges, checks complete. + return; } - for (ClassInfo ci : stratum) { - for (MethodInfo mi : BenchmarkGeneratorUtils.getMethods(ci)) { + Set currentSeen = new HashSet<>(); + currentSeen.addAll(alreadySeen); + + for (ClassQName ci : outgoing) { + // Try see if we have already seen these edges for current method. + // If so, this is a dependency cycle. + if (!currentSeen.add(ci)) { + throw new GenerationException("@" + State.class.getSimpleName() + + " dependency cycle is detected: " + ci.ci.getQualifiedName() + " " + currentSeen, method); + } + + // For each fixture method that needs the state, see if we need to initialize those as well. + // Restart the search from already seen + the outgoing edge. + Set nextSeen = new HashSet<>(); + nextSeen.addAll(alreadySeen); + nextSeen.add(ci); + for (MethodInfo mi : BenchmarkGeneratorUtils.getMethods(ci.ci)) { if (mi.getAnnotation(Setup.class) != null || mi.getAnnotation(TearDown.class) != null) { - validateNoCyclesStep(newStates, mi, false); + validateNoCyclesStep(nextSeen, mi, false); } } } } + private static class ClassQName { + private final ClassInfo ci; + + private ClassQName(ClassInfo ci) { + this.ci = ci; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ClassQName cycleInfo = (ClassQName) o; + return Objects.equals(ci.getQualifiedName(), cycleInfo.ci.getQualifiedName()); + } + + @Override + public int hashCode() { + return Objects.hash(ci.getQualifiedName()); + } + } + /** * Recursively resolve if there are any other states referenced through helper methods. */ From fe1857e18b1bd78837ef114c8a493002b0c0900f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 8 Dec 2020 21:16:46 +0100 Subject: [PATCH 233/342] 7902762: JMH: Enable experimental use of "blackhole" compiler command (#8) --- .../benchmarks/BlackholeConsecutiveBench.java | 58 +++++------- .../java/org/openjdk/jmh/validation/Main.java | 59 ++++++++++--- .../jmh/validation/ValidationTest.java | 52 ++++++++++- .../tests/BlackholeConsecutiveTest.java | 20 ++--- .../tests/BlackholeConsumeCPUTest.java | 2 +- .../tests/BlackholePipelinedTest.java | 21 ++--- .../validation/tests/BlackholeSingleTest.java | 2 +- .../validation/tests/BlackholeTestMode.java | 32 +++++++ .../validation/tests/CompilerHintsTest.java | 2 +- .../validation/tests/HelperMethodsTest.java | 2 +- .../validation/tests/ScoreStabilityTest.java | 2 +- .../validation/tests/ThermalRundownTest.java | 2 +- .../validation/tests/ThreadScalingTest.java | 2 +- .../tests/TimingMeasurementsTest.java | 2 +- .../org/openjdk/jmh/runner/CompilerHints.java | 88 +++++++++++++++++-- .../jmh/runner/format/TextReportFormat.java | 3 + 16 files changed, 250 insertions(+), 99 deletions(-) create mode 100644 jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeTestMode.java diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeConsecutiveBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeConsecutiveBench.java index f2698ebfe..d1e643461 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeConsecutiveBench.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BlackholeConsecutiveBench.java @@ -247,54 +247,36 @@ public void test_double_8(Blackhole bh) { @Benchmark public void test_Object_1(Blackhole bh) { - bh.consume(Double.valueOf(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); } @Benchmark public void test_Object_4(Blackhole bh) { - bh.consume(Double.valueOf(x / y + 1331)); - bh.consume(Double.valueOf(x / y + 1331)); - bh.consume(Double.valueOf(x / y + 1331)); - bh.consume(Double.valueOf(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); } @Benchmark public void test_Object_8(Blackhole bh) { - bh.consume(Double.valueOf(x / y + 1331)); - bh.consume(Double.valueOf(x / y + 1331)); - bh.consume(Double.valueOf(x / y + 1331)); - bh.consume(Double.valueOf(x / y + 1331)); - - bh.consume(Double.valueOf(x / y + 1331)); - bh.consume(Double.valueOf(x / y + 1331)); - bh.consume(Double.valueOf(x / y + 1331)); - bh.consume(Double.valueOf(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); + + bh.consume(cachedObject(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); + bh.consume(cachedObject(x / y + 1331)); } - @Benchmark - public void test_Array_1(Blackhole bh) { - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - } - - @Benchmark - public void test_Array_4(Blackhole bh) { - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - } - - @Benchmark - public void test_Array_8(Blackhole bh) { - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); - bh.consume(new Double[]{Double.valueOf(x / y + 1331)}); + private Object cachedObject(int v) { + if (v == 4242/1414 + 1331) { + return 42; + } else { + return v; + } } } diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java index 8f09058d7..d5cf26255 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java @@ -28,6 +28,7 @@ import org.openjdk.jmh.runner.CompilerHints; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.*; +import org.openjdk.jmh.util.JDKVersion; import org.openjdk.jmh.util.Utils; import org.openjdk.jmh.util.Version; import org.openjdk.jmh.validation.tests.*; @@ -153,6 +154,8 @@ public static void main(String[] args) throws RunnerException, CommandLineOption throw new IllegalStateException(); } + boolean testCompilerBlackhole = JDKVersion.parseMajor(System.getProperty("java.version")) >= 16; + for (Test t : tests) { switch (t) { case timing: @@ -195,20 +198,34 @@ public static void main(String[] args) throws RunnerException, CommandLineOption new BlackholeSingleTest().runWith(pw, opts); break; case blackhole_pipelined: - setBlackholeInline(false); - new BlackholePipelinedTest(false, false).runWith(pw, opts); - new BlackholePipelinedTest(true, false).runWith(pw, opts); - setBlackholeInline(true); - new BlackholePipelinedTest(false, true).runWith(pw, opts); - new BlackholePipelinedTest(true, true).runWith(pw, opts); - setBlackholeInline(false); + setBlackholeOpts(BlackholeTestMode.normal); + new BlackholePipelinedTest(false, BlackholeTestMode.normal).runWith(pw, opts); + new BlackholePipelinedTest(true, BlackholeTestMode.normal).runWith(pw, opts); + if (testCompilerBlackhole) { + setBlackholeOpts(BlackholeTestMode.compiler); + new BlackholePipelinedTest(false, BlackholeTestMode.compiler).runWith(pw, opts); + new BlackholePipelinedTest(true, BlackholeTestMode.compiler).runWith(pw, opts); + } + setBlackholeOpts(BlackholeTestMode.full_dontinline); + new BlackholePipelinedTest(false, BlackholeTestMode.full_dontinline).runWith(pw, opts); + new BlackholePipelinedTest(true, BlackholeTestMode.full_dontinline).runWith(pw, opts); + setBlackholeOpts(BlackholeTestMode.full); + new BlackholePipelinedTest(false, BlackholeTestMode.full).runWith(pw, opts); + new BlackholePipelinedTest(true, BlackholeTestMode.full).runWith(pw, opts); + setBlackholeOpts(BlackholeTestMode.normal); break; case blackhole_consec: - setBlackholeInline(false); - new BlackholeConsecutiveTest(false).runWith(pw, opts); - setBlackholeInline(true); - new BlackholeConsecutiveTest(true).runWith(pw, opts); - setBlackholeInline(false); + setBlackholeOpts(BlackholeTestMode.normal); + new BlackholeConsecutiveTest(BlackholeTestMode.normal).runWith(pw, opts); + if (testCompilerBlackhole) { + setBlackholeOpts(BlackholeTestMode.compiler); + new BlackholeConsecutiveTest(BlackholeTestMode.compiler).runWith(pw, opts); + } + setBlackholeOpts(BlackholeTestMode.full_dontinline); + new BlackholeConsecutiveTest(BlackholeTestMode.full_dontinline).runWith(pw, opts); + setBlackholeOpts(BlackholeTestMode.full); + new BlackholeConsecutiveTest(BlackholeTestMode.full).runWith(pw, opts); + setBlackholeOpts(BlackholeTestMode.normal); break; default: throw new IllegalStateException(); @@ -236,8 +253,22 @@ public enum Mode { longer, } - private static void setBlackholeInline(boolean inline) { - System.getProperties().setProperty("jmh.blackhole.forceInline", String.valueOf(inline)); + private static void setBlackholeOpts(BlackholeTestMode mode) { + switch (mode) { + case normal: + // Do nothing + System.getProperties().remove("jmh.blackhole.mode"); + break; + case compiler: + System.getProperties().setProperty("jmh.blackhole.mode", "COMPILER"); + break; + case full_dontinline: + System.getProperties().setProperty("jmh.blackhole.mode", "FULL_DONTINLINE"); + break; + case full: + System.getProperties().setProperty("jmh.blackhole.mode", "FULL"); + break; + } try { Field f = CompilerHints.class.getDeclaredField("hintsFile"); diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/ValidationTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/ValidationTest.java index 309787063..5c9fc33c3 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/ValidationTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/ValidationTest.java @@ -26,11 +26,59 @@ import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.validation.tests.BlackholeTestMode; import java.io.PrintWriter; -public interface ValidationTest { +public abstract class ValidationTest { - void runWith(PrintWriter pw, Options parent) throws RunnerException; + public abstract void runWith(PrintWriter pw, Options parent) throws RunnerException; + + protected String blackholeModeString(BlackholeTestMode mode) { + switch (mode) { + case normal: + return "DEFAULT"; + case compiler: + return "COMPILER BLACKHOLE"; + case full_dontinline: + return "FULL BLACKHOLE, NO INLINE"; + case full: + return "FULL BLACKHOLE"; + default: + throw new IllegalStateException("Unknown blackhole mode: " + mode); + } + } + + protected void blackholeModeMessage(PrintWriter pw, BlackholeTestMode mode) { + switch (mode) { + case normal: + break; + case compiler: + org.openjdk.jmh.util.Utils.reflow(pw, + "This particular test mode enables the compiler-assisted blackholes. " + + "It should provide the most consistent performance across all types. " + + "This mode is only available in modern JDKs.", + 80, 2); + pw.println(); + break; + case full_dontinline: + org.openjdk.jmh.util.Utils.reflow(pw, + "This particular test mode omits the compiler-assisted blackholes. " + + "It should provide the basic level of safety for all JDKs.", + 80, 2); + pw.println(); + break; + case full: + org.openjdk.jmh.util.Utils.reflow(pw, + "This particular test mode forces the inline of Blackhole methods, and so demolishes two of the layers " + + "in defence in depth. If this layer is broken, Blackhole should also survive. If it isn't, then " + + "JMH will have to provide more contingencies.", + 80, 2); + pw.println(); + break; + default: + throw new IllegalStateException("Unknown blackhole mode: " + mode); + } + } } diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsecutiveTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsecutiveTest.java index 9f367d66f..8603a6aa6 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsecutiveTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsecutiveTest.java @@ -37,16 +37,16 @@ import java.io.PrintWriter; import java.util.Arrays; -public class BlackholeConsecutiveTest implements ValidationTest { - private final boolean inlined; +public class BlackholeConsecutiveTest extends ValidationTest { + private final BlackholeTestMode mode; - public BlackholeConsecutiveTest(boolean inlined) { - this.inlined = inlined; + public BlackholeConsecutiveTest(BlackholeTestMode mode) { + this.mode = mode; } @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { - pw.println("--------- BLACKHOLE MERGING TEST" + (!inlined ? " (NORMAL)" : " (INLINE HINTS BROKEN)")); + pw.println("--------- BLACKHOLE MERGING TEST (" + blackholeModeString(mode) + ")"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, @@ -57,20 +57,12 @@ public void runWith(PrintWriter pw, Options parent) throws RunnerException { 80, 2); pw.println(); - if (inlined) { - org.openjdk.jmh.util.Utils.reflow(pw, - "This particular test mode forces the inline of Blackhole methods, and so demolishes one of the layers " + - "in defence in depth. If this layer is broken, Blackhole should also survive. If it isn't, then " + - "JMH will have to provide more contingencies.", - 80, 2); - pw.println(); - } + blackholeModeMessage(pw, mode); String[] types = new String[] { "boolean", "byte", "short", "char", "int", "float", "long", "double", "Object", - "Array", }; int[] ss = new int[] {1, 4, 8}; diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsumeCPUTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsumeCPUTest.java index 550f806dc..fc0902abc 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsumeCPUTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeConsumeCPUTest.java @@ -36,7 +36,7 @@ import java.io.PrintWriter; -public class BlackholeConsumeCPUTest implements ValidationTest { +public class BlackholeConsumeCPUTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- BLACKHOLE CONSUME CPU TEST"); diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholePipelinedTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholePipelinedTest.java index 070d7b424..1102ac8fd 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholePipelinedTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholePipelinedTest.java @@ -38,18 +38,18 @@ import java.io.PrintWriter; import java.util.Arrays; -public class BlackholePipelinedTest implements ValidationTest { +public class BlackholePipelinedTest extends ValidationTest { private final boolean payload; - private final boolean inlined; + private final BlackholeTestMode mode; - public BlackholePipelinedTest(boolean payload, boolean inlined) { + public BlackholePipelinedTest(boolean payload, BlackholeTestMode mode) { this.payload = payload; - this.inlined = inlined; + this.mode = mode; } @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { - pw.println("--------- BLACKHOLE PIPELINED TEST" + (payload ? " + REAL PAYLOAD" : "") + (!inlined ? " (NORMAL)" : " (INLINE HINTS BROKEN)")); + pw.println("--------- BLACKHOLE PIPELINED TEST" + (payload ? " + REAL PAYLOAD" : "") + " (" + blackholeModeString(mode) + ")"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, @@ -64,15 +64,8 @@ public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println(" Real payload is being injected into the benchmark."); pw.println(); } - if (inlined) { - org.openjdk.jmh.util.Utils.reflow(pw, - "This particular test mode forces the inline of Blackhole methods, and so demolishes one of the layers " + - "in defence in depth. If this layer is broken, Blackhole should also survive. If it isn't, then " + - "JMH will have to provide more contingencies.", - 80, 2); - pw.println(); - } - pw.println(); + + blackholeModeMessage(pw, mode); String[] types = new String[] { "boolean", "byte", "short", diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeSingleTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeSingleTest.java index 039216b7f..c4007d9f7 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeSingleTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeSingleTest.java @@ -36,7 +36,7 @@ import java.io.PrintWriter; -public class BlackholeSingleTest implements ValidationTest { +public class BlackholeSingleTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- BLACKHOLE SINGLE INVOCATION TEST"); diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeTestMode.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeTestMode.java new file mode 100644 index 000000000..948dea02d --- /dev/null +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeTestMode.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.validation.tests; + +public enum BlackholeTestMode { + normal, + compiler, + full_dontinline, + full, +} diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CompilerHintsTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CompilerHintsTest.java index 85891ebcb..1e066b8d8 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CompilerHintsTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CompilerHintsTest.java @@ -37,7 +37,7 @@ import java.io.PrintWriter; -public class CompilerHintsTest implements ValidationTest { +public class CompilerHintsTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- COMPILER HINTS TEST"); diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/HelperMethodsTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/HelperMethodsTest.java index ea03f38fb..23fc077d8 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/HelperMethodsTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/HelperMethodsTest.java @@ -38,7 +38,7 @@ import java.io.PrintWriter; -public class HelperMethodsTest implements ValidationTest { +public class HelperMethodsTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ScoreStabilityTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ScoreStabilityTest.java index 671e442bd..508d9b85d 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ScoreStabilityTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ScoreStabilityTest.java @@ -37,7 +37,7 @@ import java.io.PrintWriter; -public class ScoreStabilityTest implements ValidationTest { +public class ScoreStabilityTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- SCORE STABILITY TEST"); diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java index 1f2b5f6d4..048129a7f 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThermalRundownTest.java @@ -37,7 +37,7 @@ import java.io.PrintWriter; -public class ThermalRundownTest implements ValidationTest { +public class ThermalRundownTest extends ValidationTest { private final int iterations; diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThreadScalingTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThreadScalingTest.java index 0d25472d5..1f0d7a13c 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThreadScalingTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ThreadScalingTest.java @@ -40,7 +40,7 @@ import java.util.SortedSet; import java.util.TreeSet; -public class ThreadScalingTest implements ValidationTest { +public class ThreadScalingTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- THREAD SCALING TEST"); diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/TimingMeasurementsTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/TimingMeasurementsTest.java index b3f441794..1414bf5b3 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/TimingMeasurementsTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/TimingMeasurementsTest.java @@ -40,7 +40,7 @@ import java.io.PrintWriter; -public class TimingMeasurementsTest implements ValidationTest { +public class TimingMeasurementsTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { pw.println("--------- TIMING MEASUREMENTS TEST"); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java index 3e7db5939..3709cdedf 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java @@ -25,11 +25,9 @@ package org.openjdk.jmh.runner; import org.openjdk.jmh.util.FileUtils; +import org.openjdk.jmh.util.JDKVersion; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.Reader; +import java.io.*; import java.util.*; public class CompilerHints extends AbstractResourceReader { @@ -44,11 +42,12 @@ public class CompilerHints extends AbstractResourceReader { private static volatile CompilerHints defaultList; private static volatile String hintsFile; - private final Set hints; static final String XX_COMPILE_COMMAND_FILE = "-XX:CompileCommandFile="; + static final String BLACKHOLE_PROP_NAME = "jmh.blackhole.mode"; + public static CompilerHints defaultList() { if (defaultList == null) { defaultList = fromResource(LIST); @@ -62,11 +61,14 @@ public static String hintsFile() { final Set defaultHints = defaultList().get(); List hints = new ArrayList<>(defaultHints.size() + 2); hints.add("quiet"); - if (Boolean.getBoolean("jmh.blackhole.forceInline")) { - hints.add("inline,org/openjdk/jmh/infra/Blackhole.*"); - } else { - hints.add("dontinline,org/openjdk/jmh/infra/Blackhole.*"); + BlackholeMode bhMode = blackholeMode(); + if (bhMode.shouldBlackhole()) { + hints.add("blackhole,org/openjdk/jmh/infra/Blackhole.consume"); } + if (bhMode.shouldNotInline()) { + hints.add("dontinline,org/openjdk/jmh/infra/Blackhole.consume"); + } + hints.add("dontinline,org/openjdk/jmh/infra/Blackhole.consumeCPU"); hints.addAll(defaultHints); hintsFile = FileUtils.createTempFileWithLines("compilecommand", hints); } catch (IOException e) { @@ -192,6 +194,11 @@ public static void addCompilerHints(List command) { hintFiles.add(hotspotCompilerFile.getAbsolutePath()); } } + + if (needsDiagnosticUnlock()) { + command.add("-XX:+UnlockDiagnosticVMOptions"); + } + command.add(CompilerHints.XX_COMPILE_COMMAND_FILE + mergeHintFiles(hintFiles)); } @@ -224,4 +231,67 @@ private static String mergeHintFiles(List compileCommandFiles) { throw new IllegalStateException("Error merging compiler hints files", e); } } + + private static BlackholeMode blackholeMode() { + String prop = System.getProperty(BLACKHOLE_PROP_NAME); + if (prop != null) { + try { + return BlackholeMode.valueOf(prop); + } catch (IllegalArgumentException iae) { + throw new IllegalStateException("Unknown Blackhole mode: " + prop); + } + } + return BlackholeMode.FULL_DONTINLINE; + } + + public static void printBlackholeMode(PrintStream out) { + BlackholeMode mode = blackholeMode(); + out.print("# JMH blackhole mode: " + mode.desc()); + + // Experimental: since JDK 16, Compiler blackholing is available. + // Tell user they can enable it explicitly. We need to consider enabling + // this by default when JDK 16 stabilizes. + if (!mode.shouldBlackhole() && compilerBlackholeAvailable()) { + out.print("; set -D" + BLACKHOLE_PROP_NAME + "=" + BlackholeMode.COMPILER.name() + " to get compiler-assisted ones"); + } + + out.println(); + } + + private static boolean compilerBlackholeAvailable() { + // See https://bugs.openjdk.java.net/browse/JDK-8252505. + return JDKVersion.parseMajor(System.getProperty("java.version")) >= 16; + } + + private static boolean needsDiagnosticUnlock() { + return blackholeMode() == BlackholeMode.COMPILER; + } + + private enum BlackholeMode { + COMPILER(true, false, "compiler-assisted blackhole"), + FULL_DONTINLINE(false, true, "full blackhole + dont-inline hint"), + FULL(false, false, "full blackhole"), + ; + + private final boolean shouldBlackhole; + private final boolean shouldNotInline; + private final String desc; + + BlackholeMode(boolean shouldBlackhole, boolean shouldNotInline, String desc) { + this.shouldBlackhole = shouldBlackhole; + this.shouldNotInline = shouldNotInline; + this.desc = desc; + } + + public boolean shouldBlackhole() { + return shouldBlackhole; + } + + public boolean shouldNotInline() { + return shouldNotInline; + } + + public String desc() { return desc; } + } + } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index 44c45ba6c..33b7b58c6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -33,6 +33,7 @@ import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.results.format.ResultFormatFactory; import org.openjdk.jmh.results.format.ResultFormatType; +import org.openjdk.jmh.runner.CompilerHints; import org.openjdk.jmh.runner.IterationType; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.runner.options.VerboseMode; @@ -80,6 +81,8 @@ public void startBenchmark(BenchmarkParams params) { println("# VM invoker: " + params.getJvm()); println("# VM options: " + opts); + CompilerHints.printBlackholeMode(out); + IterationParams warmup = params.getWarmup(); if (warmup.getCount() > 0) { out.println("# Warmup: " + warmup.getCount() + " iterations, " + From 267846d82c4dcf47bf6f0140a8ebb1e7d1bad4b9 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Wed, 9 Dec 2020 08:09:02 +0000 Subject: [PATCH 234/342] 7902799: perfasm still handles event modifiers incorrectly Co-authored-by: Aleksey Shipilev Reviewed-by: shade --- .../jmh/profile/AbstractPerfAsmProfiler.java | 60 ++++++++++++------- .../jmh/profile/DTraceAsmProfiler.java | 6 +- .../jmh/profile/LinuxPerfAsmProfiler.java | 26 +++++++- .../jmh/profile/WinPerfAsmProfiler.java | 6 +- .../openjdk/jmh/profile/PerfParseTest.java | 16 +++++ 5 files changed, 83 insertions(+), 31 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index f1cdca4eb..bb41e3fa2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -39,7 +39,7 @@ public abstract class AbstractPerfAsmProfiler implements ExternalProfiler { - protected final List events; + protected final List requestedEventNames; private final double regionRateThreshold; private final int regionShowTop; @@ -198,7 +198,7 @@ protected AbstractPerfAsmProfiler(String initLine, String... events) throws Prof set = ProfilerUtils.parseInitLine(initLine, parser); try { - this.events = set.valuesOf(optEvents); + requestedEventNames = set.valuesOf(optEvents); regionRateThreshold = set.valueOf(optThresholdRate); regionShowTop = set.valueOf(optShowTop); regionTooBigThreshold = set.valueOf(optThreshold); @@ -310,6 +310,16 @@ public boolean allowPrintErr() { */ protected abstract PerfEvents readEvents(double skipMs, double lenMs); + /** + * Some profilers strip modifiers from event names. + * To properly match the events in shared code, we need to know + * what those events were stripped to. + * @return stripped events + */ + protected List stripEventNames(List src) { + return src; + } + /** * Get perf binary data extension (optional). * @@ -367,12 +377,17 @@ private TextResult processAssembly(BenchmarkResult br) { } final PerfEvents events = readEvents(skipMs, lenMs); + List evNames = stripEventNames(requestedEventNames); if (!events.isEmpty()) { pw.printf("Perf output processed (skipped %.3f seconds):%n", skipMs / 1000D); int cnt = 1; - for (String event : this.events) { - pw.printf(" Column %d: %s (%d events)%n", cnt, event, events.get(event).size()); + for (int i = 0; i < evNames.size(); i++) { + String stripped = evNames.get(i); + String requested = requestedEventNames.get(i); + pw.printf(" Column %d: %s%s (%d events)%n", cnt, + stripped, (requested.equals(stripped) ? "" : " (" + requested + ")"), + events.get(stripped).size()); cnt++; } pw.println(); @@ -394,7 +409,7 @@ private TextResult processAssembly(BenchmarkResult br) { * We would sort the regions by the hotness of the first (main) event type. */ - final String mainEvent = this.events.get(0); + final String mainEvent = evNames.get(0); Collections.sort(regions, new Comparator() { @Override @@ -421,7 +436,7 @@ public int compare(Region o1, Region o2) { r.printCode(pw, events); printDottedLine(pw); - for (String event : this.events) { + for (String event : evNames) { printLine(pw, events, event, r.getEventCount(events, event)); } pw.println(""); @@ -452,29 +467,29 @@ public int compare(Region o1, Region o2) { int shown = 0; for (Region r : regions) { if (shown++ < regionShowTop) { - for (String event : this.events) { + for (String event : evNames) { printLine(pw, events, event, r.getEventCount(events, event)); } pw.printf("%" + lenSource + "s %s (%d bytes) %n", r.desc().source(), r.desc().name(), r.end - r.begin); } else { - for (String event : this.events) { + for (String event : evNames) { other.add(event, r.getEventCount(events, event)); } } - for (String event : this.events) { + for (String event : evNames) { total.add(event, r.getEventCount(events, event)); } } if (regions.size() - regionShowTop > 0) { - for (String event : this.events) { + for (String event : evNames) { printLine(pw, events, event, other.count(event)); } pw.println("<...other " + (regions.size() - regionShowTop) + " warm regions...>"); } printDottedLine(pw); - for (String event : this.events) { + for (String event : evNames) { printLine(pw, events, event, total.count(event)); } pw.println(""); @@ -484,13 +499,13 @@ public int compare(Region o1, Region o2) { final Map> methodsByType = new HashMap<>(); final Map> methods = new HashMap<>(); - for (String event : this.events) { + for (String event : evNames) { methodsByType.put(event, new HashMultiset()); methods.put(event, new HashMultiset()); } for (Region r : regions) { - for (String event : this.events) { + for (String event : evNames) { long count = r.getEventCount(events, event); methods.get(event).add(r.desc(), count); methodsByType.get(event).add(r.desc().source(), count); @@ -510,29 +525,29 @@ public int compare(Region o1, Region o2) { List top = Multisets.sortedDesc(methods.get(mainEvent)); for (MethodDesc m : top) { if (shownMethods++ < regionShowTop) { - for (String event : this.events) { + for (String event : evNames) { printLine(pw, events, event, methods.get(event).count(m)); } pw.printf("%" + lenSource + "s %s %n", m.source(), m.name()); } else { - for (String event : this.events) { + for (String event : evNames) { other.add(event, methods.get(event).count(m)); } } - for (String event : this.events) { + for (String event : evNames) { total.add(event, methods.get(event).count(m)); } } if (top.size() - regionShowTop > 0) { - for (String event : this.events) { + for (String event : evNames) { printLine(pw, events, event, other.count(event)); } pw.println("<...other " + (top.size() - regionShowTop) + " warm methods...>"); } printDottedLine(pw); - for (String event : this.events) { + for (String event : evNames) { printLine(pw, events, event, total.count(event)); } pw.println(""); @@ -546,7 +561,7 @@ public int compare(Region o1, Region o2) { printDottedLine(pw, "Distribution by Source"); for (String m : Multisets.sortedDesc(methodsByType.get(mainEvent))) { - for (String event : this.events) { + for (String event : evNames) { printLine(pw, events, event, methodsByType.get(event).count(m)); } pw.printf("%" + lenSource + "s%n", m); @@ -554,7 +569,7 @@ public int compare(Region o1, Region o2) { printDottedLine(pw); - for (String event : this.events) { + for (String event : evNames) { printLine(pw, events, event, methodsByType.get(event).size()); } @@ -633,7 +648,7 @@ public int compare(Region o1, Region o2) { try (FileOutputStream asm = new FileOutputStream(target); PrintWriter pwAsm = new PrintWriter(asm)) { for (ASMLine line : assembly.lines) { - for (String event : this.events) { + for (String event : evNames) { long count = (line.addr != null) ? events.get(event).count(line.addr) : 0; printLine(pwAsm, events, event, count); } @@ -681,6 +696,7 @@ private void printDottedLine(PrintWriter pw, String header) { } private List makeRegions(Assembly asms, PerfEvents events) { + List strippedEvents = stripEventNames(requestedEventNames); List regions = new ArrayList<>(); SortedSet allAddrs = events.getAllAddresses(); @@ -698,7 +714,7 @@ private List makeRegions(Assembly asms, PerfEvents events) { desc = MethodDesc.unknown(); } - regions.add(new GeneratedRegion(this.events, asms, desc, intv.src, intv.dst, + regions.add(new GeneratedRegion(strippedEvents, asms, desc, intv.src, intv.dst, regionLines, eventfulAddrs, regionTooBigThreshold, drawIntraJumps, drawInterJumps)); } else { // has no assembly, should be a native region diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java index f8cf6bbf3..34f67941a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java @@ -205,9 +205,9 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { } Map> allEvents = new TreeMap<>(); - assert this.events.size() == 1; - allEvents.put(this.events.get(0), events); - return new PerfEvents(this.events, allEvents, methodMap); + assert requestedEventNames.size() == 1; + allEvents.put(requestedEventNames.get(0), events); + return new PerfEvents(requestedEventNames, allEvents, methodMap); } catch (IOException e) { throw new RuntimeException(e); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index cf2eb1a55..8445e21e5 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -67,7 +67,7 @@ protected void addMyOptions(OptionParser parser) { @Override public Collection addJVMInvokeOptions(BenchmarkParams params) { - return Arrays.asList(PerfSupport.PERF_EXEC, "record", "--freq", String.valueOf(sampleFrequency), "--event", Utils.join(events, ","), "--output", perfBinData.getAbsolutePath()); + return Arrays.asList(PerfSupport.PERF_EXEC, "record", "--freq", String.valueOf(sampleFrequency), "--event", Utils.join(requestedEventNames, ","), "--output", perfBinData.getAbsolutePath()); } @Override @@ -218,13 +218,15 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { double readFrom = skipMs / 1000D; double readTo = (skipMs + lenMs) / 1000D; + List evNames = stripEventNames(requestedEventNames); + try (FileReader fr = new FileReader(perfParsedData.file()); BufferedReader reader = new BufferedReader(fr)) { Deduplicator dedup = new Deduplicator<>(); Multimap methods = new HashMultimap<>(); Map> events = new LinkedHashMap<>(); - for (String evName : this.events) { + for (String evName : evNames) { events.put(evName, new TreeMultiset()); } @@ -265,7 +267,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { methodMap.add(md, Utils.min(addrs), Utils.max(addrs)); } - return new PerfEvents(this.events, events, methodMap); + return new PerfEvents(evNames, events, methodMap); } catch (IOException e) { throw new RuntimeException(e); } @@ -276,4 +278,22 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { protected String perfBinaryExtension() { return ".perfbin"; } + + @Override + protected List stripEventNames(List events) { + return stripPerfEventNames(events); + } + + static List stripPerfEventNames(List events) { + List res = new ArrayList<>(); + for (String ev : events) { + int tagIdx = ev.indexOf(':'); + if (tagIdx != -1) { + res.add(ev.substring(0, tagIdx)); + } else { + res.add(ev); + } + } + return res; + } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java index 4eeb6ed5e..38b97bb44 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/WinPerfAsmProfiler.java @@ -199,7 +199,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { Multimap methods = new HashMultimap<>(); Map> events = new LinkedHashMap<>(); - for (String evName : this.events) { + for (String evName : requestedEventNames) { events.put(evName, new TreeMultiset()); } @@ -212,7 +212,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { String evName = elems[0].trim(); // We work with only one event type - "SampledProfile". - if (!this.events.get(0).equals(evName)) + if (!requestedEventNames.get(0).equals(evName)) continue; // Check PID. @@ -269,7 +269,7 @@ protected PerfEvents readEvents(double skipMs, double lenMs) { methodMap.add(md, Utils.min(longs), Utils.max(longs)); } - return new PerfEvents(this.events, events, methodMap); + return new PerfEvents(requestedEventNames, events, methodMap); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java b/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java index 86aac3f56..6131de813 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java @@ -27,6 +27,9 @@ import junit.framework.Assert; import org.junit.Test; +import java.util.ArrayList; +import java.util.List; + public class PerfParseTest { @Test @@ -83,5 +86,18 @@ public void parseOptionalTag() { } } + @Test + public void stripEvents() { + List list = new ArrayList<>(); + list.add("cycles"); + list.add("instructions:u:"); + list.add("branches:pppu:"); + + List stripped = LinuxPerfAsmProfiler.stripPerfEventNames(list); + + Assert.assertEquals("cycles", stripped.get(0)); + Assert.assertEquals("instructions", stripped.get(1)); + Assert.assertEquals("branches", stripped.get(2)); + } } From 562246eab01941eac0e716404e7b15c7325c0941 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 9 Dec 2020 12:35:01 +0100 Subject: [PATCH 235/342] JMH v1.27. --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 126951a7a..99f13e617 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.27-SNAPSHOT + 1.27 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 10806fe52..50fb23788 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.27-SNAPSHOT + 1.27 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 1a122f9da..cbda814da 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.27-SNAPSHOT + 1.27 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 489733eeb..1e08e8d95 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.27-SNAPSHOT + 1.27 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 046461c1f..f65a0f0bc 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 174190040..6dd5c0a38 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index f233abfcf..7370256b2 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index b734960e4..91b9dbaaa 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 3c8076f65..5d13600a7 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 762e19624..5fd9e0252 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 5da696fad..862a7a930 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index f8ab68029..c57275204 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index e1832cd9a..b28d7caa2 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 77d771226..fafe46ea2 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.27-SNAPSHOT + 1.27 JMH Samples diff --git a/pom.xml b/pom.xml index b00e0436d..be1982a3a 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.27-SNAPSHOT + 1.27 Java Microbenchmark Harness Parent From 638660028ce4dc4cd886b5b21a29d050b35da796 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 9 Dec 2020 12:35:34 +0100 Subject: [PATCH 236/342] Continue in 1.28-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 99f13e617..82510a35d 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.27 + 1.28-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 50fb23788..ecbeb76e9 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.27 + 1.28-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index cbda814da..a24048ecf 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.27 + 1.28-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 1e08e8d95..fea9f6987 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.27 + 1.28-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index f65a0f0bc..8d6a8b311 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 6dd5c0a38..6e415e3ad 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 7370256b2..eabcfef1e 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 91b9dbaaa..fba81d408 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 5d13600a7..bc253c5dd 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 5fd9e0252..58620c1e3 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 862a7a930..32f124ebf 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index c57275204..d03314da1 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index b28d7caa2..45e180955 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index fafe46ea2..cd053930c 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.27 + 1.28-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index be1982a3a..787aeec4a 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.27 + 1.28-SNAPSHOT Java Microbenchmark Harness Parent From 2354a38e5733df0fbca79b4eac041ec31dc0a1d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 7 Jan 2021 12:26:19 +0100 Subject: [PATCH 237/342] CODETOOLS-7902818: JMH: Remove Hotspot-specific MBeans profilers (#17) --- .../HotspotClassloadingProfilerTest.java | 53 ----- .../HotspotCompilationProfilerTest.java | 54 ----- .../profilers/HotspotMemoryProfilerTest.java | 54 ----- .../profilers/HotspotRuntimeProfilerTest.java | 54 ----- .../profilers/HotspotThreadProfilerTest.java | 54 ----- .../jmh/profile/AbstractHotspotProfiler.java | 203 ------------------ .../profile/HotspotClassloadingProfiler.java | 37 ---- .../profile/HotspotCompilationProfiler.java | 102 --------- .../jmh/profile/HotspotMemoryProfiler.java | 37 ---- .../jmh/profile/HotspotRuntimeProfiler.java | 93 -------- .../jmh/profile/HotspotThreadProfiler.java | 64 ------ .../openjdk/jmh/profile/ProfilerFactory.java | 5 - 12 files changed, 810 deletions(-) delete mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java delete mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java delete mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java delete mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java delete mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java delete mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java delete mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java delete mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java delete mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java delete mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java delete mode 100644 jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java deleted file mode 100644 index 1b5234779..000000000 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.it.profilers; - -import junit.framework.Assert; -import org.junit.Test; -import org.openjdk.jmh.it.Fixtures; -import org.openjdk.jmh.profile.HotspotClassloadingProfiler; -import org.openjdk.jmh.profile.ProfilerException; -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; - -public class HotspotClassloadingProfilerTest extends AbstractHotspotProfilerTest { - - @Test - public void test() throws RunnerException { - try { - new HotspotClassloadingProfiler(); - } catch (ProfilerException e) { - Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); - return; - } - Options opts = new OptionsBuilder() - .include(Fixtures.getTestMask(this.getClass())) - .addProfiler(HotspotClassloadingProfiler.class) - .build(); - new Runner(opts).run(); - } -} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java deleted file mode 100644 index 608c452a6..000000000 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.it.profilers; - -import junit.framework.Assert; -import org.junit.Test; -import org.openjdk.jmh.it.Fixtures; -import org.openjdk.jmh.profile.HotspotClassloadingProfiler; -import org.openjdk.jmh.profile.HotspotCompilationProfiler; -import org.openjdk.jmh.profile.ProfilerException; -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; - -public class HotspotCompilationProfilerTest extends AbstractHotspotProfilerTest { - - @Test - public void test() throws RunnerException { - try { - new HotspotCompilationProfiler(); - } catch (ProfilerException e) { - Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); - return; - } - Options opts = new OptionsBuilder() - .include(Fixtures.getTestMask(this.getClass())) - .addProfiler(HotspotCompilationProfiler.class) - .build(); - new Runner(opts).run(); - } -} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java deleted file mode 100644 index 62f785096..000000000 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.it.profilers; - -import junit.framework.Assert; -import org.junit.Test; -import org.openjdk.jmh.it.Fixtures; -import org.openjdk.jmh.profile.HotspotCompilationProfiler; -import org.openjdk.jmh.profile.HotspotMemoryProfiler; -import org.openjdk.jmh.profile.ProfilerException; -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; - -public class HotspotMemoryProfilerTest extends AbstractHotspotProfilerTest { - - @Test - public void test() throws RunnerException { - try { - new HotspotMemoryProfiler(); - } catch (ProfilerException e) { - Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); - return; - } - Options opts = new OptionsBuilder() - .include(Fixtures.getTestMask(this.getClass())) - .addProfiler(HotspotMemoryProfiler.class) - .build(); - new Runner(opts).run(); - } -} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java deleted file mode 100644 index 480a4dc8c..000000000 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.it.profilers; - -import junit.framework.Assert; -import org.junit.Test; -import org.openjdk.jmh.it.Fixtures; -import org.openjdk.jmh.profile.HotspotMemoryProfiler; -import org.openjdk.jmh.profile.HotspotRuntimeProfiler; -import org.openjdk.jmh.profile.ProfilerException; -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; - -public class HotspotRuntimeProfilerTest extends AbstractHotspotProfilerTest { - - @Test - public void test() throws RunnerException { - try { - new HotspotRuntimeProfiler(); - } catch (ProfilerException e) { - Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); - return; - } - Options opts = new OptionsBuilder() - .include(Fixtures.getTestMask(this.getClass())) - .addProfiler(HotspotRuntimeProfiler.class) - .build(); - new Runner(opts).run(); - } -} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java deleted file mode 100644 index 113e9c2a1..000000000 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.it.profilers; - -import junit.framework.Assert; -import org.junit.Test; -import org.openjdk.jmh.it.Fixtures; -import org.openjdk.jmh.profile.HotspotRuntimeProfiler; -import org.openjdk.jmh.profile.HotspotThreadProfiler; -import org.openjdk.jmh.profile.ProfilerException; -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; - -public class HotspotThreadProfilerTest extends AbstractHotspotProfilerTest { - - @Test - public void test() throws RunnerException { - try { - new HotspotThreadProfiler(); - } catch (ProfilerException e) { - Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM()); - return; - } - Options opts = new OptionsBuilder() - .include(Fixtures.getTestMask(this.getClass())) - .addProfiler(HotspotThreadProfiler.class) - .build(); - new Runner(opts).run(); - } -} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java deleted file mode 100644 index 3c1f12cc7..000000000 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.profile; - -import org.openjdk.jmh.infra.BenchmarkParams; -import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.*; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.*; - -abstract class AbstractHotspotProfiler implements InternalProfiler { - - private final Method getListMethod; - private final Object bean; - - private Map prevs; - - public AbstractHotspotProfiler(String beanName, String methodName) throws ProfilerException { - try { - Class helper = Class.forName("sun.management.ManagementFactoryHelper"); - bean = helper.getMethod("get" + beanName).invoke(null); - getListMethod = bean.getClass().getMethod(methodName); - getListMethod.setAccessible(true); - getListMethod.invoke(bean); // try - } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { - throw new ProfilerException("Problem initializing profiler (" + e.getMessage() + "), are you running HotSpot VM?"); - } - } - - @Override - public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { - HotspotInternalResult res = counters(); - Collection results = new ArrayList<>(); - for (Map.Entry e : res.getDiff().entrySet()) { - results.add(new ScalarResult(Defaults.PREFIX + e.getKey(), e.getValue(), "?", AggregationPolicy.AVG)); - } - return results; - } - - @Override - public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { - prevs = new HashMap<>(); - for (HotspotCounter counter : getCounters()) { - prevs.put(counter.getName(), convert(counter.getValue())); - } - } - - public static Long convert(Object o) { - try { - return Long.valueOf(String.valueOf(o)); - } catch (IllegalArgumentException iae) { - return null; - } - } - - protected HotspotInternalResult counters() { - Map difference = new TreeMap<>(); - Map current = new TreeMap<>(); - for (HotspotCounter counter : getCounters()) { - Long prev = prevs.get(counter.getName()); - if (prev != null) { - long diff = convert(counter.getValue()) - prev; - difference.put(counter.getName(), diff); - current.put(counter.getName(), convert(counter.getValue())); - } - } - - return new HotspotInternalResult(current, difference); - } - - public List getCounters() { - try { - List counters = new ArrayList<>(); - for (Object c : (List) getListMethod.invoke(bean)) { - try { - counters.add(new HotspotCounter(c)); - } catch (UnsupportedOperationException e) { - // ignore this counter - } - } - return counters; - } catch (IllegalAccessException | InvocationTargetException e) { - throw new IllegalStateException("Should not be here", e); - } - } - - /** - * Represents the HotSpot profiling result. - */ - static class HotspotInternalResult { - private final Map current; - private final Map diff; - - public HotspotInternalResult(Map current, Map diff) { - this.current = current; - this.diff = diff; - } - - public Map getCurrent() { - return current; - } - - public Map getDiff() { - return diff; - } - - @Override - public String toString() { - return "difference: " + diff.toString(); - } - } - - /** - * Reflective proxy for Hotspot counters to dodge compatibility problems. - */ - private static class HotspotCounter { - private static final Method GET_VALUE; - private static final Method GET_NAME; - - static { - Method name = null; - Method value = null; - try { - Class cntClass = Class.forName("sun.management.counter.Counter"); - if (cntClass != null) { - try { - name = cntClass.getMethod("getName"); - } catch (NoSuchMethodException e) { - // do nothing - } - try { - value = cntClass.getMethod("getValue"); - } catch (NoSuchMethodException e) { - // do nothing - } - } - } catch (ClassNotFoundException e) { - // no nothing - } - - GET_NAME = name; - GET_VALUE = value; - } - - private final Object proxy; - - public HotspotCounter(Object proxy) throws UnsupportedOperationException { - this.proxy = proxy; - - // Try these right now - if (GET_NAME == null || GET_VALUE == null) { - throw new UnsupportedOperationException(); - } - try { - String k = (String) GET_NAME.invoke(proxy); - Object v = GET_VALUE.invoke(proxy); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new UnsupportedOperationException(e); - } - } - - public String getName() { - try { - return (String) GET_NAME.invoke(proxy); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new IllegalStateException("Cannot be here"); - } - } - - public Object getValue() { - try { - return GET_VALUE.invoke(proxy); - } catch (IllegalAccessException | InvocationTargetException e) { - throw new IllegalStateException("Cannot be here"); - } - } - } - -} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java deleted file mode 100644 index f8cf068c0..000000000 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.profile; - -public class HotspotClassloadingProfiler extends AbstractHotspotProfiler { - - public HotspotClassloadingProfiler() throws ProfilerException { - super("HotspotClassLoadingMBean", "getInternalClassLoadingCounters"); - } - - @Override - public String getDescription() { - return "HotSpot (tm) classloader profiling via implementation-specific MBeans"; - } -} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java deleted file mode 100644 index e46c8b08e..000000000 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.profile; - -import org.openjdk.jmh.infra.BenchmarkParams; -import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.*; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -public class HotspotCompilationProfiler extends AbstractHotspotProfiler { - - public HotspotCompilationProfiler() throws ProfilerException { - super("HotspotCompilationMBean", "getInternalCompilerCounters"); - } - - @Override - public String getDescription() { - return "HotSpot (tm) JIT compiler profiling via implementation-specific MBeans"; - } - - @Override - public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { - Map current = counters().getCurrent(); - return Arrays.asList( - new ScalarResult(Defaults.PREFIX + "compiler.totalTime", - current.get("java.ci.totalTime") * 1D / TimeUnit.MILLISECONDS.toNanos(1), - "ms", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.totalCompiles", - current.get("sun.ci.totalCompiles"), - "methods", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.totalBailouts", - current.get("sun.ci.totalBailouts"), - "methods", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.totalInvalidates", - current.get("sun.ci.totalInvalidates"), - "methods", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.nmethodCodeSize", - current.get("sun.ci.nmethodCodeSize") / 1024d, - "Kb", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.nmethodSize", - current.get("sun.ci.nmethodSize") / 1024d, - "Kb", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.osrCompiles", - current.get("sun.ci.osrCompiles"), - "methods", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.osrBytes", - current.get("sun.ci.osrBytes") / 1024d, - "Kb", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.osrTime", - current.get("sun.ci.osrTime") * 1d / TimeUnit.MILLISECONDS.toNanos(1), - "ms", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.standardCompiles", - current.get("sun.ci.standardCompiles"), - "methods", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.standardBytes", - current.get("sun.ci.standardBytes") / 1024d, - "Kb", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "compiler.standardTime", - current.get("sun.ci.standardTime") * 1d / TimeUnit.MILLISECONDS.toNanos(1), - "ms", AggregationPolicy.MAX) - ); - } - -} - diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java deleted file mode 100644 index ff72794f1..000000000 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.profile; - -public class HotspotMemoryProfiler extends AbstractHotspotProfiler { - - public HotspotMemoryProfiler() throws ProfilerException { - super("HotspotMemoryMBean", "getInternalMemoryCounters"); - } - - @Override - public String getDescription() { - return "HotSpot (tm) memory manager (GC) profiling via implementation-specific MBeans"; - } -} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java deleted file mode 100644 index 8d1f589f8..000000000 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.profile; - -import org.openjdk.jmh.infra.BenchmarkParams; -import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.*; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -public class HotspotRuntimeProfiler extends AbstractHotspotProfiler { - - public HotspotRuntimeProfiler() throws ProfilerException { - super("HotspotRuntimeMBean", "getInternalRuntimeCounters"); - } - - @Override - public String getDescription() { - return "HotSpot (tm) runtime profiling via implementation-specific MBeans"; - } - - @Override - public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { - Map current = counters().getCurrent(); - return Arrays.asList( - new ScalarResult(Defaults.PREFIX + "rt.sync.fatMonitors", - current.get("sun.rt._sync_MonExtant"), - "monitors", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "rt.sync.monitorInflations", - current.get("sun.rt._sync_Inflations"), - "monitors", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "rt.sync.monitorDeflations", - current.get("sun.rt._sync_Deflations"), - "monitors", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "rt.sync.contendedLockAttempts", - current.get("sun.rt._sync_ContendedLockAttempts"), - "locks", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "rt.sync.parks", - current.get("sun.rt._sync_Parks"), - "counts", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "rt.sync.notifications", - current.get("sun.rt._sync_Notifications"), - "counts", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "rt.sync.futileWakeups", - current.get("sun.rt._sync_FutileWakeups"), - "counts", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "rt.safepoints", - current.get("sun.rt.safepoints"), - "counts", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "rt.safepointSyncTime", - current.get("sun.rt.safepointSyncTime") * 1d / TimeUnit.MILLISECONDS.toNanos(1), - "ms", AggregationPolicy.MAX), - - new ScalarResult(Defaults.PREFIX + "rt.safepointTime", - current.get("sun.rt.safepointTime") * 1d / TimeUnit.MILLISECONDS.toNanos(1), - "ms", AggregationPolicy.MAX) - ); - } - -} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java deleted file mode 100644 index a699d169b..000000000 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.profile; - -import org.openjdk.jmh.infra.BenchmarkParams; -import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.results.*; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; - -public class HotspotThreadProfiler extends AbstractHotspotProfiler { - - public HotspotThreadProfiler() throws ProfilerException { - super("HotspotThreadMBean", "getInternalThreadingCounters"); - } - - @Override - public String getDescription() { - return "HotSpot (tm) threading subsystem via implementation-specific MBeans"; - } - - @Override - public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { - Map current = counters().getCurrent(); - return Arrays.asList( - new ScalarResult(Defaults.PREFIX + "threads.alive", - current.get("java.threads.live"), - "threads", AggregationPolicy.AVG), - - new ScalarResult(Defaults.PREFIX + "threads.daemon", - current.get("java.threads.daemon"), - "threads", AggregationPolicy.AVG), - - new ScalarResult(Defaults.PREFIX + "threads.started", - current.get("java.threads.started"), - "threads", AggregationPolicy.MAX) - ); - } - -} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java index 162b1e12d..412516edb 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ProfilerFactory.java @@ -168,11 +168,6 @@ public static void listProfilers(PrintStream out) { BUILT_IN.put("cl", ClassloaderProfiler.class); BUILT_IN.put("comp", CompilerProfiler.class); BUILT_IN.put("gc", GCProfiler.class); - BUILT_IN.put("hs_cl", HotspotClassloadingProfiler.class); - BUILT_IN.put("hs_comp", HotspotCompilationProfiler.class); - BUILT_IN.put("hs_gc", HotspotMemoryProfiler.class); - BUILT_IN.put("hs_rt", HotspotRuntimeProfiler.class); - BUILT_IN.put("hs_thr", HotspotThreadProfiler.class); BUILT_IN.put("jfr", JavaFlightRecorderProfiler.class); BUILT_IN.put("stack", StackProfiler.class); BUILT_IN.put("perf", LinuxPerfProfiler.class); From 662743e7a44606a1ef77739cd3898f7d3b3996b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Wed, 13 Jan 2021 16:09:38 +0100 Subject: [PATCH 238/342] CODETOOLS-7902813: Amend experimental compiler-assisted blackhole support (#16) --- .../java/org/openjdk/jmh/validation/Main.java | 26 +-- .../validation/tests/BlackholeSingleTest.java | 10 +- .../java/org/openjdk/jmh/infra/Blackhole.java | 178 +++++++++++++----- .../org/openjdk/jmh/runner/CompilerHints.java | 38 ++-- 4 files changed, 172 insertions(+), 80 deletions(-) diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java index d5cf26255..052b812cd 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java @@ -154,8 +154,6 @@ public static void main(String[] args) throws RunnerException, CommandLineOption throw new IllegalStateException(); } - boolean testCompilerBlackhole = JDKVersion.parseMajor(System.getProperty("java.version")) >= 16; - for (Test t : tests) { switch (t) { case timing: @@ -195,17 +193,23 @@ public static void main(String[] args) throws RunnerException, CommandLineOption new BlackholeConsumeCPUTest().runWith(pw, opts); break; case blackhole_single: - new BlackholeSingleTest().runWith(pw, opts); + setBlackholeOpts(BlackholeTestMode.normal); + new BlackholeSingleTest(BlackholeTestMode.normal).runWith(pw, opts); + setBlackholeOpts(BlackholeTestMode.compiler); + new BlackholeSingleTest(BlackholeTestMode.compiler).runWith(pw, opts); + setBlackholeOpts(BlackholeTestMode.full_dontinline); + new BlackholeSingleTest(BlackholeTestMode.full_dontinline).runWith(pw, opts); + setBlackholeOpts(BlackholeTestMode.full); + new BlackholeSingleTest(BlackholeTestMode.full).runWith(pw, opts); + setBlackholeOpts(BlackholeTestMode.normal); break; case blackhole_pipelined: setBlackholeOpts(BlackholeTestMode.normal); new BlackholePipelinedTest(false, BlackholeTestMode.normal).runWith(pw, opts); new BlackholePipelinedTest(true, BlackholeTestMode.normal).runWith(pw, opts); - if (testCompilerBlackhole) { - setBlackholeOpts(BlackholeTestMode.compiler); - new BlackholePipelinedTest(false, BlackholeTestMode.compiler).runWith(pw, opts); - new BlackholePipelinedTest(true, BlackholeTestMode.compiler).runWith(pw, opts); - } + setBlackholeOpts(BlackholeTestMode.compiler); + new BlackholePipelinedTest(false, BlackholeTestMode.compiler).runWith(pw, opts); + new BlackholePipelinedTest(true, BlackholeTestMode.compiler).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.full_dontinline); new BlackholePipelinedTest(false, BlackholeTestMode.full_dontinline).runWith(pw, opts); new BlackholePipelinedTest(true, BlackholeTestMode.full_dontinline).runWith(pw, opts); @@ -217,10 +221,8 @@ public static void main(String[] args) throws RunnerException, CommandLineOption case blackhole_consec: setBlackholeOpts(BlackholeTestMode.normal); new BlackholeConsecutiveTest(BlackholeTestMode.normal).runWith(pw, opts); - if (testCompilerBlackhole) { - setBlackholeOpts(BlackholeTestMode.compiler); - new BlackholeConsecutiveTest(BlackholeTestMode.compiler).runWith(pw, opts); - } + setBlackholeOpts(BlackholeTestMode.compiler); + new BlackholeConsecutiveTest(BlackholeTestMode.compiler).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.full_dontinline); new BlackholeConsecutiveTest(BlackholeTestMode.full_dontinline).runWith(pw, opts); setBlackholeOpts(BlackholeTestMode.full); diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeSingleTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeSingleTest.java index c4007d9f7..96116a1b0 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeSingleTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BlackholeSingleTest.java @@ -37,9 +37,15 @@ import java.io.PrintWriter; public class BlackholeSingleTest extends ValidationTest { + private final BlackholeTestMode mode; + + public BlackholeSingleTest(BlackholeTestMode mode) { + this.mode = mode; + } + @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { - pw.println("--------- BLACKHOLE SINGLE INVOCATION TEST"); + pw.println("--------- BLACKHOLE SINGLE INVOCATION TEST (" + blackholeModeString(mode) + ")"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, @@ -49,6 +55,8 @@ public void runWith(PrintWriter pw, Options parent) throws RunnerException { 80, 2); pw.println(); + blackholeModeMessage(pw, mode); + String[] types = new String[] { "boolean", "byte", "short", "char", "int", "float", diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java index 874c74b03..b6bc77aba 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java @@ -152,7 +152,7 @@ abstract class BlackholeL4 extends BlackholeL3 { */ public final class Blackhole extends BlackholeL4 { - /** + /* * IMPLEMENTATION NOTES: * * The major things to dodge with Blackholes are: @@ -236,6 +236,11 @@ public final class Blackhole extends BlackholeL4 { * In all cases, consumes do the volatile reads to have a consistent memory * semantics across all consume methods. * + * There is an experimental compiler support for Blackholes that instructs compilers + * to treat specific methods as blackholes: keeping their arguments alive. At some + * point in the future, we hope to switch to that mode by default, thus greatly + * simplifying the Blackhole code. + * * An utmost caution should be exercised when changing the Blackhole code. Nominally, * the JMH Core Benchmarks should be run on multiple platforms (and their generated code * examined) to check the effects are still in place, and the overheads are not prohibitive. @@ -246,6 +251,8 @@ public final class Blackhole extends BlackholeL4 { * AND LOTS OF TIME OVER THAT. ADJUST YOUR PLANS ACCORDINGLY. */ + private static final boolean COMPILER_BLACKHOLE = Boolean.getBoolean("compilerBlackholesEnabled"); + static { Utils.check(Blackhole.class, "b1", "b2"); Utils.check(Blackhole.class, "bool1", "bool2"); @@ -304,12 +311,10 @@ public void evaporate(String challengeResponse) { * @param obj object to consume. */ public final void consume(Object obj) { - int tlrMask = this.tlrMask; // volatile read - int tlr = (this.tlr = (this.tlr * 1664525 + 1013904223)); - if ((tlr & tlrMask) == 0) { - // SHOULD ALMOST NEVER HAPPEN IN MEASUREMENT - this.obj1 = new WeakReference<>(obj); - this.tlrMask = (tlrMask << 1) + 1; + if (COMPILER_BLACKHOLE) { + consumeCompiler(obj); + } else { + consumeFull(obj); } } @@ -319,11 +324,10 @@ public final void consume(Object obj) { * @param b object to consume. */ public final void consume(byte b) { - byte b1 = this.b1; // volatile read - byte b2 = this.b2; - if ((b ^ b1) == (b ^ b2)) { - // SHOULD NEVER HAPPEN - nullBait.b1 = b; // implicit null pointer exception + if (COMPILER_BLACKHOLE) { + consumeCompiler(b); + } else { + consumeFull(b); } } @@ -333,11 +337,10 @@ public final void consume(byte b) { * @param bool object to consume. */ public final void consume(boolean bool) { - boolean bool1 = this.bool1; // volatile read - boolean bool2 = this.bool2; - if ((bool ^ bool1) == (bool ^ bool2)) { - // SHOULD NEVER HAPPEN - nullBait.bool1 = bool; // implicit null pointer exception + if (COMPILER_BLACKHOLE) { + consumeCompiler(bool); + } else { + consumeFull(bool); } } @@ -347,11 +350,10 @@ public final void consume(boolean bool) { * @param c object to consume. */ public final void consume(char c) { - char c1 = this.c1; // volatile read - char c2 = this.c2; - if ((c ^ c1) == (c ^ c2)) { - // SHOULD NEVER HAPPEN - nullBait.c1 = c; // implicit null pointer exception + if (COMPILER_BLACKHOLE) { + consumeCompiler(c); + } else { + consumeFull(c); } } @@ -361,11 +363,10 @@ public final void consume(char c) { * @param s object to consume. */ public final void consume(short s) { - short s1 = this.s1; // volatile read - short s2 = this.s2; - if ((s ^ s1) == (s ^ s2)) { - // SHOULD NEVER HAPPEN - nullBait.s1 = s; // implicit null pointer exception + if (COMPILER_BLACKHOLE) { + consumeCompiler(s); + } else { + consumeFull(s); } } @@ -375,11 +376,10 @@ public final void consume(short s) { * @param i object to consume. */ public final void consume(int i) { - int i1 = this.i1; // volatile read - int i2 = this.i2; - if ((i ^ i1) == (i ^ i2)) { - // SHOULD NEVER HAPPEN - nullBait.i1 = i; // implicit null pointer exception + if (COMPILER_BLACKHOLE) { + consumeCompiler(i); + } else { + consumeFull(i); } } @@ -389,11 +389,10 @@ public final void consume(int i) { * @param l object to consume. */ public final void consume(long l) { - long l1 = this.l1; // volatile read - long l2 = this.l2; - if ((l ^ l1) == (l ^ l2)) { - // SHOULD NEVER HAPPEN - nullBait.l1 = l; // implicit null pointer exception + if (COMPILER_BLACKHOLE) { + consumeCompiler(l); + } else { + consumeFull(l); } } @@ -403,11 +402,10 @@ public final void consume(long l) { * @param f object to consume. */ public final void consume(float f) { - float f1 = this.f1; // volatile read - float f2 = this.f2; - if (f == f1 & f == f2) { - // SHOULD NEVER HAPPEN - nullBait.f1 = f; // implicit null pointer exception + if (COMPILER_BLACKHOLE) { + consumeCompiler(f); + } else { + consumeFull(f); } } @@ -417,6 +415,92 @@ public final void consume(float f) { * @param d object to consume. */ public final void consume(double d) { + if (COMPILER_BLACKHOLE) { + consumeCompiler(d); + } else { + consumeFull(d); + } + } + + // Compiler blackholes block: let compilers figure out how to deal with it. + + private static void consumeCompiler(boolean v) {} + private static void consumeCompiler(byte v) {} + private static void consumeCompiler(short v) {} + private static void consumeCompiler(char v) {} + private static void consumeCompiler(int v) {} + private static void consumeCompiler(float v) {} + private static void consumeCompiler(double v) {} + private static void consumeCompiler(long v) {} + private static void consumeCompiler(Object v) {} + + // Full blackholes block: confuse compilers to get blackholing effects. + // See implementation comments at the top to understand what this code is doing. + + private void consumeFull(byte b) { + byte b1 = this.b1; // volatile read + byte b2 = this.b2; + if ((b ^ b1) == (b ^ b2)) { + // SHOULD NEVER HAPPEN + nullBait.b1 = b; // implicit null pointer exception + } + } + + private void consumeFull(boolean bool) { + boolean bool1 = this.bool1; // volatile read + boolean bool2 = this.bool2; + if ((bool ^ bool1) == (bool ^ bool2)) { + // SHOULD NEVER HAPPEN + nullBait.bool1 = bool; // implicit null pointer exception + } + } + + private void consumeFull(char c) { + char c1 = this.c1; // volatile read + char c2 = this.c2; + if ((c ^ c1) == (c ^ c2)) { + // SHOULD NEVER HAPPEN + nullBait.c1 = c; // implicit null pointer exception + } + } + + private void consumeFull(short s) { + short s1 = this.s1; // volatile read + short s2 = this.s2; + if ((s ^ s1) == (s ^ s2)) { + // SHOULD NEVER HAPPEN + nullBait.s1 = s; // implicit null pointer exception + } + } + + private void consumeFull(int i) { + int i1 = this.i1; // volatile read + int i2 = this.i2; + if ((i ^ i1) == (i ^ i2)) { + // SHOULD NEVER HAPPEN + nullBait.i1 = i; // implicit null pointer exception + } + } + + private void consumeFull(long l) { + long l1 = this.l1; // volatile read + long l2 = this.l2; + if ((l ^ l1) == (l ^ l2)) { + // SHOULD NEVER HAPPEN + nullBait.l1 = l; // implicit null pointer exception + } + } + + private void consumeFull(float f) { + float f1 = this.f1; // volatile read + float f2 = this.f2; + if (f == f1 & f == f2) { + // SHOULD NEVER HAPPEN + nullBait.f1 = f; // implicit null pointer exception + } + } + + private void consumeFull(double d) { double d1 = this.d1; // volatile read double d2 = this.d2; if (d == d1 & d == d2) { @@ -425,6 +509,16 @@ public final void consume(double d) { } } + private void consumeFull(Object obj) { + int tlrMask = this.tlrMask; // volatile read + int tlr = (this.tlr = (this.tlr * 1664525 + 1013904223)); + if ((tlr & tlrMask) == 0) { + // SHOULD ALMOST NEVER HAPPEN IN MEASUREMENT + this.obj1 = new WeakReference<>(obj); + this.tlrMask = (tlrMask << 1) + 1; + } + } + private static volatile long consumedCPU = System.nanoTime(); /** diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java index 3709cdedf..8eaa53935 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java @@ -61,14 +61,17 @@ public static String hintsFile() { final Set defaultHints = defaultList().get(); List hints = new ArrayList<>(defaultHints.size() + 2); hints.add("quiet"); + + // Set up Blackholes BlackholeMode bhMode = blackholeMode(); + hints.add("inline,org/openjdk/jmh/infra/Blackhole.consume"); + hints.add("dontinline,org/openjdk/jmh/infra/Blackhole.consumeCPU"); if (bhMode.shouldBlackhole()) { - hints.add("blackhole,org/openjdk/jmh/infra/Blackhole.consume"); + hints.add("blackhole,org/openjdk/jmh/infra/Blackhole.consumeCompiler"); } if (bhMode.shouldNotInline()) { - hints.add("dontinline,org/openjdk/jmh/infra/Blackhole.consume"); + hints.add("dontinline,org/openjdk/jmh/infra/Blackhole.consumeFull"); } - hints.add("dontinline,org/openjdk/jmh/infra/Blackhole.consumeCPU"); hints.addAll(defaultHints); hintsFile = FileUtils.createTempFileWithLines("compilecommand", hints); } catch (IOException e) { @@ -195,8 +198,10 @@ public static void addCompilerHints(List command) { } } - if (needsDiagnosticUnlock()) { + if (blackholeMode() == BlackholeMode.COMPILER) { command.add("-XX:+UnlockDiagnosticVMOptions"); + command.add("-XX:+UnlockExperimentalVMOptions"); + command.add("-DcompilerBlackholesEnabled=true"); } command.add(CompilerHints.XX_COMPILE_COMMAND_FILE + mergeHintFiles(hintFiles)); @@ -246,31 +251,14 @@ private static BlackholeMode blackholeMode() { public static void printBlackholeMode(PrintStream out) { BlackholeMode mode = blackholeMode(); - out.print("# JMH blackhole mode: " + mode.desc()); - - // Experimental: since JDK 16, Compiler blackholing is available. - // Tell user they can enable it explicitly. We need to consider enabling - // this by default when JDK 16 stabilizes. - if (!mode.shouldBlackhole() && compilerBlackholeAvailable()) { - out.print("; set -D" + BLACKHOLE_PROP_NAME + "=" + BlackholeMode.COMPILER.name() + " to get compiler-assisted ones"); - } - + out.print("# Blackhole mode: " + mode.desc()); out.println(); } - private static boolean compilerBlackholeAvailable() { - // See https://bugs.openjdk.java.net/browse/JDK-8252505. - return JDKVersion.parseMajor(System.getProperty("java.version")) >= 16; - } - - private static boolean needsDiagnosticUnlock() { - return blackholeMode() == BlackholeMode.COMPILER; - } - private enum BlackholeMode { - COMPILER(true, false, "compiler-assisted blackhole"), - FULL_DONTINLINE(false, true, "full blackhole + dont-inline hint"), - FULL(false, false, "full blackhole"), + COMPILER(true, false, "compiler-assisted (EXPERIMENTAL, check generated code)"), + FULL_DONTINLINE(false, true, "full + dont-inline hint"), + FULL(false, false, "full (DIAGNOSTIC)"), ; private final boolean shouldBlackhole; From 0cb36802275a26cb31dfe382c7a684c47eb74172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 14 Jan 2021 12:17:11 +0100 Subject: [PATCH 239/342] CODETOOLS-7902695: JMH should not try to access inaccessible fields (#18) --- .../main/java/org/openjdk/jmh/util/Utils.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 9ee05f904..fc8c10c72 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -28,7 +28,9 @@ import java.io.*; import java.lang.management.ManagementFactory; +import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.charset.Charset; import java.util.*; @@ -221,6 +223,28 @@ public static int figureOutHotCPUs() { return max; } + private static void setAccessible(Object holder, AccessibleObject o) throws IllegalAccessException { + // JDK 9+ has the module protections in place, which would print the warning + // to the console if we try setAccessible(true) on inaccessible object. + // JDK 16 would deny access by default, so we have no recourse at all. + // Try to check with JDK 9+ AccessibleObject.canAccess before doing this + // to avoid the confusing console warnings. Force the break in if user asks + // explicitly. + + if (!Boolean.getBoolean("jmh.forceSetAccessible")) { + try { + Method canAccess = AccessibleObject.class.getDeclaredMethod("canAccess", Object.class); + if (!(boolean) canAccess.invoke(o, holder)) { + throw new IllegalAccessException(o + " is not accessible"); + } + } catch (NoSuchMethodException | InvocationTargetException e) { + // fall-through + } + } + + o.setAccessible(true); + } + public static Charset guessConsoleEncoding() { // The reason for this method to exist is simple: we need the proper platform encoding for output. // We cannot use Console class directly, because we also need the access to the raw byte stream, @@ -232,13 +256,13 @@ public static Charset guessConsoleEncoding() { Console console = System.console(); if (console != null) { Field f = Console.class.getDeclaredField("cs"); - f.setAccessible(true); + setAccessible(console, f); Object res = f.get(console); if (res instanceof Charset) { return (Charset) res; } Method m = Console.class.getDeclaredMethod("encoding"); - m.setAccessible(true); + setAccessible(console, m); res = m.invoke(null); if (res instanceof String) { return Charset.forName((String) res); @@ -256,7 +280,7 @@ public static Charset guessConsoleEncoding() { PrintStream out = System.out; if (out != null) { Field f = PrintStream.class.getDeclaredField("charOut"); - f.setAccessible(true); + setAccessible(out, f); Object res = f.get(out); if (res instanceof OutputStreamWriter) { String encoding = ((OutputStreamWriter) res).getEncoding(); From 5ca5645ad6b4cf09e6eb783124b6a7be7c803673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 18 Feb 2021 11:52:33 +0100 Subject: [PATCH 240/342] 7902828: JMH: Start testing with JDK 17 EA --- .github/workflows/pre-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-integration.yml b/.github/workflows/pre-integration.yml index c0c8856de..99b66b347 100644 --- a/.github/workflows/pre-integration.yml +++ b/.github/workflows/pre-integration.yml @@ -10,7 +10,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - java: [7, 8, 11, 15, 16-ea] + java: [7, 8, 11, 15, 16-ea, 17-ea] os: [ubuntu-18.04, windows-2019, macos-10.15] profile: [default, reflection, asm] fail-fast: false From 5b3a1296dff77ee3f6743e38833eafdd0970bace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 18 Feb 2021 12:47:18 +0100 Subject: [PATCH 241/342] 7902825: Generated BenchmarkList file should be sorted for reproducibility Reviewed-by: redestad --- .../org/openjdk/jmh/runner/BenchmarkList.java | 8 +- .../jmh/runner/TestBenchmarkListEncoding.java | 5 +- .../jmh/runner/TestBenchmarkListSorting.java | 103 ++++++++++++++++++ 3 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListSorting.java diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java index b06658613..0d97dd774 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkList.java @@ -56,9 +56,9 @@ public static BenchmarkList fromString(String strings) { return new BenchmarkList(null, null, strings); } - public static Collection readBenchmarkList(InputStream stream) throws IOException { + public static List readBenchmarkList(InputStream stream) throws IOException { try (Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { - Collection entries = new ArrayList<>(); + List entries = new ArrayList<>(); for (String line : FileUtils.readAllLines(reader)) { BenchmarkListEntry ble = new BenchmarkListEntry(line); entries.add(ble); @@ -69,7 +69,9 @@ public static Collection readBenchmarkList(InputStream strea public static void writeBenchmarkList(OutputStream stream, Collection entries) { try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8))) { - for (BenchmarkListEntry entry : entries) { + List sorted = new ArrayList<>(entries); + Collections.sort(sorted); + for (BenchmarkListEntry entry : sorted) { writer.println(entry.toLine()); } } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListEncoding.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListEncoding.java index 69ffd1263..ce0e576ff 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListEncoding.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListEncoding.java @@ -104,9 +104,8 @@ public void testWith(String src, String dst) throws IOException { resetCharset(); System.setProperty("file.encoding", dst); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - Collection read = BenchmarkList.readBenchmarkList(bis); - BenchmarkListEntry first = read.iterator().next(); - assertEquals("something.Test.testКонкаррентХэшмап", first.getUsername()); + List read = BenchmarkList.readBenchmarkList(bis); + assertEquals("something.Test.testКонкаррентХэшмап", read.get(0).getUsername()); } private void resetCharset() { diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListSorting.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListSorting.java new file mode 100644 index 000000000..f81b5543e --- /dev/null +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/TestBenchmarkListSorting.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.runner; + +import org.junit.Test; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.runner.options.TimeValue; +import org.openjdk.jmh.util.Optional; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.*; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; + +public class TestBenchmarkListSorting { + + private static BenchmarkListEntry stub(String userClassQName, String generatedClassQName, String method, Mode mode) { + BenchmarkListEntry br = new BenchmarkListEntry( + userClassQName, + generatedClassQName, + method, + mode, + Optional.none(), + new int[]{1}, + Optional.>none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.none(), + Optional.>none(), + Optional.>none(), + Optional.>none(), + Optional.>none(), + Optional.none(), + Optional.none(), + Optional.none() + ); + return br; + } + + @Test + public void test() throws Exception { + BenchmarkListEntry br1 = stub("something.Test1", + "something.generated.Test1", + "something.generated.TestMethod", + Mode.AverageTime); + BenchmarkListEntry br2 = stub("something.Test2", + "something.generated.Test1", + "something.generated.TestMethod", + Mode.AverageTime); + BenchmarkListEntry br3 = stub("something.Test3", + "something.generated.Test1", + "something.generated.TestMethod", + Mode.AverageTime); + BenchmarkListEntry br4 = stub("something.Test4", + "something.generated.Test1", + "something.generated.TestMethod", + Mode.AverageTime); + + // Present to writer in mixed order + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + BenchmarkList.writeBenchmarkList(bos, Arrays.asList(br4, br2, br3, br1)); + + ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); + List read = BenchmarkList.readBenchmarkList(bis); + + // Assert we read these in proper order + assertEquals("something.Test1", read.get(0).getUserClassQName()); + assertEquals("something.Test2", read.get(1).getUserClassQName()); + assertEquals("something.Test3", read.get(2).getUserClassQName()); + assertEquals("something.Test4", read.get(3).getUserClassQName()); + } + +} From c950cdb437d10606284b744d9b5a1a70f8aa2499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 18 Feb 2021 16:57:26 +0100 Subject: [PATCH 242/342] 7902829: JMH Statistics implementations do not follow Comparable spec --- .../main/java/org/openjdk/jmh/util/AbstractStatistics.java | 4 +--- .../test/java/org/openjdk/jmh/util/TestListStatistics.java | 6 +++--- .../java/org/openjdk/jmh/util/TestMultisetStatistics.java | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/AbstractStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/AbstractStatistics.java index c5fb5b158..1a67a227f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/AbstractStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/AbstractStatistics.java @@ -91,9 +91,7 @@ public double getStandardDeviation() { @Override public int compareTo(Statistics other, double confidence) { if (isDifferent(other, confidence)) { - double t = getMean(); - double o = other.getMean(); - return (t > o) ? -1 : 1; + return Double.compare(getMean(), other.getMean()); } else { return 0; } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java index 6add7c7d4..193b74a1a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java @@ -187,7 +187,7 @@ public strictfp void testSignificant_Always() { for (double conf : new double[] {0.5, 0.9, 0.99, 0.999, 0.9999, 0.99999}) { Assert.assertTrue("Diff significant at " + conf, s1.isDifferent(s2, conf)); - Assert.assertEquals(1, s1.compareTo(s2, conf)); + Assert.assertTrue(s1.compareTo(s2, conf) < 0); } } @@ -227,8 +227,8 @@ public strictfp void testSignificant_Sometimes() { Assert.assertFalse("Diff not significant at 0.999", s1.isDifferent(s2, 0.999)); Assert.assertFalse("Diff not significant at 0.9999", s1.isDifferent(s2, 0.9999)); - Assert.assertEquals("compareTo at 0.5", 1, s1.compareTo(s2, 0.5)); - Assert.assertEquals("compareTo at 0.9", 1, s1.compareTo(s2, 0.9)); + Assert.assertTrue("compareTo at 0.5", s1.compareTo(s2, 0.5) < 0); + Assert.assertTrue("compareTo at 0.9", s1.compareTo(s2, 0.9) < 0); Assert.assertEquals("compareTo at 0.99", 0, s1.compareTo(s2, 0.99)); Assert.assertEquals("compareTo at 0.999", 0, s1.compareTo(s2, 0.999)); Assert.assertEquals("compareTo at 0.9999", 0, s1.compareTo(s2, 0.9999)); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java index a9b600796..7a203cbae 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java @@ -183,7 +183,7 @@ public strictfp void testSignificant_Always() { for (double conf : new double[] {0.5, 0.9, 0.99, 0.999, 0.9999, 0.99999}) { Assert.assertTrue("Diff significant at " + conf, s1.isDifferent(s2, conf)); - Assert.assertEquals(1, s1.compareTo(s2, conf)); + Assert.assertTrue(s1.compareTo(s2, conf) < 0); } } @@ -219,8 +219,8 @@ public strictfp void testSignificant_Sometimes() { Assert.assertFalse("Diff not significant at 0.999", s1.isDifferent(s2, 0.999)); Assert.assertFalse("Diff not significant at 0.9999", s1.isDifferent(s2, 0.9999)); - Assert.assertEquals("compareTo at 0.5", 1, s1.compareTo(s2, 0.5)); - Assert.assertEquals("compareTo at 0.9", 1, s1.compareTo(s2, 0.9)); + Assert.assertTrue("compareTo at 0.5", s1.compareTo(s2, 0.5) < 0); + Assert.assertTrue("compareTo at 0.9", s1.compareTo(s2, 0.9) < 0); Assert.assertEquals("compareTo at 0.99", 0, s1.compareTo(s2, 0.99)); Assert.assertEquals("compareTo at 0.999", 0, s1.compareTo(s2, 0.999)); Assert.assertEquals("compareTo at 0.9999", 0, s1.compareTo(s2, 0.9999)); From 3acfb65cb8b8f4846f570ce5ceda9f0e3458564c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 23 Feb 2021 20:02:51 +0100 Subject: [PATCH 243/342] 7902830: dtraceasm: do not Process.destroy the dtrace process --- .../jmh/profile/DTraceAsmProfiler.java | 19 +++++- .../main/java/org/openjdk/jmh/util/Utils.java | 65 ++++++++++++++----- .../java/org/openjdk/jmh/util/TestUtil.java | 15 ++++- 3 files changed, 79 insertions(+), 20 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java index 34f67941a..fbb0d4d7e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java @@ -87,11 +87,28 @@ public Collection afterTrial(BenchmarkResult br, long pid, Fil throw new IllegalStateException("DTrace needs the forked VM PID, but it is not initialized"); } - Collection messages = Utils.destroy(dtraceProcess); + // We cannot use Process.destroy, because it closes the streams right away. + // Instead, deliver TERM by hand and wait for process to gracefully terminate. + long dtracePid = Utils.getPid(dtraceProcess); + if (dtracePid == 0) { + throw new IllegalStateException("Cannot determine dtrace process PID"); + } + + Collection messages = Utils.tryWith("sudo", "kill", "-TERM", Long.toString(dtracePid)); if (!messages.isEmpty()) { throw new IllegalStateException(messages.toString()); } + // Wait for dtrace to finish. + try { + int errcode = dtraceProcess.waitFor(); + if (errcode != 0) { + throw new IllegalStateException("Non-zero error code from dtrace: " + errcode); + } + } catch (InterruptedException e) { + throw new IllegalStateException("Interrupted while waiting for profiler to stop"); + } + this.pid = String.valueOf(pid); return super.afterTrial(br, pid, stdOut, stdErr); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index fc8c10c72..69e5b9c1b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -440,6 +440,54 @@ public static long getPid() { throw new IllegalStateException("Unsupported PID format: " + name); } + /** + * Gets the PID of the target process. + * @param process to poll + * @return PID, or zero if no PID is found + */ + public static long getPid(Process process) { + // Step 1. Try Process.pid, available since Java 9. + try { + Method m = Process.class.getMethod("pid"); + Object pid = m.invoke(process); + if (pid instanceof Long) { + return (long) pid; + } + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + // Fallthrough + } + + // Step 2. Try to hack into the JDK 8- UNIXProcess. + try { + Class c = Class.forName("java.lang.UNIXProcess"); + Field f = c.getDeclaredField("pid"); + setAccessible(process, f); + Object o = f.get(process); + if (o instanceof Integer) { + return (int) o; + } + } catch (NoSuchFieldException | ClassNotFoundException | IllegalAccessException e) { + // Fallthrough + } + + // Step 3. Try to hack into JDK 9+ ProcessImpl. + // Renamed from UNIXProcess with JDK-8071481. + try { + Class c = Class.forName("java.lang.ProcessImpl"); + Field f = c.getDeclaredField("pid"); + setAccessible(process, f); + Object o = f.get(process); + if (o instanceof Integer) { + return (int) o; + } + } catch (NoSuchFieldException | ClassNotFoundException | IllegalAccessException e) { + // Fallthrough + } + + // No dice, return zero + return 0; + } + public static Collection tryWith(String... cmd) { Collection messages = new ArrayList<>(); try { @@ -478,23 +526,6 @@ public static Process runAsync(String... cmd) { } } - public static Collection destroy(Process process) { - Collection messages = new ArrayList<>(); - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - process.destroy(); - int exitCode = process.waitFor(); - if (exitCode == 0) { - return Collections.emptyList(); - } - - messages.add(baos.toString()); - return messages; - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - } - public static Collection runWith(List cmd) { Collection messages = new ArrayList<>(); try { diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestUtil.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestUtil.java index e0ff23da3..3028506de 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestUtil.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestUtil.java @@ -27,13 +27,24 @@ import junit.framework.Assert; import org.junit.Test; +import java.io.IOException; import java.util.Arrays; public class TestUtil { @Test - public void testPID() { - Assert.assertFalse(Utils.getPid() == 0); + public void testPID_Current() { + Assert.assertTrue(Utils.getPid() != 0); + } + + @Test + public void testPID_Other() throws IOException, InterruptedException { + if (!Utils.isWindows()) { + ProcessBuilder pb = new ProcessBuilder().command("sleep", "1"); + Process p = pb.start(); + Assert.assertTrue(Utils.getPid(p) != 0); + p.waitFor(); + } } @Test From 6ffede87a2d072533b239e0e2eb2382e66abd851 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 1 Mar 2021 13:08:49 +0100 Subject: [PATCH 244/342] JMH v1.28. --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 82510a35d..f3e2df73d 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.28-SNAPSHOT + 1.28 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index ecbeb76e9..f5418a9d2 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.28-SNAPSHOT + 1.28 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index a24048ecf..a8bd79d17 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.28-SNAPSHOT + 1.28 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index fea9f6987..f75c9433f 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.28-SNAPSHOT + 1.28 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 8d6a8b311..407ce3ec0 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 6e415e3ad..cd5d72d2d 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index eabcfef1e..f48fb585d 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index fba81d408..3c8df1df2 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index bc253c5dd..30128da60 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 58620c1e3..5c9cadfb1 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 32f124ebf..579440adb 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index d03314da1..33adfed8d 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 45e180955..d44f7ffa4 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index cd053930c..c2e9cac50 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.28-SNAPSHOT + 1.28 JMH Samples diff --git a/pom.xml b/pom.xml index 787aeec4a..11f8c96cb 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.28-SNAPSHOT + 1.28 Java Microbenchmark Harness Parent From f3e7d82b0b68ab345f81e0598c7f850c5b334027 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 1 Mar 2021 13:09:22 +0100 Subject: [PATCH 245/342] Continue in 1.29-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index f3e2df73d..a29ffb35a 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.28 + 1.29-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index f5418a9d2..2ae61c4d2 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.28 + 1.29-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index a8bd79d17..75d644df8 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.28 + 1.29-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index f75c9433f..e52774433 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.28 + 1.29-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 407ce3ec0..e5f70f112 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index cd5d72d2d..1de891e2b 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index f48fb585d..50bb90c7d 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 3c8df1df2..444f9336c 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 30128da60..4692c8531 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 5c9cadfb1..e944a6c7f 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 579440adb..251c2fcc0 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 33adfed8d..52fa51755 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index d44f7ffa4..0c7cb8205 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index c2e9cac50..b0d2476b3 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.28 + 1.29-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 11f8c96cb..800a38651 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.28 + 1.29-SNAPSHOT Java Microbenchmark Harness Parent From ec0740c2bfa23041f247654bc6fbf6fab7a4a417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 9 Mar 2021 16:30:54 +0100 Subject: [PATCH 246/342] CODETOOLS-7902838: JMH: Don't use fail() inside a try-catch catching an AssertionError --- .../java/org/openjdk/jmh/it/fails/AbruptFailureTest.java | 4 ++-- .../jmh/it/fails/FailingBenchmarkBenchSetupTest.java | 4 ++-- .../jmh/it/fails/FailingBenchmarkBenchTearDownTest.java | 4 ++-- .../org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java | 6 +++--- .../jmh/it/fails/FailingBenchmarkStateSetupTest.java | 6 +++--- .../jmh/it/fails/FailingBenchmarkStateTearDownTest.java | 6 +++--- .../jmh/it/fails/FailingForkedBenchStackProfilerTest.java | 6 +++--- .../org/openjdk/jmh/it/fails/FailingForkedBenchTest.java | 6 +++--- .../org/openjdk/jmh/it/fails/FailingForkedSetupTest.java | 6 +++--- .../org/openjdk/jmh/it/fails/FailingForkedTearDownTest.java | 6 +++--- .../openjdk/jmh/it/fails/FailingGroupBenchSetupTest.java | 6 +++--- .../openjdk/jmh/it/fails/FailingGroupBenchTearDownTest.java | 6 +++--- .../org/openjdk/jmh/it/fails/FailingGroupBenchTest.java | 6 +++--- .../openjdk/jmh/it/fails/FailingGroupStateSetupTest.java | 6 +++--- .../openjdk/jmh/it/fails/FailingGroupStateTearDownTest.java | 6 +++--- .../openjdk/jmh/it/fails/FailingThreadBenchSetupTest.java | 6 +++--- .../jmh/it/fails/FailingThreadBenchTearDownTest.java | 6 +++--- .../org/openjdk/jmh/it/fails/FailingThreadBenchTest.java | 6 +++--- .../openjdk/jmh/it/fails/FailingThreadStateSetupTest.java | 6 +++--- .../jmh/it/fails/FailingThreadStateTearDownTest.java | 6 +++--- .../it/fails/inherit/AbstractBenchmarkBenchSetupTest.java | 4 ++-- .../fails/inherit/AbstractBenchmarkBenchTearDownTest.java | 4 ++-- .../it/fails/inherit/AbstractBenchmarkStateSetupTest.java | 4 ++-- .../fails/inherit/AbstractBenchmarkStateTearDownTest.java | 4 ++-- .../jmh/it/fails/inherit/AbstractGroupBenchSetupTest.java | 4 ++-- .../it/fails/inherit/AbstractGroupBenchTearDownTest.java | 4 ++-- .../jmh/it/fails/inherit/AbstractGroupStateSetupTest.java | 4 ++-- .../it/fails/inherit/AbstractGroupStateTearDownTest.java | 4 ++-- .../jmh/it/fails/inherit/AbstractThreadBenchSetupTest.java | 4 ++-- .../it/fails/inherit/AbstractThreadBenchTearDownTest.java | 4 ++-- .../jmh/it/fails/inherit/AbstractThreadStateSetupTest.java | 4 ++-- .../it/fails/inherit/AbstractThreadStateTearDownTest.java | 4 ++-- .../it/fails/inherit/InheritBenchmarkBenchSetupTest.java | 4 ++-- .../it/fails/inherit/InheritBenchmarkBenchTearDownTest.java | 4 ++-- .../it/fails/inherit/InheritBenchmarkStateSetupTest.java | 4 ++-- .../it/fails/inherit/InheritBenchmarkStateTearDownTest.java | 4 ++-- .../jmh/it/fails/inherit/InheritGroupBenchSetupTest.java | 4 ++-- .../jmh/it/fails/inherit/InheritGroupBenchTearDownTest.java | 4 ++-- .../jmh/it/fails/inherit/InheritGroupStateSetupTest.java | 4 ++-- .../jmh/it/fails/inherit/InheritGroupStateTearDownTest.java | 4 ++-- .../jmh/it/fails/inherit/InheritThreadBenchSetupTest.java | 4 ++-- .../it/fails/inherit/InheritThreadBenchTearDownTest.java | 4 ++-- .../jmh/it/fails/inherit/InheritThreadStateSetupTest.java | 4 ++-- .../it/fails/inherit/InheritThreadStateTearDownTest.java | 4 ++-- 44 files changed, 105 insertions(+), 105 deletions(-) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/AbruptFailureTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/AbruptFailureTest.java index 214c89293..26bed8cbf 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/AbruptFailureTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/AbruptFailureTest.java @@ -57,7 +57,7 @@ public void test(ThreadParams tp) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { long time1 = System.nanoTime(); try { Options opt = new OptionsBuilder() @@ -67,7 +67,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected long time2 = System.nanoTime(); long delay = TimeUnit.NANOSECONDS.toSeconds(time2 - time1); diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchSetupTest.java index 153ca7d4f..9ac47ca28 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchSetupTest.java @@ -65,7 +65,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -74,7 +74,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTearDownTest.java index bc891941f..336582787 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTearDownTest.java @@ -65,7 +65,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -74,7 +74,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java index bb669dff5..5de936623 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java @@ -59,7 +59,7 @@ public void doTest() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -67,8 +67,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateSetupTest.java index e222c3298..952c5ec4b 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateSetupTest.java @@ -67,7 +67,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -75,8 +75,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateTearDownTest.java index 4f1388165..facebee39 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkStateTearDownTest.java @@ -67,7 +67,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -75,8 +75,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchStackProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchStackProfilerTest.java index b7c7ae998..a5cf5b1f3 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchStackProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchStackProfilerTest.java @@ -60,7 +60,7 @@ public void doTest() { } @Test(timeout = 60*1000) - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -70,8 +70,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchTest.java index e420de5a3..d108fef7c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchTest.java @@ -59,7 +59,7 @@ public void doTest() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -68,8 +68,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedSetupTest.java index ed999f5d5..ed374d9f4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedSetupTest.java @@ -65,7 +65,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -74,8 +74,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedTearDownTest.java index 755ffc186..d479c5136 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedTearDownTest.java @@ -65,7 +65,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -74,8 +74,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchSetupTest.java index 55d8e4d49..08c4b01b3 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchSetupTest.java @@ -67,7 +67,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -75,8 +75,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTearDownTest.java index a951904d0..c92b5a80d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTearDownTest.java @@ -67,7 +67,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -75,8 +75,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java index ea32aa35f..140f0452e 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java @@ -61,7 +61,7 @@ public void doTest() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -69,8 +69,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateSetupTest.java index 4b88f6fdd..9bea1212e 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateSetupTest.java @@ -69,7 +69,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -77,8 +77,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateTearDownTest.java index 7a069b472..f4d814e6f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupStateTearDownTest.java @@ -69,7 +69,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -77,8 +77,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchSetupTest.java index c2d6bfff2..aae99995e 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchSetupTest.java @@ -65,7 +65,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -73,8 +73,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTearDownTest.java index 8af2db6d0..ed0b0753c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTearDownTest.java @@ -65,7 +65,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -73,8 +73,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTest.java index 6952e911b..00e3bae5c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTest.java @@ -59,7 +59,7 @@ public void doTest() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -67,8 +67,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateSetupTest.java index 6eaf69b46..ed44ad6f6 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateSetupTest.java @@ -67,7 +67,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -75,8 +75,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateTearDownTest.java index 3aacf9745..8f6ab8e63 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadStateTearDownTest.java @@ -67,7 +67,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -75,8 +75,8 @@ public void invokeAPI() throws RunnerException { .build(); new Runner(opt).run(); - org.junit.Assert.fail("Should have failed"); - } catch (Throwable t) { + Assert.fail("Should have failed"); + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkBenchSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkBenchSetupTest.java index b57602092..c9cadba22 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkBenchSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkBenchSetupTest.java @@ -61,7 +61,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -70,7 +70,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkBenchTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkBenchTearDownTest.java index a4097dfa2..5e51c1539 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkBenchTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkBenchTearDownTest.java @@ -61,7 +61,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -70,7 +70,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkStateSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkStateSetupTest.java index 4063f23a8..f7dca0e34 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkStateSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkStateSetupTest.java @@ -63,7 +63,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -72,7 +72,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkStateTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkStateTearDownTest.java index 785e25e8c..6a81bfb68 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkStateTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractBenchmarkStateTearDownTest.java @@ -63,7 +63,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -72,7 +72,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchSetupTest.java index 8ddcccc13..1fb243b99 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchSetupTest.java @@ -63,7 +63,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -72,7 +72,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchTearDownTest.java index 0dbc55c26..1323a3505 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupBenchTearDownTest.java @@ -63,7 +63,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -72,7 +72,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateSetupTest.java index d3925d99c..3a00056e4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateSetupTest.java @@ -65,7 +65,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -74,7 +74,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateTearDownTest.java index e0026639a..c050bf97b 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractGroupStateTearDownTest.java @@ -65,7 +65,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -74,7 +74,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadBenchSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadBenchSetupTest.java index 391663caf..2c985639b 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadBenchSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadBenchSetupTest.java @@ -61,7 +61,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -70,7 +70,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadBenchTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadBenchTearDownTest.java index 93cf0037a..4b31b6246 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadBenchTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadBenchTearDownTest.java @@ -61,7 +61,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -70,7 +70,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadStateSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadStateSetupTest.java index 06484a399..ffbca4cd0 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadStateSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadStateSetupTest.java @@ -63,7 +63,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -72,7 +72,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadStateTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadStateTearDownTest.java index fc336c754..03b1a0991 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadStateTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/AbstractThreadStateTearDownTest.java @@ -63,7 +63,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -72,7 +72,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkBenchSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkBenchSetupTest.java index 4ce1d98c3..0e15a6263 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkBenchSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkBenchSetupTest.java @@ -58,7 +58,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -67,7 +67,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkBenchTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkBenchTearDownTest.java index 4d660711f..cec4a5f17 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkBenchTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkBenchTearDownTest.java @@ -58,7 +58,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -67,7 +67,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkStateSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkStateSetupTest.java index 8492a9181..16fedc6aa 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkStateSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkStateSetupTest.java @@ -60,7 +60,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -69,7 +69,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkStateTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkStateTearDownTest.java index 8fbd911f7..51a6dab8c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkStateTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritBenchmarkStateTearDownTest.java @@ -60,7 +60,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -69,7 +69,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchSetupTest.java index 0873617a6..44a43fb2c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchSetupTest.java @@ -60,7 +60,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -69,7 +69,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchTearDownTest.java index 59dae0d5a..5614bee43 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupBenchTearDownTest.java @@ -60,7 +60,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -69,7 +69,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateSetupTest.java index a90585d30..8f33ab845 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateSetupTest.java @@ -62,7 +62,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -71,7 +71,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateTearDownTest.java index 19ad02846..4eeb65706 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritGroupStateTearDownTest.java @@ -62,7 +62,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -71,7 +71,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadBenchSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadBenchSetupTest.java index ac3d631cb..02c23ad55 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadBenchSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadBenchSetupTest.java @@ -58,7 +58,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -67,7 +67,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadBenchTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadBenchTearDownTest.java index 464dcfbf9..5f5ba853d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadBenchTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadBenchTearDownTest.java @@ -58,7 +58,7 @@ public void test() { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -67,7 +67,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadStateSetupTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadStateSetupTest.java index bc69c1a7d..8cab56b9f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadStateSetupTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadStateSetupTest.java @@ -60,7 +60,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -69,7 +69,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadStateTearDownTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadStateTearDownTest.java index 5ffa587e9..2d6435581 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadStateTearDownTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/inherit/InheritThreadStateTearDownTest.java @@ -60,7 +60,7 @@ public void test(MyState state) { } @Test - public void invokeAPI() throws RunnerException { + public void invokeAPI() { try { Options opt = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) @@ -69,7 +69,7 @@ public void invokeAPI() throws RunnerException { new Runner(opt).run(); Assert.fail("Should have failed"); - } catch (Throwable t) { + } catch (RunnerException e) { // expected } } From 3b7bab948801128ef7d07aaacf0804f8a8c5d0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 9 Mar 2021 16:39:13 +0100 Subject: [PATCH 247/342] CODETOOLS-7902840: JMH: Fix *Statistics iterators to throw NoSuchElementException properly --- .../org/openjdk/jmh/util/ListStatistics.java | 4 ++++ .../openjdk/jmh/util/SingletonStatistics.java | 4 ++++ .../openjdk/jmh/util/TestListStatistics.java | 8 +++++++ .../jmh/util/TestMultisetStatistics.java | 24 +++++++++++++++++-- .../jmh/util/TestSingletonStatistics.java | 8 +++++++ 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java index d54af7525..da8995c5d 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/ListStatistics.java @@ -30,6 +30,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.Map; +import java.util.NoSuchElementException; /** * Calculate statistics over a list of doubles. @@ -181,6 +182,9 @@ public boolean hasNext() { @Override public Map.Entry next() { + if (!hasNext()) { + throw new NoSuchElementException("No more elements."); + } return new AbstractMap.SimpleImmutableEntry<>(values[currentIndex++], 1L); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java b/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java index dc23796a1..5e0a40112 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/SingletonStatistics.java @@ -27,6 +27,7 @@ import java.util.AbstractMap; import java.util.Iterator; import java.util.Map; +import java.util.NoSuchElementException; /** * Calculate statistics with just a single value. @@ -98,6 +99,9 @@ public boolean hasNext() { @Override public Map.Entry next() { + if (entryReturned) { + throw new NoSuchElementException("No more elements."); + } entryReturned = true; return new AbstractMap.SimpleImmutableEntry<>(value, 1L); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java index 193b74a1a..40959151e 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java @@ -30,6 +30,7 @@ import java.util.Iterator; import java.util.Map; +import java.util.NoSuchElementException; import static org.junit.Assert.assertEquals; @@ -407,7 +408,14 @@ public strictfp void testRawDataIterator() { Assert.assertEquals(entry.getKey(), item); Assert.assertEquals(entry.getValue().longValue(), 1L); } + Assert.assertFalse(listIter.hasNext()); + try { + listIter.next(); + Assert.fail("Expected NoSuchElementException"); + } catch (NoSuchElementException e) { + // expected + } } } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java index 7a203cbae..e77f34c78 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java @@ -28,7 +28,9 @@ import org.junit.BeforeClass; import org.junit.Test; +import java.util.Iterator; import java.util.Map; +import java.util.NoSuchElementException; import static org.junit.Assert.assertEquals; @@ -394,7 +396,8 @@ public strictfp void testHistogram_increasing() { @Test public strictfp void testRawDataIterator_no_duplicates() { int itemCount = 0; - for (Map.Entry entry : Utils.adaptForLoop(instance.getRawData())) { + Iterator> it = instance.getRawData(); + for (Map.Entry entry : Utils.adaptForLoop(it)) { Assert.assertEquals(entry.getValue().longValue(), 1L); // Check if key (the actual data) is in the VALUES collection, @@ -413,6 +416,14 @@ public strictfp void testRawDataIterator_no_duplicates() { itemCount++; } Assert.assertEquals(itemCount, VALUES.length); + + Assert.assertFalse(it.hasNext()); + try { + it.next(); + Assert.fail("Expected NoSuchElementException"); + } catch (NoSuchElementException e) { + // expected + } } /** @@ -426,12 +437,21 @@ public strictfp void testRawDataIterator_duplicates() { s.addValue(c * 10, c); } + Iterator> it = s.getRawData(); int itemCount = 0; - for (Map.Entry entry : Utils.adaptForLoop(s.getRawData())) { + for (Map.Entry entry : Utils.adaptForLoop(it)) { Assert.assertEquals(entry.getKey(), (double)(entry.getValue() * 10)); itemCount++; } Assert.assertEquals(itemCount, 10); + + Assert.assertFalse(it.hasNext()); + try { + it.next(); + Assert.fail("Expected NoSuchElementException"); + } catch (NoSuchElementException e) { + // expected + } } } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java index 145dba5be..3e363608a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java @@ -30,6 +30,7 @@ import java.util.Iterator; import java.util.Map; +import java.util.NoSuchElementException; import static org.junit.Assert.assertEquals; @@ -258,7 +259,14 @@ public strictfp void testRawDataIterator() { Map.Entry entry = singIter.next(); Assert.assertEquals(entry.getKey(), VALUE); Assert.assertEquals(entry.getValue().longValue(), 1L); + Assert.assertFalse(singIter.hasNext()); + try { + singIter.next(); + Assert.fail("Expected NoSuchElementException"); + } catch (NoSuchElementException e) { + // expected + } } } From f8eef4a83bf02a16db2b56bfdd112e94bf6a4555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Wed, 10 Mar 2021 10:15:58 +0100 Subject: [PATCH 248/342] CODETOOLS-7902841: JMH: Reflow JMH file locking code --- .../java/org/openjdk/jmh/runner/Runner.java | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index 102bd0c67..d9aadda59 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -185,39 +185,32 @@ public Collection run() throws RunnerException { out.println("# WARNING: JMH lock is ignored by user request, make sure no other JMH instances are running"); return internalRun(); } - FileChannel channel = null; - FileLock lock = null; + + final String tailMsg = " the JMH lock (" + JMH_LOCK_FILE + "), exiting. Use -Djmh.ignoreLock=true to forcefully continue."; + + File lockFile; try { + lockFile = new File(JMH_LOCK_FILE); + lockFile.createNewFile(); + // Make sure the lock file is world-writeable, otherwise the lock file created by current // user would not work for any other user, always failing the run. - File file = new File(JMH_LOCK_FILE); - file.createNewFile(); - file.setWritable(true, false); - - channel = new RandomAccessFile(file, "rw").getChannel(); - - try { - lock = channel.tryLock(); - } catch (OverlappingFileLockException e) { - // fall-through - } + lockFile.setWritable(true, false); + } catch (IOException e) { + throw new RunnerException("ERROR: Unable to create" + tailMsg, e); + } + try (RandomAccessFile raf = new RandomAccessFile(lockFile, "rw"); + FileLock lock = raf.getChannel().tryLock()) { if (lock == null) { - throw new RunnerException("ERROR: Unable to acquire the JMH lock (" + JMH_LOCK_FILE + "): already taken by another JMH instance, exiting. Use -Djmh.ignoreLock=true to forcefully continue."); + // Lock acquisition failed, pretend this was the overlap. + throw new OverlappingFileLockException(); } - return internalRun(); + } catch (OverlappingFileLockException e) { + throw new RunnerException("ERROR: Another JMH instance might be running. Unable to acquire" + tailMsg); } catch (IOException e) { - throw new RunnerException("ERROR: Exception while trying to acquire the JMH lock (" + JMH_LOCK_FILE + "), exiting. Use -Djmh.ignoreLock=true to forcefully continue.", e); - } finally { - try { - if (lock != null) { - lock.release(); - } - } catch (IOException e) { - // do nothing - } - FileUtils.safelyClose(channel); + throw new RunnerException("ERROR: Unexpected exception while trying to acquire" + tailMsg, e); } } From 3787066feb1322a704076f31e76d02bebf28dec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Wed, 10 Mar 2021 10:18:12 +0100 Subject: [PATCH 249/342] CODETOOLS-7902839: JMH: Replace the use of ThreadLocal with explicitly managed thread map * CODETOOLS-7902839: JMH: Replace the use of ThreadLocal with explicitly managed thread map * Rename a bit --- .../openjdk/jmh/runner/BenchmarkHandler.java | 74 ++++++++++++------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index b79a0b93a..dd7ecc69e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -53,47 +53,35 @@ class BenchmarkHandler { */ private final ExecutorService executor; - // (Aleksey) Forgive me, Father, for I have sinned. - private final ThreadLocal threadData; + private final ConcurrentMap workerData; + private final BlockingQueue tps; private final OutputFormat out; private final List profilers; private final List profilersRev; + private final Class clazz; private final Method method; public BenchmarkHandler(OutputFormat out, Options options, BenchmarkParams executionParams) { String target = executionParams.generatedBenchmark(); int lastDot = target.lastIndexOf('.'); - final Class clazz = ClassUtils.loadClass(target.substring(0, lastDot)); + clazz = ClassUtils.loadClass(target.substring(0, lastDot)); - this.method = BenchmarkHandler.findBenchmarkMethod(clazz, target.substring(lastDot + 1)); - this.profilers = ProfilerFactory.getSupportedInternal(options.getProfilers()); - this.profilersRev = new ArrayList<>(profilers); + method = BenchmarkHandler.findBenchmarkMethod(clazz, target.substring(lastDot + 1)); + + profilers = ProfilerFactory.getSupportedInternal(options.getProfilers()); + profilersRev = new ArrayList<>(profilers); Collections.reverse(profilersRev); - final BlockingQueue tps = new ArrayBlockingQueue<>(executionParams.getThreads()); + tps = new ArrayBlockingQueue<>(executionParams.getThreads()); tps.addAll(distributeThreads(executionParams.getThreads(), executionParams.getThreadGroups())); - this.threadData = new ThreadLocal() { - @Override - protected ThreadData initialValue() { - try { - Object o = clazz.getConstructor().newInstance(); - ThreadParams t = tps.poll(); - if (t == null) { - throw new IllegalStateException("Cannot get another thread params"); - } - return new ThreadData(o, t); - } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { - throw new RuntimeException("Class " + clazz.getName() + " instantiation error ", e); - } - } - }; + workerData = new ConcurrentHashMap<>(); this.out = out; try { - this.executor = EXECUTOR_TYPE.createExecutor(executionParams.getThreads(), executionParams.getBenchmark()); + executor = EXECUTOR_TYPE.createExecutor(executionParams.getThreads(), executionParams.getBenchmark()); } catch (Exception e) { throw new IllegalStateException(e); } @@ -280,6 +268,9 @@ protected void stopProfilers(BenchmarkParams benchmarkParams, IterationParams it * Do required shutdown actions. */ public void shutdown() { + // No transient data is shared between benchmarks, purge it. + workerData.clear(); + if (EXECUTOR_TYPE.shutdownForbidden() || (executor == null)) { return; } @@ -431,6 +422,31 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa return result; } + private WorkerData newWorkerData(Thread worker) { + WorkerData wd = workerData.get(worker); + if (wd != null) { + return wd; + } + + try { + Object o = clazz.getConstructor().newInstance(); + ThreadParams t = tps.poll(); + if (t == null) { + throw new IllegalStateException("Cannot get another thread params"); + } + + wd = new WorkerData(o, t); + WorkerData exist = workerData.put(worker, wd); + if (exist != null) { + throw new IllegalStateException("Duplicate thread data"); + } + + return wd; + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + throw new RuntimeException("Class " + clazz.getName() + " instantiation error ", e); + } + } + /** * Worker body. */ @@ -448,9 +464,10 @@ public BenchmarkTaskResult call() throws Exception { // bind the executor thread runner = Thread.currentThread(); - // go for the run - ThreadData td = threadData.get(); - return (BenchmarkTaskResult) method.invoke(td.instance, control, td.params); + // poll the current data, or instantiate in this thread, if needed + WorkerData wd = newWorkerData(runner); + + return (BenchmarkTaskResult) method.invoke(wd.instance, control, wd.params); } catch (Throwable e) { // about to fail the iteration; @@ -481,13 +498,14 @@ public BenchmarkTaskResult call() throws Exception { runner = null; } } + } /** * Handles thread-local data for each worker that should not change * between the iterations. */ - private static class ThreadData { + private static class WorkerData { /** * Synthetic benchmark instance, which holds the benchmark metadata. * Expected to be touched by a single thread only. @@ -500,7 +518,7 @@ private static class ThreadData { */ final ThreadParams params; - public ThreadData(Object instance, ThreadParams params) { + public WorkerData(Object instance, ThreadParams params) { this.instance = instance; this.params = params; } From 41548a7ae931f70ea84d2f85124a278d97000e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Wed, 10 Mar 2021 10:18:27 +0100 Subject: [PATCH 250/342] CODETOOLS-7902834: JMHSample_25_API_GA selectToBreed selection bug --- .../org/openjdk/jmh/samples/JMHSample_25_API_GA.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java index 4d4ad178e..8b645c900 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_25_API_GA.java @@ -182,11 +182,15 @@ public Chromosome selectToBreed() { double thresh = Math.random() * totalScore; for (Chromosome c : list) { - if (thresh < 0) return c; - thresh =- c.score(); + if (thresh >= 0) { + thresh -= c.score(); + } else { + return c; + } } - throw new IllegalStateException("Can not choose"); + // Return the last + return list.get(list.size() - 1); } public int size() { From 01ae29cb288f1334b920b2f856f62d2073ef457c Mon Sep 17 00:00:00 2001 From: Henri Tremblay Date: Wed, 10 Mar 2021 12:25:34 +0000 Subject: [PATCH 251/342] Upgrade to JUnit 4.13.2 Reviewed-by: shade --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 800a38651..733378530 100644 --- a/pom.xml +++ b/pom.xml @@ -265,7 +265,7 @@ questions. junit junit - 4.10 + 4.13.2 test From cf8a3b044f7bb47d9401ed731bc1f1af7333e4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Wed, 10 Mar 2021 13:42:15 +0100 Subject: [PATCH 252/342] CODETOOLS-7902844: JMH: Clean up jmh.separateClassLoader support --- .../separatecl/SeparateClassLoaderTest.java | 62 +++++++++++++++++++ .../java/org/openjdk/jmh/util/ClassUtils.java | 12 ++-- 2 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/separatecl/SeparateClassLoaderTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/separatecl/SeparateClassLoaderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/separatecl/SeparateClassLoaderTest.java new file mode 100644 index 000000000..08f9f65ff --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/separatecl/SeparateClassLoaderTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.separatecl; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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 java.net.URI; +import java.net.URISyntaxException; +import java.security.NoSuchAlgorithmException; +import java.util.concurrent.TimeUnit; + +@State(Scope.Benchmark) +public class SeparateClassLoaderTest { + + @Benchmark + @BenchmarkMode(Mode.All) + @Warmup(iterations = 0) + @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS) + @Fork(1) + public void test() { + Fixtures.work(); + } + + @Test + public void invokeAPI() throws RunnerException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .jvmArgsAppend("-Djmh.separateClassLoader=true") + .build(); + new Runner(opts).run(); + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java index 397a38150..a3ccb680e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java @@ -25,6 +25,7 @@ package org.openjdk.jmh.util; import java.io.File; +import java.io.IOException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; @@ -72,7 +73,7 @@ public static Class loadClass(String className) { return Class.forName(className); } - // load the class in a different classloader + // Load the class in a different classloader String classPathValue = System.getProperty("java.class.path"); String[] classPath = classPathValue.split(File.pathSeparator); URL[] classPathUrl = new URL[classPath.length]; @@ -80,12 +81,15 @@ public static Class loadClass(String className) { try { classPathUrl[i] = new File(classPath[i]).toURI().toURL(); } catch (MalformedURLException ex) { - throw new RuntimeException("Error parsing the value of property java.class.path: " + classPathValue, ex); + throw new IllegalStateException("Error parsing the value of property java.class.path: " + classPathValue, ex); } } - URLClassLoader loader = new URLClassLoader(classPathUrl); - return loader.loadClass(className); + try (URLClassLoader loader = new URLClassLoader(classPathUrl)) { + return loader.loadClass(className); + } catch (IOException e) { + throw new IllegalStateException(e); + } } catch (ClassNotFoundException ex) { throw new IllegalArgumentException("Benchmark does not match a class", ex); } From ce2042a540e9ccf20ef4c4b25b55f70bca3d29f6 Mon Sep 17 00:00:00 2001 From: Henri Tremblay Date: Wed, 10 Mar 2021 15:18:57 +0000 Subject: [PATCH 253/342] Ignore IntelliJ files and Maven target directory Reviewed-by: shade --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..7f995f335 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.iml +target/ From 73a33e7511628083a83334773fc255ec72daeba4 Mon Sep 17 00:00:00 2001 From: Niels Basjes Date: Wed, 24 Mar 2021 07:57:23 +0000 Subject: [PATCH 254/342] 7902853: JMH: Fix lint and deprecation warnings Co-authored-by: Aleksey Shipilev Reviewed-by: shade --- .../java/org/openjdk/jmh/ct/CompileTest.java | 45 ++++++++++-- .../ct/multsession/MultipleSessionsTest.java | 2 +- .../jmh/it/asymm/ExactThreadCountTest.java | 2 +- .../jmh/it/asymm/Zero1ThreadCountTest.java | 2 +- .../jmh/it/asymm/Zero2ThreadCountTest.java | 2 +- .../jmh/it/batchsize/BatchSizeSanityTest.java | 2 +- .../jmh/it/batchsize/OpsPerInvSanityTest.java | 2 +- .../jmh/it/bulkwarmup/NonForkedModesTest.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode0_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode1_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode2_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode3_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode4_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode5_Test.java | 2 +- .../jmh/it/bulkwarmup/WarmupMode6_Test.java | 2 +- .../jmh/it/control/ControlStartStopTest.java | 2 +- .../BenchmarkIterationDagOrderTest.java | 2 +- .../dagorder/BenchmarkTrialDagOrderTest.java | 2 +- .../MixedBGTIterationDagOrderTest.java | 2 +- .../dagorder/MixedBGTTrialDagOrderTest.java | 2 +- .../MixedBTGIterationDagOrderTest.java | 2 +- .../dagorder/MixedBTGTrialDagOrderTest.java | 2 +- .../MixedGBTIterationDagOrderTest.java | 2 +- .../dagorder/MixedGBTTrialDagOrderTest.java | 2 +- .../MixedGTBIterationDagOrderTest.java | 2 +- .../dagorder/MixedGTBTrialDagOrderTest.java | 2 +- .../MixedTBGIterationDagOrderTest.java | 2 +- .../dagorder/MixedTBGTrialDagOrderTest.java | 2 +- .../MixedTGBIterationDagOrderTest.java | 2 +- .../dagorder/MixedTGBTrialDagOrderTest.java | 2 +- .../dagorder/ThreadIterationDagOrderTest.java | 2 +- .../it/dagorder/ThreadTrialDagOrderTest.java | 2 +- .../jmh/it/errors/EmbeddedErrorsTest.java | 2 +- .../it/errors/EmbeddedThrowExceptionTest.java | 2 +- .../EmbeddedThrowRuntimeExceptionTest.java | 2 +- .../jmh/it/errors/ForkedErrorsTest.java | 2 +- .../jmh/it/errors/ForkedExit0Test.java | 2 +- .../jmh/it/errors/ForkedExit1Test.java | 2 +- .../jmh/it/errors/ForkedExit42Test.java | 2 +- .../jmh/it/errors/ForkedHalt1Test.java | 2 +- .../jmh/it/errors/ForkedHalt42Test.java | 2 +- .../errors/ForkedStuckShutdownHookTest.java | 2 +- .../jmh/it/errors/ForkedStuckThreadTest.java | 2 +- .../it/errors/ForkedThrowExceptionTest.java | 2 +- .../ForkedThrowRuntimeExceptionTest.java | 2 +- .../it/fails/FailingBenchmarkBenchTest.java | 2 +- .../FailingForkedBenchStackProfilerTest.java | 2 +- .../jmh/it/fails/FailingForkedBenchTest.java | 2 +- .../jmh/it/fails/FailingGroupBenchTest.java | 2 +- .../jmh/it/fails/FailingThreadBenchTest.java | 2 +- .../interorder/BenchmarkBenchOrderTest.java | 2 +- .../interorder/BenchmarkStateOrderTest.java | 2 +- .../it/interorder/GroupBenchOrderTest.java | 2 +- .../it/interorder/GroupStateOrderTest.java | 2 +- .../it/interorder/ThreadBenchOrderTest.java | 2 +- .../it/interorder/ThreadStateOrderTest.java | 2 +- .../jmh/it/params/CollidingParamsTest.java | 2 +- .../params/EmptyLeadingStringParamTest.java | 2 +- .../it/params/EmptyMiddleStringParamTest.java | 2 +- .../params/EmptyTrailingStringParamTest.java | 2 +- .../EnumBenchParamImplicitSequenceTest.java | 2 +- .../jmh/it/params/EnumParamSequenceTest.java | 2 +- .../EnumParamToStringOverridingTest.java | 2 +- .../EnumStateParamImplicitSequenceTest.java | 2 +- .../jmh/it/params/EscapedParamsTest.java | 2 +- .../it/params/IsolatedParamSequenceTest.java | 2 +- .../jmh/it/params/OverridingParamsTest.java | 2 +- .../jmh/it/params/QuotedParamsTest.java | 2 +- .../org/openjdk/jmh/it/params/Shared.java | 2 +- .../openjdk/jmh/it/params/UTF8ParamsTest.java | 2 +- .../jmh/it/profilers/ChangeJVMOptsTest.java | 2 +- .../CountingExternalProfilerTest.java | 2 +- .../it/profilers/DuplicateProfilerTest.java | 2 +- .../jmh/it/profilers/ItExternalProfiler.java | 2 +- .../it/profilers/order/ProfilerOrderTest.java | 2 +- .../jmh/it/threads/MaxThreadCountTest.java | 2 +- .../jmh/it/threads/OneThreadCountTest.java | 2 +- .../jmh/it/threads/TwoThreadCountTest.java | 2 +- .../GroupThreadStateHelperTimesTest.java | 2 +- .../BenchmarkInvocationFailureTimesTest.java | 2 +- .../BenchmarkIterationFailureTimesTest.java | 2 +- .../fail/BenchmarkTrialFailureTimesTest.java | 2 +- .../fail/GroupInvocationFailureTimesTest.java | 2 +- .../fail/GroupIterationFailureTimesTest.java | 2 +- .../fail/GroupTrialFailureTimesTest.java | 2 +- .../ThreadInvocationFailureTimesTest.java | 2 +- .../fail/ThreadIterationFailureTimesTest.java | 2 +- .../fail/ThreadTrialFailureTimesTest.java | 2 +- .../generators/core/BenchmarkGenerator.java | 2 +- .../java/org/openjdk/jmh/BlackholeTest.java | 2 +- .../openjdk/jmh/profile/PerfParseTest.java | 10 +-- .../jmh/profile/SafepointsProfilerTest.java | 2 +- .../jmh/results/ResultAggregationTest.java | 68 ++++++++++--------- .../jmh/results/TestAverageTimeResult.java | 12 ++-- .../jmh/results/TestSampleTimeResult.java | 8 ++- .../jmh/results/TestSingleShotResult.java | 8 ++- .../jmh/results/TestThroughputResult.java | 16 +++-- .../jmh/results/format/ResultFormatTest.java | 2 +- .../jmh/runner/DistributeGroupsTest.java | 2 +- .../jmh/runner/parameters/TimeValueTest.java | 2 +- .../jmh/util/BoundedPriorityQueueTest.java | 2 +- .../org/openjdk/jmh/util/MultisetsTest.java | 2 +- .../org/openjdk/jmh/util/TestClassUtils.java | 2 +- .../openjdk/jmh/util/TestListStatistics.java | 52 +++++++------- .../jmh/util/TestMultisetStatistics.java | 50 +++++++------- .../jmh/util/TestSingletonStatistics.java | 27 ++++---- .../java/org/openjdk/jmh/util/TestUtil.java | 2 +- .../test/java/org/openjdk/jmh/util/Util.java | 2 +- .../openjdk/jmh/util/lines/TestLineTest.java | 2 +- 109 files changed, 272 insertions(+), 222 deletions(-) diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java index b304f6337..33f02c36a 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java @@ -24,7 +24,11 @@ */ package org.openjdk.jmh.ct; -import junit.framework.Assert; +import org.junit.Assert; +import org.openjdk.jmh.ct.benchmark.PublicStaticBenchmarkTest; +import org.openjdk.jmh.ct.benchmark.PublicSynchronizedStaticBenchmarkStateBenchmarkTest; +import org.openjdk.jmh.ct.other.GenericReturnTest; +import org.openjdk.jmh.ct.other.SwingTest; import org.openjdk.jmh.generators.asm.ASMGeneratorSource; import org.openjdk.jmh.generators.core.BenchmarkGenerator; import org.openjdk.jmh.generators.core.GeneratorSource; @@ -88,7 +92,7 @@ private static boolean doTest(Class klass, InMemoryGeneratorDestination desti if (GENERATOR_TYPE.equalsIgnoreCase("reflection")) { RFGeneratorSource source = new RFGeneratorSource(); source.processClasses(klass); - return doTestOther(source, destination); + return doTestOther(klass, source, destination); } else if (GENERATOR_TYPE.equalsIgnoreCase("asm")) { ASMGeneratorSource source = new ASMGeneratorSource(); String name = "/" + klass.getCanonicalName().replaceAll("\\.", "/") + ".class"; @@ -97,15 +101,44 @@ private static boolean doTest(Class klass, InMemoryGeneratorDestination desti } catch (IOException e) { throw new IllegalStateException(name, e); } - return doTestOther(source, destination); + return doTestOther(klass, source, destination); } else if (GENERATOR_TYPE.equalsIgnoreCase("annprocess")) { return doTestAnnprocess(klass, destination); } else throw new IllegalStateException("Unhandled compile test generator: " + GENERATOR_TYPE); } + private static Collection javacOptions(boolean annProc, Class klass) { + // These tests print warnings (as designed), so -Werror fails. + if (klass.equals(SwingTest.class)) { + if (annProc) { + return Collections.emptyList(); + } else { + return Collections.singleton("-proc:none"); + } + } + + // These tests fail when generated code references the static target + // through the instance. + if (klass.equals(GenericReturnTest.class) || + klass.equals(PublicStaticBenchmarkTest.class) || + klass.equals(PublicSynchronizedStaticBenchmarkStateBenchmarkTest.class)) { + if (annProc) { + return Arrays.asList("-Xlint:all,-processing,-static", "-Werror"); + } else { + return Arrays.asList("-proc:none", "-Xlint:all,-static", "-Werror"); + } + } + + // Regular tests should compile with full lint and Werror. + if (annProc) { + return Arrays.asList("-Xlint:all,-processing", "-Werror"); + } else { + return Arrays.asList("-proc:none", "-Xlint:all", "-Werror"); + } + } - public static boolean doTestOther(GeneratorSource source, InMemoryGeneratorDestination destination) { + public static boolean doTestOther(Class klass, GeneratorSource source, InMemoryGeneratorDestination destination) { BenchmarkGenerator gen = new BenchmarkGenerator(); gen.generate(source, destination); gen.complete(source, destination); @@ -125,7 +158,7 @@ public static boolean doTestOther(GeneratorSource source, InMemoryGeneratorDesti sources.add(new JavaSourceFromString(e.getKey(), e.getValue())); } - JavaCompiler.CompilationTask task = javac.getTask(null, fm, diagnostics, Collections.singleton("-proc:none"), null, sources); + JavaCompiler.CompilationTask task = javac.getTask(null, fm, diagnostics, javacOptions(false, klass), null, sources); boolean success = task.call(); if (!success) { @@ -158,7 +191,7 @@ private static boolean doTestAnnprocess(Class klass, InMemoryGeneratorDestina String file = Utils.join(lines, "\n"); Collection sources = Collections.singleton(new JavaSourceFromString(shortName, file)); - JavaCompiler.CompilationTask task = javac.getTask(null, fm, diagnostics, null, null, sources); + JavaCompiler.CompilationTask task = javac.getTask(null, fm, diagnostics, javacOptions(true, klass), null, sources); boolean success = task.call(); diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/MultipleSessionsTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/MultipleSessionsTest.java index 197ffefd4..ccc459545 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/MultipleSessionsTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/MultipleSessionsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.ct.multsession; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.ct.InMemoryGeneratorDestination; import org.openjdk.jmh.generators.core.BenchmarkGenerator; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/ExactThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/ExactThreadCountTest.java index 3695d1071..474c366ea 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/ExactThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/ExactThreadCountTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.asymm; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java index 8e5c28492..4bd558637 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.asymm; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java index c487c3f86..29a1390f4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.asymm; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java index 8427eea4d..afae58aa4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/BatchSizeSanityTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.batchsize; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java index cedc2876d..f25eebc27 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/batchsize/OpsPerInvSanityTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.batchsize; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java index 8203d5cd3..bae058425 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/NonForkedModesTest.java @@ -43,7 +43,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; @State(Scope.Thread) public class NonForkedModesTest { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java index 3397a7ecb..79f91a9d4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode0_Test.java @@ -42,7 +42,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java index 49fd73ed5..48764c6a9 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode1_Test.java @@ -42,7 +42,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java index c90d8aca6..b2b5267ac 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode2_Test.java @@ -42,7 +42,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java index 615d62833..81f3a6ee0 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode3_Test.java @@ -42,7 +42,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java index 5d4ed378f..43b27f013 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode4_Test.java @@ -42,7 +42,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java index b69b9963a..2f3e9c7cd 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode5_Test.java @@ -43,7 +43,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java index 62752f7e2..960710315 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/bulkwarmup/WarmupMode6_Test.java @@ -43,7 +43,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; /** * Tests if harness honors warmup command line settings like: diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStartStopTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStartStopTest.java index 98dbadab2..ca1b0f91c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStartStopTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStartStopTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.control; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Control; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkIterationDagOrderTest.java index c6fd3652d..878584e3c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkIterationDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkIterationDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkTrialDagOrderTest.java index 9b9f4a794..d15f34550 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkTrialDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/BenchmarkTrialDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTIterationDagOrderTest.java index 5e73ce365..dbc370fbc 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTIterationDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTIterationDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTTrialDagOrderTest.java index 8d4422294..bf3ab23cf 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTTrialDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBGTTrialDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGIterationDagOrderTest.java index f69453f0e..285dd62aa 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGIterationDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGIterationDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGTrialDagOrderTest.java index 97e77f088..583b3a686 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGTrialDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedBTGTrialDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTIterationDagOrderTest.java index f5c9cbc3f..48719cf50 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTIterationDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTIterationDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTTrialDagOrderTest.java index 7b31def86..b02ebfe29 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTTrialDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGBTTrialDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBIterationDagOrderTest.java index 8da6e759f..112787b63 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBIterationDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBIterationDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBTrialDagOrderTest.java index 7af69b93e..8486314b1 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBTrialDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedGTBTrialDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGIterationDagOrderTest.java index 288ba5387..c82fd66d3 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGIterationDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGIterationDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGTrialDagOrderTest.java index 0ad2ca7b1..bf7b03aa8 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGTrialDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTBGTrialDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBIterationDagOrderTest.java index 4720ca16c..63201aca4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBIterationDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBIterationDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBTrialDagOrderTest.java index e2f6a204b..c4e0114f1 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBTrialDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/MixedTGBTrialDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadIterationDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadIterationDagOrderTest.java index 52ec78679..55242aa58 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadIterationDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadIterationDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadTrialDagOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadTrialDagOrderTest.java index eff447179..ca8d8d8a3 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadTrialDagOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/dagorder/ThreadTrialDagOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.dagorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedErrorsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedErrorsTest.java index 56ea580d4..dced5021d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedErrorsTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedErrorsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowExceptionTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowExceptionTest.java index 8ac16a724..0d00de15f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowExceptionTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowExceptionTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowRuntimeExceptionTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowRuntimeExceptionTest.java index 9e0082563..0157950c9 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowRuntimeExceptionTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowRuntimeExceptionTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedErrorsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedErrorsTest.java index 7ee3b9ca5..437143f62 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedErrorsTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedErrorsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit0Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit0Test.java index c4db876ca..b6ab80ed7 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit0Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit0Test.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit1Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit1Test.java index 46386a69c..6073c3b02 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit1Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit1Test.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit42Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit42Test.java index f89803cb5..8d638c7ce 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit42Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit42Test.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt1Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt1Test.java index aa53a382a..7cdabf66f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt1Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt1Test.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt42Test.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt42Test.java index fbf91e4f1..468639019 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt42Test.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt42Test.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckShutdownHookTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckShutdownHookTest.java index b065e7b71..5d76d7910 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckShutdownHookTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckShutdownHookTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckThreadTest.java index 47ab60ed5..ab4ccdd45 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckThreadTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedStuckThreadTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowExceptionTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowExceptionTest.java index add89986f..396ea3dad 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowExceptionTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowExceptionTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowRuntimeExceptionTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowRuntimeExceptionTest.java index 8ba0b774f..0c67d8ae4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowRuntimeExceptionTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowRuntimeExceptionTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.errors; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Measurement; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java index 5de936623..7805ca9e9 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingBenchmarkBenchTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.fails; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchStackProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchStackProfilerTest.java index a5cf5b1f3..ce787b5f8 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchStackProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchStackProfilerTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.fails; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchTest.java index d108fef7c..92e6ed7ae 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingForkedBenchTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.fails; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java index 140f0452e..7d9ec3b33 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingGroupBenchTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.fails; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTest.java index 00e3bae5c..e6bc34f5e 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/fails/FailingThreadBenchTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.fails; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkBenchOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkBenchOrderTest.java index 3d33d4567..679485127 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkBenchOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkBenchOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.interorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkStateOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkStateOrderTest.java index 16094a9d2..a47bb3ebd 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkStateOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkStateOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.interorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupBenchOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupBenchOrderTest.java index 271afc4a0..5e312b0b3 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupBenchOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupBenchOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.interorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupStateOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupStateOrderTest.java index 59353fbe7..f04165ae6 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupStateOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupStateOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.interorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadBenchOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadBenchOrderTest.java index 9144e351a..0c8309c7b 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadBenchOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadBenchOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.interorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadStateOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadStateOrderTest.java index 5363dc0d3..72b415ba2 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadStateOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadStateOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.interorder; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/CollidingParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/CollidingParamsTest.java index 96c04baad..767646c21 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/CollidingParamsTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/CollidingParamsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java index 83e34acba..d2906936c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java index 82fe6dc97..9c466b65f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java index 7e3bd073e..bbac7ae2f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java index 73c6fde6f..443d796f0 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java index 4cde66ba1..f81cf6575 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java index 638263b3f..270dddaa0 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java index 81adc3625..6275947e5 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EscapedParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EscapedParamsTest.java index 999a5ad2a..541c24705 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EscapedParamsTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EscapedParamsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/IsolatedParamSequenceTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/IsolatedParamSequenceTest.java index 61d532582..c514c1fe3 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/IsolatedParamSequenceTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/IsolatedParamSequenceTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/OverridingParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/OverridingParamsTest.java index 361138724..7d1500321 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/OverridingParamsTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/OverridingParamsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java index 1a3c55347..a02ed0fcc 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java index 81dfd7035..ba816200b 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.results.RunResult; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java index 48efd907d..65d130a8f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.params; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java index a6cff8ac4..9ef3a48ff 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.profilers; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java index cdc3ba8b5..54ce83e0a 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.profilers; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java index 31f9b8ab1..540673b4a 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.profilers; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ItExternalProfiler.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ItExternalProfiler.java index 181057e87..5143dceff 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ItExternalProfiler.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ItExternalProfiler.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.profilers; -import junit.framework.Assert; +import org.junit.Assert; import org.openjdk.jmh.infra.BenchmarkParams; import org.openjdk.jmh.profile.ExternalProfiler; import org.openjdk.jmh.results.BenchmarkResult; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ProfilerOrderTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ProfilerOrderTest.java index 292c0f9f7..410a1f832 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ProfilerOrderTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ProfilerOrderTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.profilers.order; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java index 96a10475f..edb471da5 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.threads; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java index 0761238a7..70e58816b 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.threads; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java index 59b2c7425..36af356a2 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.threads; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupThreadStateHelperTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupThreadStateHelperTimesTest.java index 9a0b79fd7..4c2064b15 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupThreadStateHelperTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/GroupThreadStateHelperTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkInvocationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkInvocationFailureTimesTest.java index 2818c0b72..f1f619a8d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkInvocationFailureTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkInvocationFailureTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times.fail; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkIterationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkIterationFailureTimesTest.java index 1429952d8..e55ceb579 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkIterationFailureTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkIterationFailureTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times.fail; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkTrialFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkTrialFailureTimesTest.java index fe399c8b5..4b37e4bd6 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkTrialFailureTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/BenchmarkTrialFailureTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times.fail; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupInvocationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupInvocationFailureTimesTest.java index 59d5a8238..cfedce092 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupInvocationFailureTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupInvocationFailureTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times.fail; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupIterationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupIterationFailureTimesTest.java index dbc65a7bb..4de0fe32b 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupIterationFailureTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupIterationFailureTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times.fail; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupTrialFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupTrialFailureTimesTest.java index c7526cd2c..875fdfd54 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupTrialFailureTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/GroupTrialFailureTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times.fail; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadInvocationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadInvocationFailureTimesTest.java index f64c6adaf..7baf08cef 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadInvocationFailureTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadInvocationFailureTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times.fail; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadIterationFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadIterationFailureTimesTest.java index e7825c9e0..97d21ae70 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadIterationFailureTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadIterationFailureTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times.fail; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadTrialFailureTimesTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadTrialFailureTimesTest.java index 73cdc3555..7cd6329df 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadTrialFailureTimesTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/times/fail/ThreadTrialFailureTimesTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.it.times.fail; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index 72b1ddcdd..d870a9b94 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -1022,7 +1022,7 @@ private void generateSingleShotTime(PrintWriter writer, Mode benchmarkKind, Meth writer.println(ident(3) + "int opsPerInv = control.benchmarkParams.getOpsPerInvocation();"); writer.println(ident(3) + "long totalOps = opsPerInv;"); - writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult((long)totalOps, (long)totalOps);"); + writer.println(ident(3) + "BenchmarkTaskResult results = new BenchmarkTaskResult(totalOps, totalOps);"); if (isSingleMethod) { writer.println(ident(3) + "results.add(new SingleShotResult(ResultRole.PRIMARY, \"" + method.getName() + "\", res.getTime(), benchmarkParams.getTimeUnit()));"); } else { diff --git a/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java b/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java index 15bddd844..b61982212 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.infra.Blackhole; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java b/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java index 6131de813..9644d5040 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/profile/PerfParseTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.profile; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import java.util.ArrayList; @@ -32,6 +32,8 @@ public class PerfParseTest { + private static final double ASSERT_ACCURACY = 0.0000001; + @Test public void parsePerf_4_4() { String[] lines = new String[] { @@ -41,7 +43,7 @@ public void parsePerf_4_4() { for (String line : lines) { LinuxPerfAsmProfiler.PerfLine perfLine = LinuxPerfAsmProfiler.parsePerfLine(line); - Assert.assertEquals(328650.667569D, perfLine.time()); + Assert.assertEquals(328650.667569D, perfLine.time(), ASSERT_ACCURACY); Assert.assertEquals("instructions", perfLine.eventName()); Assert.assertEquals(0x7f82b6a8beb4L, perfLine.addr()); Assert.assertEquals("ConstantPoolCache::allocate", perfLine.symbol()); @@ -57,7 +59,7 @@ public void parseRaggedSymbols() { for (String line : lines) { LinuxPerfAsmProfiler.PerfLine perfLine = LinuxPerfAsmProfiler.parsePerfLine(line); - Assert.assertEquals(328650.667569D, perfLine.time()); + Assert.assertEquals(328650.667569D, perfLine.time(), ASSERT_ACCURACY); Assert.assertEquals("instructions", perfLine.eventName()); Assert.assertEquals(0x7f82b6a8beb4L, perfLine.addr()); Assert.assertEquals("ConstantPoolCache::allocate(Thread* thr)", perfLine.symbol()); @@ -78,7 +80,7 @@ public void parseOptionalTag() { for (String line : lines) { LinuxPerfAsmProfiler.PerfLine perfLine = LinuxPerfAsmProfiler.parsePerfLine(line); - Assert.assertEquals(328650.667569D, perfLine.time()); + Assert.assertEquals(328650.667569D, perfLine.time(), ASSERT_ACCURACY); Assert.assertEquals("instructions", perfLine.eventName()); Assert.assertEquals(0x7f82b6a8beb4L, perfLine.addr()); Assert.assertEquals("ConstantPoolCache::allocate", perfLine.symbol()); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java index 2af31ddff..1d437fe27 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/profile/SafepointsProfilerTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.profile; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; public class SafepointsProfilerTest { diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/ResultAggregationTest.java b/jmh-core/src/test/java/org/openjdk/jmh/results/ResultAggregationTest.java index 555e89d8f..2d669eb65 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/ResultAggregationTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/ResultAggregationTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.results; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.util.SampleBuffer; @@ -33,6 +33,8 @@ public class ResultAggregationTest { + private static final double ASSERT_ACCURACY = 0.0000001; + @Test public void testThroughput() { IterationResult ir = new IterationResult(null, null, null); @@ -40,8 +42,8 @@ public void testThroughput() { ir.addResult(new ThroughputResult(ResultRole.PRIMARY, "", 10_000, 1, TimeUnit.NANOSECONDS)); ir.addResult(new ThroughputResult(ResultRole.SECONDARY, "sec", 5_000, 1, TimeUnit.NANOSECONDS)); ir.addResult(new ThroughputResult(ResultRole.SECONDARY, "sec", 5_000, 1, TimeUnit.NANOSECONDS)); - Assert.assertEquals(20_000.0, ir.getPrimaryResult().getScore()); - Assert.assertEquals(10_000.0, ir.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(20_000.0, ir.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(10_000.0, ir.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); @@ -49,18 +51,18 @@ public void testThroughput() { BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); br.addBenchmarkResult(new ThroughputResult(ResultRole.SECONDARY, "bench", 3_000, 1, TimeUnit.NANOSECONDS)); - Assert.assertEquals(20_000.0, br.getPrimaryResult().getScore()); - Assert.assertEquals(10_000.0, br.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(20_000.0, br.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(10_000.0, br.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); + Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); - Assert.assertEquals(20_000.0, rr.getPrimaryResult().getScore()); - Assert.assertEquals(10_000.0, rr.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(20_000.0, rr.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(10_000.0, rr.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); + Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(4, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); @@ -74,8 +76,8 @@ public void testAverageTime() { ir.addResult(new AverageTimeResult(ResultRole.PRIMARY, "", 1, 10_000, TimeUnit.NANOSECONDS)); ir.addResult(new AverageTimeResult(ResultRole.SECONDARY, "sec", 1, 5_000, TimeUnit.NANOSECONDS)); ir.addResult(new AverageTimeResult(ResultRole.SECONDARY, "sec", 1, 5_000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore()); - Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); @@ -83,18 +85,18 @@ public void testAverageTime() { BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); br.addBenchmarkResult(new AverageTimeResult(ResultRole.SECONDARY, "bench", 1, 3_000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore()); - Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); + Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); - Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore()); - Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); + Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(4, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); @@ -117,8 +119,8 @@ public void testSampleTime() { ir.addResult(new SampleTimeResult(ResultRole.PRIMARY, "", sb10000, TimeUnit.NANOSECONDS)); ir.addResult(new SampleTimeResult(ResultRole.SECONDARY, "sec", sb5000, TimeUnit.NANOSECONDS)); ir.addResult(new SampleTimeResult(ResultRole.SECONDARY, "sec", sb5000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore()); - Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); Assert.assertEquals(2, ir.getRawSecondaryResults().get("sec").size()); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); @@ -126,18 +128,18 @@ public void testSampleTime() { BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); br.addBenchmarkResult(new SampleTimeResult(ResultRole.SECONDARY, "bench", sb3000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore()); - Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); + Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(4, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); - Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore()); - Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); + Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(8, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(8, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); @@ -151,8 +153,8 @@ public void testSingleShot() { ir.addResult(new SingleShotResult(ResultRole.PRIMARY, "", 10_000, TimeUnit.NANOSECONDS)); ir.addResult(new SingleShotResult(ResultRole.SECONDARY, "sec", 5_000, TimeUnit.NANOSECONDS)); ir.addResult(new SingleShotResult(ResultRole.SECONDARY, "sec", 5_000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore()); - Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore()); + Assert.assertEquals(10_000.0, ir.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(5_000.0, ir.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, ir.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, ir.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, ir.getRawPrimaryResults().size()); @@ -160,18 +162,18 @@ public void testSingleShot() { BenchmarkResult br = new BenchmarkResult(null, Arrays.asList(ir, ir)); br.addBenchmarkResult(new SingleShotResult(ResultRole.SECONDARY, "bench", 3_000, TimeUnit.NANOSECONDS)); - Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore()); - Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, br.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(5_000.0, br.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); + Assert.assertEquals(3_000.0, br.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(2, br.getPrimaryResult().getSampleCount()); Assert.assertEquals(2, br.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(1, br.getSecondaryResults().get("bench").getSampleCount()); Assert.assertEquals(2, br.getIterationResults().size()); RunResult rr = new RunResult(null, Arrays.asList(br, br)); - Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore()); - Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore()); - Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore()); + Assert.assertEquals(10_000.0, rr.getPrimaryResult().getScore(), ASSERT_ACCURACY); + Assert.assertEquals(5_000.0, rr.getSecondaryResults().get("sec").getScore(), ASSERT_ACCURACY); + Assert.assertEquals(3_000.0, rr.getSecondaryResults().get("bench").getScore(), ASSERT_ACCURACY); Assert.assertEquals(4, rr.getPrimaryResult().getSampleCount()); Assert.assertEquals(4, rr.getSecondaryResults().get("sec").getSampleCount()); Assert.assertEquals(2, rr.getSecondaryResults().get("bench").getSampleCount()); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAverageTimeResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAverageTimeResult.java index 1fc1f6aa1..44d1ab64a 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestAverageTimeResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestAverageTimeResult.java @@ -29,17 +29,19 @@ import java.util.Arrays; import java.util.concurrent.TimeUnit; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; public class TestAverageTimeResult { + private static final double ASSERT_ACCURACY = 0.0000001; + @Test public void testIterationAggregator1() { AverageTimeResult r1 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 2_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(1.5, result.getScore()); + assertEquals(1.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @@ -49,7 +51,7 @@ public void testIterationAggregator2() { AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(1.0, result.getScore()); + assertEquals(1.0, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @@ -59,7 +61,7 @@ public void testThreadAggregator1() { AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 1_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(1.0, result.getScore()); + assertEquals(1.0, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @@ -69,7 +71,7 @@ public void testThreadAggregator2() { AverageTimeResult r2 = new AverageTimeResult(ResultRole.PRIMARY, "test1", 1_000L, 2_000_000L, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(1.5, result.getScore()); + assertEquals(1.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestSampleTimeResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestSampleTimeResult.java index 40ca22fa6..8048ed98e 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestSampleTimeResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestSampleTimeResult.java @@ -30,10 +30,12 @@ import java.util.Arrays; import java.util.concurrent.TimeUnit; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; public class TestSampleTimeResult { + private static final double ASSERT_ACCURACY = 0.0000001; + @Test public void testIterationAggregator1() { SampleBuffer b1 = new SampleBuffer(); @@ -48,7 +50,7 @@ public void testIterationAggregator1() { SampleTimeResult r2 = new SampleTimeResult(ResultRole.PRIMARY, "Test1", b2, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(2.5, result.getScore()); + assertEquals(2.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @@ -66,7 +68,7 @@ public void testThreadAggregator1() { SampleTimeResult r2 = new SampleTimeResult(ResultRole.PRIMARY, "Test1", b2, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(2.5, result.getScore()); + assertEquals(2.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestSingleShotResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestSingleShotResult.java index 25f9aa305..cac08ad21 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestSingleShotResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestSingleShotResult.java @@ -29,17 +29,19 @@ import java.util.Arrays; import java.util.concurrent.TimeUnit; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; public class TestSingleShotResult { + private static final double ASSERT_ACCURACY = 0.0000001; + @Test public void testIterationAggregator1() { SingleShotResult r1 = new SingleShotResult(ResultRole.PRIMARY, "Test1", 1000L, TimeUnit.MICROSECONDS); SingleShotResult r2 = new SingleShotResult(ResultRole.PRIMARY, "Test1", 2000L, TimeUnit.MICROSECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(1.5, result.getScore()); + assertEquals(1.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } @@ -49,7 +51,7 @@ public void testThreadAggregator1() { SingleShotResult r2 = new SingleShotResult(ResultRole.PRIMARY, "Test1", 2000L, TimeUnit.MICROSECONDS); Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(1.5, result.getScore()); + assertEquals(1.5, result.getScore(), ASSERT_ACCURACY); assertEquals("us/op", result.getScoreUnit()); } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/TestThroughputResult.java b/jmh-core/src/test/java/org/openjdk/jmh/results/TestThroughputResult.java index d7647916e..dac9c5080 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/TestThroughputResult.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/TestThroughputResult.java @@ -29,10 +29,12 @@ import java.util.Arrays; import java.util.concurrent.TimeUnit; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; public class TestThroughputResult { + private static final double ASSERT_ACCURACY = 0.0000001; + /** * Test of getScore method, of class ThroughputResult. */ @@ -83,7 +85,7 @@ public void testRunAggregator1() { ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 10_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(150.0, result.getScore()); + assertEquals(150.0, result.getScore(), ASSERT_ACCURACY); assertEquals("ops/ms", result.getScoreUnit()); } @@ -93,7 +95,7 @@ public void testRunAggregator2() { ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(100.0, result.getScore()); + assertEquals(100.0, result.getScore(), ASSERT_ACCURACY); assertEquals("ops/ms", result.getScoreUnit()); } @@ -103,7 +105,7 @@ public void testIterationAggregator3() { ThroughputResult r2 = new ThroughputResult(ResultRole.PRIMARY, "test1", 2_000_000_000L, 20_000_000L, TimeUnit.MILLISECONDS); Result result = r1.getIterationAggregator().aggregate(Arrays.asList(r1, r2)); - assertEquals(100_000_000.0, result.getScore()); + assertEquals(100_000_000.0, result.getScore(), ASSERT_ACCURACY); assertEquals("ops/ms", result.getScoreUnit()); } @@ -114,7 +116,7 @@ public void testThreadAggregator1() { Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals("ops/ms", result.getScoreUnit()); - assertEquals(300.0, result.getScore()); + assertEquals(300.0, result.getScore(), ASSERT_ACCURACY); } @Test @@ -124,7 +126,7 @@ public void testThreadAggregator2() { Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals("ops/ms", result.getScoreUnit()); - assertEquals(200.0, result.getScore()); + assertEquals(200.0, result.getScore(), ASSERT_ACCURACY); } @Test // regression test, check for overflow @@ -134,6 +136,6 @@ public void testThreadAggregator3() { Result result = r1.getThreadAggregator().aggregate(Arrays.asList(r1, r2)); assertEquals("ops/ms", result.getScoreUnit()); - assertEquals(200_000_000.0, result.getScore()); + assertEquals(200_000_000.0, result.getScore(), ASSERT_ACCURACY); } } diff --git a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java index 306ce2be3..350f08907 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/results/format/ResultFormatTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.results.format; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.infra.BenchmarkParams; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/DistributeGroupsTest.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/DistributeGroupsTest.java index 3cdbf7506..8d3c9fef8 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/DistributeGroupsTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/DistributeGroupsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.runner; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.infra.ThreadParams; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/parameters/TimeValueTest.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/parameters/TimeValueTest.java index 722e4cad1..77b55aca8 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/parameters/TimeValueTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/parameters/TimeValueTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.runner.parameters; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.runner.options.TimeValue; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/BoundedPriorityQueueTest.java b/jmh-core/src/test/java/org/openjdk/jmh/util/BoundedPriorityQueueTest.java index 6d72545e8..f9c0ab498 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/BoundedPriorityQueueTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/BoundedPriorityQueueTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.util; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import java.util.Collections; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetsTest.java b/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetsTest.java index 8b6cd613a..31b6184d1 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetsTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/MultisetsTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.util; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import java.util.List; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java index d3495263a..8894f05ed 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestClassUtils.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.util; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import java.util.Arrays; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java index 40959151e..6348d8e1c 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestListStatistics.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.util; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -47,6 +47,8 @@ public class TestListStatistics { 36.99130073, 60.17648239, 33.1484382, 56.4605944, 93.67454206 }; + private static final double ASSERT_ACCURACY = 0.0000000001; + private static final ListStatistics instance = new ListStatistics(); @BeforeClass @@ -240,17 +242,17 @@ public strictfp void testEmpty() { Statistics s = new ListStatistics(); Assert.assertEquals(0, s.getN()); - Assert.assertEquals(Double.NaN, s.getSum()); - Assert.assertEquals(Double.NaN, s.getMin()); - Assert.assertEquals(Double.NaN, s.getMax()); - Assert.assertEquals(Double.NaN, s.getMean()); - Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5)); - Assert.assertEquals(Double.NaN, s.getVariance()); - Assert.assertEquals(Double.NaN, s.getStandardDeviation()); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0]); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1]); - Assert.assertEquals(Double.NaN, s.getPercentile(0)); - Assert.assertEquals(Double.NaN, s.getPercentile(100)); + Assert.assertEquals(Double.NaN, s.getSum(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMin(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMax(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMean(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getPercentile(0), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getPercentile(100), ASSERT_ACCURACY); } @Test @@ -259,17 +261,17 @@ public strictfp void testSingle() { s.addValue(42.0D); Assert.assertEquals(1, s.getN()); - Assert.assertEquals(42.0D, s.getSum()); - Assert.assertEquals(42.0D, s.getMin()); - Assert.assertEquals(42.0D, s.getMax()); - Assert.assertEquals(42.0D, s.getMean()); - Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5)); - Assert.assertEquals(Double.NaN, s.getVariance()); - Assert.assertEquals(Double.NaN, s.getStandardDeviation()); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0]); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1]); - Assert.assertEquals(42.0D, s.getPercentile(0)); - Assert.assertEquals(42.0D, s.getPercentile(100)); + Assert.assertEquals(42.0D, s.getSum(), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getMin(), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getMax(), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getMean(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getPercentile(0), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getPercentile(100), ASSERT_ACCURACY); } @Test @@ -405,8 +407,8 @@ public strictfp void testRawDataIterator() { for (double item : VALUES) { Assert.assertTrue(listIter.hasNext()); Map.Entry entry = listIter.next(); - Assert.assertEquals(entry.getKey(), item); - Assert.assertEquals(entry.getValue().longValue(), 1L); + Assert.assertEquals(entry.getKey(), item, ASSERT_ACCURACY); + Assert.assertEquals(1L, entry.getValue().longValue()); } Assert.assertFalse(listIter.hasNext()); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java index e77f34c78..893584724 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestMultisetStatistics.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.util; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -47,6 +47,8 @@ public class TestMultisetStatistics { 36.99130073, 60.17648239, 33.1484382, 56.4605944, 93.67454206 }; + private static final double ASSERT_ACCURACY = 0.000000001; + private static final MultisetStatistics instance = new MultisetStatistics(); @BeforeClass @@ -234,17 +236,17 @@ public strictfp void testEmpty() { Statistics s = new MultisetStatistics(); Assert.assertEquals(0, s.getN()); - Assert.assertEquals(Double.NaN, s.getSum()); - Assert.assertEquals(Double.NaN, s.getMin()); - Assert.assertEquals(Double.NaN, s.getMax()); - Assert.assertEquals(Double.NaN, s.getMean()); - Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5)); - Assert.assertEquals(Double.NaN, s.getVariance()); - Assert.assertEquals(Double.NaN, s.getStandardDeviation()); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0]); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1]); - Assert.assertEquals(Double.NaN, s.getPercentile(0)); - Assert.assertEquals(Double.NaN, s.getPercentile(100)); + Assert.assertEquals(Double.NaN, s.getSum(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMin(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMax(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMean(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getPercentile(0), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getPercentile(100), ASSERT_ACCURACY); } @Test @@ -253,17 +255,17 @@ public strictfp void testSingle() { s.addValue(42.0D, 1); Assert.assertEquals(1, s.getN()); - Assert.assertEquals(42.0D, s.getSum()); - Assert.assertEquals(42.0D, s.getMin()); - Assert.assertEquals(42.0D, s.getMax()); - Assert.assertEquals(42.0D, s.getMean()); - Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5)); - Assert.assertEquals(Double.NaN, s.getVariance()); - Assert.assertEquals(Double.NaN, s.getStandardDeviation()); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0]); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1]); - Assert.assertEquals(42.0D, s.getPercentile(0)); - Assert.assertEquals(42.0D, s.getPercentile(100)); + Assert.assertEquals(42.0D, s.getSum(), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getMin(), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getMax(), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getMean(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getPercentile(0), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getPercentile(100), ASSERT_ACCURACY); } @@ -440,7 +442,7 @@ public strictfp void testRawDataIterator_duplicates() { Iterator> it = s.getRawData(); int itemCount = 0; for (Map.Entry entry : Utils.adaptForLoop(it)) { - Assert.assertEquals(entry.getKey(), (double)(entry.getValue() * 10)); + Assert.assertEquals(entry.getKey(), (double)(entry.getValue() * 10), ASSERT_ACCURACY); itemCount++; } Assert.assertEquals(itemCount, 10); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java index 3e363608a..7ff236510 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestSingletonStatistics.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.util; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -40,6 +40,7 @@ public class TestSingletonStatistics { private static final double VALUE = 42.73638635; + private static final double ASSERT_ACCURACY = 0.000000001; private static final ListStatistics listStats = new ListStatistics(); private static final SingletonStatistics singStats = new SingletonStatistics(VALUE); @@ -146,17 +147,17 @@ public strictfp void testSingle() { SingletonStatistics s = new SingletonStatistics(42.0D); Assert.assertEquals(1, s.getN()); - Assert.assertEquals(42.0D, s.getSum()); - Assert.assertEquals(42.0D, s.getMin()); - Assert.assertEquals(42.0D, s.getMax()); - Assert.assertEquals(42.0D, s.getMean()); - Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5)); - Assert.assertEquals(Double.NaN, s.getVariance()); - Assert.assertEquals(Double.NaN, s.getStandardDeviation()); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0]); - Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1]); - Assert.assertEquals(42.0D, s.getPercentile(0)); - Assert.assertEquals(42.0D, s.getPercentile(100)); + Assert.assertEquals(42.0D, s.getSum(), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getMin(), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getMax(), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getMean(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getMeanErrorAt(0.5), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getVariance(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getStandardDeviation(), ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[0], ASSERT_ACCURACY); + Assert.assertEquals(Double.NaN, s.getConfidenceIntervalAt(0.50)[1], ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getPercentile(0), ASSERT_ACCURACY); + Assert.assertEquals(42.0D, s.getPercentile(100), ASSERT_ACCURACY); } @Test @@ -257,7 +258,7 @@ public strictfp void testRawDataIterator() { Iterator> singIter = singStats.getRawData(); Assert.assertTrue(singIter.hasNext()); Map.Entry entry = singIter.next(); - Assert.assertEquals(entry.getKey(), VALUE); + Assert.assertEquals(entry.getKey(), VALUE, ASSERT_ACCURACY); Assert.assertEquals(entry.getValue().longValue(), 1L); Assert.assertFalse(singIter.hasNext()); diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/TestUtil.java b/jmh-core/src/test/java/org/openjdk/jmh/util/TestUtil.java index 3028506de..f1d038d6d 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/TestUtil.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/TestUtil.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.util; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import java.io.IOException; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/Util.java b/jmh-core/src/test/java/org/openjdk/jmh/util/Util.java index c35aacd92..673387bc7 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/Util.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/Util.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.util; -import junit.framework.Assert; +import org.junit.Assert; import java.util.Arrays; diff --git a/jmh-core/src/test/java/org/openjdk/jmh/util/lines/TestLineTest.java b/jmh-core/src/test/java/org/openjdk/jmh/util/lines/TestLineTest.java index 8b55fdcec..edca88b95 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/util/lines/TestLineTest.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/util/lines/TestLineTest.java @@ -24,7 +24,7 @@ */ package org.openjdk.jmh.util.lines; -import junit.framework.Assert; +import org.junit.Assert; import org.junit.Test; import org.openjdk.jmh.runner.options.TimeValue; import org.openjdk.jmh.util.Optional; From 85bb312d5f6952dda74ea4576ab64d0f558a44af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Wed, 24 Mar 2021 10:23:17 +0100 Subject: [PATCH 255/342] CODETOOLS-7902863: JMH: Cache parsing patterns in profilers --- .../jmh/profile/AbstractPerfAsmProfiler.java | 55 ++++++++++--------- .../jmh/profile/LinuxPerfProfiler.java | 4 +- .../main/java/org/openjdk/jmh/util/Utils.java | 12 ---- 3 files changed, 31 insertions(+), 40 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java index bb41e3fa2..e5e24b29c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractPerfAsmProfiler.java @@ -777,14 +777,14 @@ private Collection> splitAssembly(File stdOut) { Multimap writerToLines = new HashMultimap<>(); long writerId = -1L; - Pattern pWriterThread = Pattern.compile("(.*)(.*)"); - String line; + final Pattern writerThreadPattern = Pattern.compile("(.*)(.*)"); + String line; while ((line = br.readLine()) != null) { // Parse the writer threads IDs: // if (line.contains(" + final Pattern nmethodPattern = Pattern.compile("(.*?)(.*?)"); + for (Collection cs : splitAssembly(stdOut)) { String prevLine = ""; for (String line : cs) { @@ -854,23 +877,7 @@ private Assembly readAssembly(File stdOut) { } if (prevLine.contains("--------") || line.contains("StubRoutines::")) { - // Try parsing the interpreter/runtime stub: - // ---------------------------------------------------------------------- - // invokehandle 233 invokehandle [0x00007f631d023100, 0x00007f631d0233c0] 704 bytes - // StubRoutines::catch_exception [0x00007feb43fa7b27, 0x00007feb43fa7b46[ (31 bytes) - - // JDK 13 adds another "-------" line after StubRoutines line, so we need to filter out - // mismatched lines that follow it. This is why regexp is anchored at the start of the line. - // Example: - // - // StubRoutines::updateBytesCRC32 [0x0000ffff6c819700, 0x0000ffff6c819870] (368 bytes) - // -------------------------------------------------------------------------------- - // 0x0000ffff6c819700: stp x29, x30, [sp, #-16]! <--- do not match this - // 0x0000ffff6c819704: mov x29, sp - // 0x0000ffff6c819708: mvn w0, w0 - - Pattern pattern = Pattern.compile("^(\\S.*)( +)\\[(.+), (.+)[\\]\\[](.*)"); - Matcher matcher = pattern.matcher(line); + Matcher matcher = interpreterStubPattern.matcher(line); if (matcher.matches()) { String name = matcher.group(1); @@ -891,13 +898,7 @@ private Assembly readAssembly(File stdOut) { } if (line.contains(" - - Matcher matcher = Pattern.compile("(.*?)(.*?)").matcher(line); + Matcher matcher = nmethodPattern.matcher(line); if (matcher.matches()) { String body = matcher.group(2); body = body.replaceAll("='", "="); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java index d284464de..d957ed1a7 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java @@ -141,6 +141,8 @@ private PerfResult process(File stdOut, File stdErr) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); + final Pattern hashLinePattern = Pattern.compile("(.*)#(.*)"); + try (FileReader fr = new FileReader(stdErr); BufferedReader reader = new BufferedReader(fr)) { @@ -157,7 +159,7 @@ private PerfResult process(File stdOut, File stdErr) { printing = true; } - Matcher m = Pattern.compile("(.*)#(.*)").matcher(line); + Matcher m = hashLinePattern.matcher(line); if (m.matches()) { String pair = m.group(1).trim(); if (pair.contains(" cycles")) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 69e5b9c1b..5cbeb3487 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -35,7 +35,6 @@ import java.nio.charset.Charset; import java.util.*; import java.util.concurrent.*; -import java.util.regex.Pattern; public class Utils { @@ -55,17 +54,6 @@ private Utils() { } - private static final ConcurrentMap PATTERNS = new ConcurrentHashMap<>(); - - public static Pattern lazyCompile(String pattern) { - Pattern patt = PATTERNS.get(pattern); - if (patt == null) { - patt = Pattern.compile(pattern); - PATTERNS.put(pattern, patt); - } - return patt; - } - public static > T min(Collection ts) { T min = null; for (T t : ts) { From 42209ac5a6cf3140bcb31d6d371145f5e4da6cde Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 24 Mar 2021 10:28:10 +0100 Subject: [PATCH 256/342] JMH v1.29. --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index a29ffb35a..8792f6814 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.29-SNAPSHOT + 1.29 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 2ae61c4d2..b27342fa3 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.29-SNAPSHOT + 1.29 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 75d644df8..0736210cd 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.29-SNAPSHOT + 1.29 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index e52774433..e33066450 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.29-SNAPSHOT + 1.29 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index e5f70f112..387a6d286 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 1de891e2b..e751f1f62 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 50bb90c7d..2cac66096 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 444f9336c..4acb926d2 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 4692c8531..b831e0ae6 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index e944a6c7f..df66e42f9 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 251c2fcc0..5b0338649 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 52fa51755..9e24e93b8 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 0c7cb8205..8fcb5b063 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index b0d2476b3..2005918b2 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.29-SNAPSHOT + 1.29 JMH Samples diff --git a/pom.xml b/pom.xml index 733378530..33bf4d8f6 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.29-SNAPSHOT + 1.29 Java Microbenchmark Harness Parent From 99e9c19c80a0133c28f6532ef2b5776d5b8bd023 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 24 Mar 2021 10:28:49 +0100 Subject: [PATCH 257/342] Continue in 1.30-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 8792f6814..371cca302 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.29 + 1.30-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index b27342fa3..cb4c18580 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.29 + 1.30-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 0736210cd..48dd07158 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.29 + 1.30-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index e33066450..36bdd0bc0 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.29 + 1.30-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 387a6d286..9ff951c87 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index e751f1f62..4c7ec4af0 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 2cac66096..b332b4837 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 4acb926d2..effcba7d7 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index b831e0ae6..9006c004e 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index df66e42f9..5a49ca0e3 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 5b0338649..538f44802 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 9e24e93b8..c9f025403 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 8fcb5b063..8ed43c51b 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 2005918b2..2ea165201 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.29 + 1.30-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 33bf4d8f6..d368d1917 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.29 + 1.30-SNAPSHOT Java Microbenchmark Harness Parent From 5e497a984b5b18e0e5de4ebb08a07fdbadf360c2 Mon Sep 17 00:00:00 2001 From: Patrick Reinhart Date: Wed, 28 Apr 2021 12:56:02 +0000 Subject: [PATCH 258/342] 7902902: JMH: non .jar class path file entries treated as directories Reviewed-by: shade --- jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java index d9aadda59..94c0be85a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java @@ -885,7 +885,7 @@ private void addClasspath(List command) { String rel = relPath.toString(); sb.append(rel.replace('\\', '/').replace(" ", "%20")); - if (!cp.endsWith(".jar")) { + if (Files.isDirectory(cpPath)) { sb.append('/'); } sb.append(" "); From 03fa35a8283be10c5db52a4f25eeaef8286a0176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 4 May 2021 11:10:21 +0200 Subject: [PATCH 259/342] CODETOOLS-7902915: JMH: Use Console.charset() if available --- .../main/java/org/openjdk/jmh/util/Utils.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 5cbeb3487..6140a64e9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -238,22 +238,34 @@ public static Charset guessConsoleEncoding() { // We cannot use Console class directly, because we also need the access to the raw byte stream, // e.g. for pushing in a raw output from a forked VM invocation. Therefore, we are left with // reflectively poking out the Charset from Console, and use it for our own private output streams. + // Since JDK 17, there is Console.charset(), which we can use reflectively. // Try 1. Try to poke the System.console(). try { Console console = System.console(); if (console != null) { - Field f = Console.class.getDeclaredField("cs"); - setAccessible(console, f); - Object res = f.get(console); - if (res instanceof Charset) { - return (Charset) res; + { + Method m = Console.class.getDeclaredMethod("charset"); + Object res = m.invoke(console); + if (res instanceof Charset) { + return (Charset) res; + } + } + { + Field f = Console.class.getDeclaredField("cs"); + setAccessible(console, f); + Object res = f.get(console); + if (res instanceof Charset) { + return (Charset) res; + } } - Method m = Console.class.getDeclaredMethod("encoding"); - setAccessible(console, m); - res = m.invoke(null); - if (res instanceof String) { - return Charset.forName((String) res); + { + Method m = Console.class.getDeclaredMethod("encoding"); + setAccessible(console, m); + Object res = m.invoke(null); + if (res instanceof String) { + return Charset.forName((String) res); + } } } } catch (Exception e) { From fbf0db1fdebac25950b377b64ee7b660f2636ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Wed, 5 May 2021 16:06:52 +0200 Subject: [PATCH 260/342] CODETOOLS-7902926: JMH: More reliable Console charset probing --- .../main/java/org/openjdk/jmh/util/Utils.java | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 6140a64e9..e91aa4a07 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -241,35 +241,37 @@ public static Charset guessConsoleEncoding() { // Since JDK 17, there is Console.charset(), which we can use reflectively. // Try 1. Try to poke the System.console(). - try { - Console console = System.console(); - if (console != null) { - { - Method m = Console.class.getDeclaredMethod("charset"); - Object res = m.invoke(console); - if (res instanceof Charset) { - return (Charset) res; - } + Console console = System.console(); + if (console != null) { + try { + Method m = Console.class.getDeclaredMethod("charset"); + Object res = m.invoke(console); + if (res instanceof Charset) { + return (Charset) res; } - { - Field f = Console.class.getDeclaredField("cs"); - setAccessible(console, f); - Object res = f.get(console); - if (res instanceof Charset) { - return (Charset) res; - } + } catch (Exception e) { + // fall-through + } + try { + Field f = Console.class.getDeclaredField("cs"); + setAccessible(console, f); + Object res = f.get(console); + if (res instanceof Charset) { + return (Charset) res; } - { - Method m = Console.class.getDeclaredMethod("encoding"); - setAccessible(console, m); - Object res = m.invoke(null); - if (res instanceof String) { - return Charset.forName((String) res); - } + } catch (Exception e) { + // fall-through + } + try { + Method m = Console.class.getDeclaredMethod("encoding"); + setAccessible(console, m); + Object res = m.invoke(null); + if (res instanceof String) { + return Charset.forName((String) res); } + } catch (Exception e) { + // fall-through } - } catch (Exception e) { - // fall-through } // Try 2. Try to poke stdout. From 66f929f688fcc401f590f583261c9fbf6a226048 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 5 May 2021 16:32:23 +0200 Subject: [PATCH 261/342] JMH v1.30. --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 371cca302..e68515f94 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.30-SNAPSHOT + 1.30 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index cb4c18580..d63b23ae5 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.30-SNAPSHOT + 1.30 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 48dd07158..ae2d0204d 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.30-SNAPSHOT + 1.30 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 36bdd0bc0..29cca8615 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.30-SNAPSHOT + 1.30 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 9ff951c87..18df5176c 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 4c7ec4af0..9e5fbed4d 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index b332b4837..42d032d5a 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index effcba7d7..477211e8f 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 9006c004e..e17a87017 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 5a49ca0e3..f8fe00aa5 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 538f44802..30ee10e2d 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index c9f025403..18208b990 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 8ed43c51b..d31921869 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 2ea165201..e8166f7be 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.30-SNAPSHOT + 1.30 JMH Samples diff --git a/pom.xml b/pom.xml index d368d1917..3a8027986 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.30-SNAPSHOT + 1.30 Java Microbenchmark Harness Parent From 8f4faf636fcb9b842f7f1be127ca4083218ef518 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 5 May 2021 16:34:52 +0200 Subject: [PATCH 262/342] Continue in 1.31-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index e68515f94..370e438e2 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.30 + 1.31-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index d63b23ae5..39227af81 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.30 + 1.31-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index ae2d0204d..b154b3a10 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.30 + 1.31-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 29cca8615..be5dbf014 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.30 + 1.31-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 18df5176c..4946029bd 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 9e5fbed4d..bca722c71 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 42d032d5a..a8afe4b46 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 477211e8f..f9826ce70 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index e17a87017..de3048286 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index f8fe00aa5..f3d4523c4 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 30ee10e2d..d97fb9b9d 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 18208b990..d8e6aa0a1 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index d31921869..02accd4e2 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index e8166f7be..80920aaca 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.30 + 1.31-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 3a8027986..a797eac96 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.30 + 1.31-SNAPSHOT Java Microbenchmark Harness Parent From 2415f72d50335a927749c36d730c4e05ad1626e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 6 May 2021 07:33:20 +0200 Subject: [PATCH 263/342] CODETOOLS-7902927: JMH: Support HTML flamegraphs for async-profiler --- .../main/java/org/openjdk/jmh/profile/AsyncProfiler.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java index 4c294201c..f19a23ad4 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java @@ -302,11 +302,14 @@ private TextResult stopAndDump(File trialOutDir) { dump(trialOutDir, "collapsed-%s.csv", "collapsed"); break; case flamegraph: + // The last SVG-enabled version is 1.x + String ver = execute("version"); + String ext = ver.startsWith("1.") ? "svg" : "html"; if (direction == Direction.both || direction == Direction.forward) { - dump(trialOutDir, "flame-%s-forward.svg", "svg"); + dump(trialOutDir, "flame-%s-forward." + ext, "flamegraph"); } if (direction == Direction.both || direction == Direction.reverse) { - dump(trialOutDir, "flame-%s-reverse.svg", "svg,reverse"); + dump(trialOutDir, "flame-%s-reverse." + ext, "flamegraph,reverse"); } break; case tree: From 0aeda8de3a40e6d23657bf651492cfc7cf8c6a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 11 May 2021 10:38:33 +0200 Subject: [PATCH 264/342] CODETOOLS-7902933: JMH: Update test JDK lists for GHA --- .github/workflows/pre-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-integration.yml b/.github/workflows/pre-integration.yml index 99b66b347..928ff4ffd 100644 --- a/.github/workflows/pre-integration.yml +++ b/.github/workflows/pre-integration.yml @@ -10,7 +10,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - java: [7, 8, 11, 15, 16-ea, 17-ea] + java: [7, 8, 11, 16, 17-ea] os: [ubuntu-18.04, windows-2019, macos-10.15] profile: [default, reflection, asm] fail-fast: false From 768f38ef4dab5917b53cd018ff43cfcafe2b1e79 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 12 May 2021 05:29:51 +0000 Subject: [PATCH 265/342] 7902929: JMH generators fail for benchmark in unnamed package Reviewed-by: shade --- .../src/test/java/UnnamedPackageTest.java | 39 +++++++++++++++++++ .../jmh/generators/asm/ASMClassInfo.java | 23 ++++++++--- .../generators/reflection/RFClassInfo.java | 8 +++- 3 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 jmh-core-ct/src/test/java/UnnamedPackageTest.java diff --git a/jmh-core-ct/src/test/java/UnnamedPackageTest.java b/jmh-core-ct/src/test/java/UnnamedPackageTest.java new file mode 100644 index 000000000..5822386b2 --- /dev/null +++ b/jmh-core-ct/src/test/java/UnnamedPackageTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import org.junit.Test; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.ct.CompileTest; + +public class UnnamedPackageTest { + @Benchmark + public void test() { + } + + @Test + public void compileTest() { + CompileTest.assertFail(getClass(), "Benchmark class should have package other than default."); + } +} diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java index f435d353c..0fed62b13 100644 --- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java +++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java @@ -79,11 +79,24 @@ public void visit(int version, int access, String name, String signature, String this.superName = superName; this.idName = name; this.access = access; - qualifiedName = name.replace("/", "."); - packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf(".")); - origQualifiedName = qualifiedName; - qualifiedName = qualifiedName.replace('$', '.'); - this.name = qualifiedName.substring(qualifiedName.lastIndexOf(".") + 1); + this.qualifiedName = name.replace("/", "."); + + int dotIndex = qualifiedName.lastIndexOf("."); + if (dotIndex != -1) { + packageName = qualifiedName.substring(0, dotIndex); + } else { + packageName = ""; + } + + this.origQualifiedName = qualifiedName; + this.qualifiedName = qualifiedName.replace('$', '.'); + + dotIndex = qualifiedName.lastIndexOf("."); + if (dotIndex != -1) { + this.name = qualifiedName.substring(dotIndex + 1); + } else { + this.name = qualifiedName; + } } @Override diff --git a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java index 6d8b7da96..09764fe20 100644 --- a/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java +++ b/jmh-generator-reflection/src/main/java/org/openjdk/jmh/generators/reflection/RFClassInfo.java @@ -46,9 +46,9 @@ public RFClassInfo(Class klass) { @Override public String getPackageName() { if (klass.getDeclaringClass() != null) { - return klass.getDeclaringClass().getPackage().getName(); + return nameOf(klass.getDeclaringClass().getPackage()); } else { - return klass.getPackage().getName(); + return nameOf(klass.getPackage()); } } @@ -171,4 +171,8 @@ public Collection getEnumConstants() { public String toString() { return getQualifiedName(); } + + private String nameOf(Package pack) { + return pack == null ? "" : pack.getName(); + } } From a394dad4bc32ba2ff6fa21cedbe3ef8dfde7f2cd Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 12 May 2021 06:23:46 +0000 Subject: [PATCH 266/342] 7902928: Improve support for async-profiler 2.x Reviewed-by: shade --- .../openjdk/jmh/profile/AsyncProfiler.java | 211 +++++++++++++----- 1 file changed, 149 insertions(+), 62 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java index f19a23ad4..e04922bab 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java @@ -41,11 +41,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.List; +import java.util.*; /** @@ -54,7 +50,6 @@ * @author Jason Zaugg */ public final class AsyncProfiler implements ExternalProfiler, InternalProfiler { - private static final String DEFAULT_EVENT = "cpu"; private final JavaApi instance; @@ -62,15 +57,18 @@ public final class AsyncProfiler implements ExternalProfiler, InternalProfiler { private final Direction direction; private final String profilerConfig; private final List output; - private final String event; + private final String outputFilePrefix; private final File outDir; + private File trialOutDir; private final int traces; private final int flat; - private boolean warmupStarted = false; - private boolean measurementStarted = false; + private boolean isVersion1x; + + private boolean warmupStarted; + private boolean measurementStarted; private int measurementIterationCount; - private final List generated = new ArrayList<>(); + private final LinkedHashSet generated = new LinkedHashSet<>(); public AsyncProfiler(String initLine) throws ProfilerException { OptionParser parser = new OptionParser(); @@ -78,7 +76,7 @@ public AsyncProfiler(String initLine) throws ProfilerException { parser.formatHelpWith(new ProfilerOptionFormatter("async")); OptionSpec optOutput = parser.accepts("output", - "Output format(s). Supported: " + EnumSet.allOf(OutputType.class).toString() + ".") + "Output format(s). Supported: " + EnumSet.allOf(OutputType.class) + ".") .withRequiredArg().ofType(OutputType.class).withValuesSeparatedBy(",").describedAs("format+").defaultsTo(OutputType.text); OptionSpec optDirection = parser.accepts("direction", @@ -92,8 +90,17 @@ public AsyncProfiler(String initLine) throws ProfilerException { .withRequiredArg().ofType(String.class).describedAs("path"); OptionSpec optEvent = parser.accepts("event", - "Event to sample: cpu, alloc, wall, lock, cache-misses, etc.") - .withRequiredArg().ofType(String.class).describedAs("event").defaultsTo(DEFAULT_EVENT); + "Event to sample: cpu, alloc, lock, wall, itimer; com.foo.Bar.methodName; any event from `perf list` e.g. cache-misses") + .withRequiredArg().ofType(String.class).describedAs("event").defaultsTo("cpu"); + + String secondaryEventOk = "May be captured as a secondary event under output=jfr."; + OptionSpec optAlloc = parser.accepts("alloc", + "Enable allocation profiling. Optional argument (e.g. =512k) reduces sampling from the default of one-sample-per-TLAB. " + secondaryEventOk) + .withOptionalArg().ofType(String.class).describedAs("sample bytes"); + + OptionSpec optLock = parser.accepts("lock", + "Enable lock profiling. Optional argument (e.g. =1ms) limits capture based on lock duration. " + secondaryEventOk) + .withOptionalArg().ofType(String.class).describedAs("duration"); OptionSpec optDir = parser.accepts("dir", "Output directory.") @@ -183,12 +190,9 @@ public AsyncProfiler(String initLine) throws ProfilerException { OptionSet set = ProfilerUtils.parseInitLine(initLine, parser); - StringBuilder profilerOptions = new StringBuilder(); - try { - ProfilerOptionsBuilder builder = new ProfilerOptionsBuilder(set, profilerOptions); - this.event = optEvent.value(set); - builder.append(optEvent); + ProfilerOptionsBuilder builder = new ProfilerOptionsBuilder(set); + if (!set.has(optDir)) { outDir = new File(System.getProperty("user.dir")); } else { @@ -220,10 +224,8 @@ public AsyncProfiler(String initLine) throws ProfilerException { builder.appendRaw(optRawCommand.value(set)); } - this.traces = optTraces.value(set); - this.flat = optFlat.value(set); - - this.profilerConfig = profilerOptions.toString(); + traces = optTraces.value(set); + flat = optFlat.value(set); try { if (set.has(optLibPath)) { @@ -236,9 +238,68 @@ public AsyncProfiler(String initLine) throws ProfilerException { "is on LD_LIBRARY_PATH (Linux), DYLD_LIBRARY_PATH (Mac OS), or -Djava.library.path. " + "Alternatively, point to explicit library location with -prof async:libPath=.", e); } - this.direction = optDirection.value(set); - this.output = optOutput.values(set); - this.verbose = optVerbose.value(set); + verbose = optVerbose.value(set); + try { + String version = instance.execute("version"); + if (verbose) { + System.out.println("[async-profiler] version=" + version); + } + isVersion1x = version.startsWith("1."); + } catch (IOException e) { + throw new ProfilerException(e); + } + direction = optDirection.value(set); + + output = optOutput.values(set); + builder.appendMulti(optOutput); + + // Secondary events are those that may be collected simultaneously with a primary event in a JFR profile. + // To be used as such, we require they are specifed with the lock and alloc option, rather than event=lock, + // event=alloc. + Set secondaryEvents = new HashSet<>(); + + if (set.has(optAlloc)) { + secondaryEvents.add("alloc"); + builder.append(optAlloc); + } + + if (set.has(optLock)) { + secondaryEvents.add("lock"); + builder.append(optLock); + } + + if (set.has(optEvent)) { + String evName = set.valueOf(optEvent); + if (evName.contains(",")) { + throw new ProfilerException("Event name should not contain commas: " + evName); + } + outputFilePrefix = evName; + builder.append(optEvent); + } else { + if (secondaryEvents.isEmpty()) { + // Default to the cpu event if no events at all are selected. + builder.appendRaw("event=cpu"); + outputFilePrefix = "cpu"; + } else if (secondaryEvents.size() == 1) { + // No primary event, one secondary -- promote it to the primary event. This means any output + // format is allowed and the event name will be included in the output file name. + outputFilePrefix = secondaryEvents.iterator().next(); + secondaryEvents.clear(); + } else { + outputFilePrefix = "profile"; + } + } + + if (!secondaryEvents.isEmpty()) { + if (isVersion1x) { + throw new ProfilerException("Secondary event capture not supported on async-profiler 1.x"); + } + if (output.size() > 1 || output.get(0) != OutputType.jfr) { + throw new ProfilerException("Secondary event capture is only supported with output=" + OutputType.jfr.name()); + } + } + + profilerConfig = builder.profilerOptions(); } catch (OptionException e) { throw new ProfilerException(e.getMessage()); } @@ -246,10 +307,13 @@ public AsyncProfiler(String initLine) throws ProfilerException { @Override public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { + if (trialOutDir == null) { + createTrialOutDir(benchmarkParams); + } if (iterationParams.getType() == IterationType.WARMUP) { if (!warmupStarted) { // Collect profiles during warmup to warmup the profiler itself. - execute("start," + profilerConfig); + start(); warmupStarted = true; } } @@ -260,63 +324,79 @@ public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams ite execute("stop"); } // ...and start collecting again. - execute("start," + profilerConfig); + start(); measurementStarted = true; } } } + private void start() { + if (output.contains(OutputType.jfr)) { + execute("start," + profilerConfig + ",file=" + outputFile("jfr-%s.jfr").getAbsolutePath()); + } else { + execute("start," + profilerConfig); + } + } + @Override public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult iterationResult) { if (iterationParams.getType() == IterationType.MEASUREMENT) { measurementIterationCount += 1; if (measurementIterationCount == iterationParams.getCount()) { - File trialOutDir = createTrialOutDir(benchmarkParams); - return Collections.singletonList(stopAndDump(trialOutDir)); + return Collections.singletonList(stopAndDump()); } } return Collections.emptyList(); } - private File createTrialOutDir(BenchmarkParams benchmarkParams) { - String fileName = benchmarkParams.id(); - File trialOutDir = new File(this.outDir, fileName); - trialOutDir.mkdirs(); - return trialOutDir; + private void createTrialOutDir(BenchmarkParams benchmarkParams) { + if (trialOutDir == null) { + // async-profiler expands %p to PID and %t to timestamp, make sure we don't + // include % in the file name. + String fileName = benchmarkParams.id().replace("%", "_"); + trialOutDir = new File(outDir, fileName); + trialOutDir.mkdirs(); + } } - private TextResult stopAndDump(File trialOutDir) { + private TextResult stopAndDump() { execute("stop"); - StringWriter output = new StringWriter(); - PrintWriter pw = new PrintWriter(output); - for (OutputType outputType : this.output) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + for (OutputType outputType : output) { switch (outputType) { case text: - String textOutput = dump(trialOutDir, "summary-%s.txt", "summary,flat=" + flat + ",traces=" + traces); - pw.println(textOutput); + File out = outputFile("summary-%s.txt"); + dump(out, "summary,flat=" + flat + ",traces=" + traces); + try { + for (String line : FileUtils.readAllLines(out)) { + pw.println(line); + } + } catch (IOException e) { + throw new RuntimeException(e); + } break; case collapsed: - dump(trialOutDir, "collapsed-%s.csv", "collapsed"); + dump(outputFile("collapsed-%s.csv"), "collapsed"); break; case flamegraph: // The last SVG-enabled version is 1.x - String ver = execute("version"); - String ext = ver.startsWith("1.") ? "svg" : "html"; + String ext = isVersion1x ? "svg" : "html"; if (direction == Direction.both || direction == Direction.forward) { - dump(trialOutDir, "flame-%s-forward." + ext, "flamegraph"); + dump(outputFile("flame-%s-forward." + ext), "flamegraph"); } if (direction == Direction.both || direction == Direction.reverse) { - dump(trialOutDir, "flame-%s-reverse." + ext, "flamegraph,reverse"); + dump(outputFile("flame-%s-reverse." + ext), "flamegraph,reverse"); } break; case tree: - dump(trialOutDir, "tree-%s.html", "tree"); + dump(outputFile("tree-%s.html"), "tree"); break; case jfr: - dump(trialOutDir, "%s.jfr", "jfr"); + // JFR is already dumped into file by async-profiler. break; } } @@ -329,19 +409,17 @@ private TextResult stopAndDump(File trialOutDir) { pw.flush(); pw.close(); - return new TextResult(output.toString(), "async"); + return new TextResult(sw.toString(), "async"); } - private String dump(File specificOutDir, String fileNameFormatString, String content) { - File output = new File(specificOutDir, String.format(fileNameFormatString, event)); + private void dump(File target, String command) { + execute(command + "," + profilerConfig + ",file=" + target.getAbsolutePath()); + } + + private File outputFile(String fileNameFormat) { + File output = new File(trialOutDir, String.format(fileNameFormat, outputFilePrefix)); generated.add(output); - String result = execute(content + "," + profilerConfig); - try { - FileUtils.writeLines(output, Collections.singletonList(result)); - return result; - } catch (IOException e) { - return "N/A"; - } + return output; } private String execute(String command) { @@ -379,9 +457,9 @@ private static class ProfilerOptionsBuilder { private final OptionSet optionSet; private final StringBuilder profilerOptions; - ProfilerOptionsBuilder(OptionSet optionSet, StringBuilder profilerOptions) { + ProfilerOptionsBuilder(OptionSet optionSet) { this.optionSet = optionSet; - this.profilerOptions = profilerOptions; + this.profilerOptions = new StringBuilder(); } void appendIfExists(OptionSpec option) { @@ -394,7 +472,11 @@ void append(OptionSpec option) { assert (option.options().size() == 1); String optionName = option.options().iterator().next(); separate(); - profilerOptions.append(optionName).append('=').append(optionSet.valueOf(option).toString()); + profilerOptions.append(optionName); + T arg = optionSet.valueOf(option); + if (arg != null) { + profilerOptions.append('=').append(arg); + } } void appendRaw(String command) { @@ -414,15 +496,20 @@ void appendIfTrue(OptionSpec option) { } } - private void appendMulti(OptionSpec option) { + void appendMulti(OptionSpec option) { if (optionSet.has(option)) { assert (option.options().size() == 1); String optionName = option.options().iterator().next(); for (T value : optionSet.valuesOf(option)) { - profilerOptions.append(',').append(optionName).append('=').append(value.toString()); + separate(); + profilerOptions.append(optionName).append('=').append(value.toString()); } } } + + public String profilerOptions() { + return profilerOptions.toString(); + } } @Override From 299cc723c74ab2b217605942f356bcbdf927247f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 12 May 2021 11:19:46 +0200 Subject: [PATCH 267/342] JMH v1.31. --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 370e438e2..e51c78f5c 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.31-SNAPSHOT + 1.31 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 39227af81..b57514f35 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.31-SNAPSHOT + 1.31 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index b154b3a10..b6f48e5b3 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.31-SNAPSHOT + 1.31 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index be5dbf014..e7656d502 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.31-SNAPSHOT + 1.31 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index 4946029bd..a372ec408 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index bca722c71..b888ecda2 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index a8afe4b46..2c01b4680 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index f9826ce70..35efad9c0 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index de3048286..782d5a6d3 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index f3d4523c4..6d39102d8 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index d97fb9b9d..aeae4aaf5 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index d8e6aa0a1..f30ccc354 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 02accd4e2..da9f5d9dd 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 80920aaca..abfb9b1a7 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.31-SNAPSHOT + 1.31 JMH Samples diff --git a/pom.xml b/pom.xml index a797eac96..3579628bb 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.31-SNAPSHOT + 1.31 Java Microbenchmark Harness Parent From 333fa14597b07c01603a45c0dcfffa620d9f90a1 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 12 May 2021 11:20:02 +0200 Subject: [PATCH 268/342] Continue in 1.32-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index e51c78f5c..6e4e2d358 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.31 + 1.32-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index b57514f35..130a7f241 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.31 + 1.32-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index b6f48e5b3..475014912 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.31 + 1.32-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index e7656d502..3247f1c8f 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.31 + 1.32-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index a372ec408..aeb383f7d 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index b888ecda2..071e5ab1d 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 2c01b4680..458cc39c2 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 35efad9c0..ea936de82 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 782d5a6d3..99408fb09 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 6d39102d8..07f54d1d6 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index aeae4aaf5..95890594f 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index f30ccc354..d063c4ab4 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index da9f5d9dd..87d556783 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index abfb9b1a7..9f89cc28d 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.31 + 1.32-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 3579628bb..3cc65ae33 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.31 + 1.32-SNAPSHOT Java Microbenchmark Harness Parent From 4c34b33e8666b1c121724f445b0b6a14721bdaea Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 26 May 2021 09:23:34 +0000 Subject: [PATCH 269/342] 7902936: Stray output in forked VM breaks external version parsing Reviewed-by: shade --- .../jmh/it/jvmoption/JvmOptionTest.java | 67 +++++++++++++++++++ .../jmh/runner/PrintPropertiesMain.java | 18 +++-- .../main/java/org/openjdk/jmh/util/Utils.java | 28 +++----- 3 files changed, 92 insertions(+), 21 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/jvmoption/JvmOptionTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/jvmoption/JvmOptionTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/jvmoption/JvmOptionTest.java new file mode 100644 index 000000000..cf213c196 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/jvmoption/JvmOptionTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.jvmoption; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +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.util.Utils; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.concurrent.TimeUnit; + +@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +@State(Scope.Thread) +public class JvmOptionTest { + + @Param("") + public String x; + + @Benchmark + public void test() { + Fixtures.work(); + } + + @Test + public void test_api() throws RunnerException { + Path currentJvm = Paths.get(Utils.getCurrentJvm()); + // Construct an alternative path to the JVM to exercise PrintPropertiesMain + Path alternativePathToJvm = currentJvm.getParent().resolve(".").resolve(currentJvm.getFileName()); + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .jvm(alternativePathToJvm.toString()) + .build(); + + new Runner(opts).run(); + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/PrintPropertiesMain.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/PrintPropertiesMain.java index 07669344a..133159cda 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/PrintPropertiesMain.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/PrintPropertiesMain.java @@ -26,6 +26,11 @@ import org.openjdk.jmh.util.Utils; +import java.io.BufferedOutputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; + /** * Main program entry point for exporting the system properties, used for detecting the VM version. */ @@ -35,10 +40,15 @@ class PrintPropertiesMain { * @param argv Command line arguments */ public static void main(String[] argv) throws Exception { - Utils.getRecordedSystemProperties().storeToXML( - System.out, - "JMH properties export for target JVM", - "UTF-8"); + if (argv.length != 1) { + throw new IllegalArgumentException("Usage: java " + PrintPropertiesMain.class.getName() + " "); + } + try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(Paths.get(argv[0])))) { + Utils.getRecordedSystemProperties().storeToXML( + os, + "JMH properties export for target JVM", + "UTF-8"); + } } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index e91aa4a07..31a6fb89e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -575,26 +575,20 @@ public static Properties getRecordedSystemProperties() { public static Properties readPropertiesFromCommand(List cmd) { Properties out = new Properties(); try { - Process p = new ProcessBuilder(cmd).start(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - // drain streams, else we might lock up - InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), System.err); - InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), baos); - - errDrainer.start(); - outDrainer.start(); + File tempFile = FileUtils.tempFile("properties"); + List cmdWithFile = new ArrayList<>(cmd); + cmdWithFile.add(tempFile.getAbsolutePath()); + Collection errs = tryWith(cmdWithFile.toArray(new String[0])); - int err = p.waitFor(); - - errDrainer.join(); - outDrainer.join(); - out.loadFromXML(new ByteArrayInputStream(baos.toByteArray())); + if (!errs.isEmpty()) { + throw new RuntimeException("Unable to extract forked JVM properties using: '" + join(cmd, " ") + "'; " + errs); + } + try (InputStream in = new BufferedInputStream(new FileInputStream(tempFile))) { + // This will automatically pick UTF-8 based on the encoding in the XML declaration. + out.loadFromXML(in); + } } catch (IOException ex) { throw new RuntimeException(ex); - } catch (InterruptedException ex) { - throw new IllegalStateException(ex); } return out; } From 1804d04da87fdadf357731501ab5d2b197aeea6a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 26 May 2021 19:37:13 +0200 Subject: [PATCH 270/342] JMH v1.32. --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 6e4e2d358..49908775b 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.32-SNAPSHOT + 1.32 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 130a7f241..b3d338bf1 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.32-SNAPSHOT + 1.32 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 475014912..df5dfcc8b 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.32-SNAPSHOT + 1.32 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 3247f1c8f..eff8b7d28 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.32-SNAPSHOT + 1.32 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index aeb383f7d..c1a2ac28d 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 071e5ab1d..3517df1c3 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 458cc39c2..3a3e0be5b 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index ea936de82..399407511 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 99408fb09..bd87e82ae 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 07f54d1d6..27b881a25 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 95890594f..d9b8e773b 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index d063c4ab4..d6783100d 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 87d556783..c3dacb9b8 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 9f89cc28d..0d1bc5bd3 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.32-SNAPSHOT + 1.32 JMH Samples diff --git a/pom.xml b/pom.xml index 3cc65ae33..7527c1802 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.32-SNAPSHOT + 1.32 Java Microbenchmark Harness Parent From 6696c744003fd3920c4848d450fb3ed1c83c2239 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 26 May 2021 19:37:32 +0200 Subject: [PATCH 271/342] Continue in 1.33-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 49908775b..a34bd0663 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.32 + 1.33-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index b3d338bf1..069865081 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.32 + 1.33-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index df5dfcc8b..95aa6add7 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.32 + 1.33-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index eff8b7d28..7fa8100ad 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.32 + 1.33-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index c1a2ac28d..dbd9a5747 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 3517df1c3..fa3483429 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 3a3e0be5b..886966cb3 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 399407511..750d911ec 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index bd87e82ae..41541d802 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 27b881a25..3ba45e52e 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index d9b8e773b..836beb31f 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index d6783100d..23bf1f37d 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index c3dacb9b8..2a0d98a70 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index 0d1bc5bd3..c77b07028 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.32 + 1.33-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index 7527c1802..97abfc407 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.32 + 1.33-SNAPSHOT Java Microbenchmark Harness Parent From 0d2a82094d91a782c5d2f2d594987be5c88e956f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Fri, 30 Jul 2021 12:18:25 +0300 Subject: [PATCH 272/342] CODETOOLS-7903002: JMH: StrictFP tests fail with JDK 17+ due to new warnings --- .../java/org/openjdk/jmh/ct/CompileTest.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java index 33f02c36a..a48e61235 100644 --- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java +++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java @@ -34,6 +34,7 @@ import org.openjdk.jmh.generators.core.GeneratorSource; import org.openjdk.jmh.generators.reflection.RFGeneratorSource; import org.openjdk.jmh.util.FileUtils; +import org.openjdk.jmh.util.JDKVersion; import org.openjdk.jmh.util.Utils; import javax.tools.*; @@ -109,33 +110,34 @@ private static boolean doTest(Class klass, InMemoryGeneratorDestination desti } private static Collection javacOptions(boolean annProc, Class klass) { + Collection result = new ArrayList<>(); + + if (!annProc) { + result.add("-proc:none"); + } + // These tests print warnings (as designed), so -Werror fails. - if (klass.equals(SwingTest.class)) { - if (annProc) { - return Collections.emptyList(); - } else { - return Collections.singleton("-proc:none"); - } + boolean noWerror = klass.equals(SwingTest.class); + + if (!noWerror) { + result.add("-Werror"); } // These tests fail when generated code references the static target // through the instance. - if (klass.equals(GenericReturnTest.class) || - klass.equals(PublicStaticBenchmarkTest.class) || - klass.equals(PublicSynchronizedStaticBenchmarkStateBenchmarkTest.class)) { - if (annProc) { - return Arrays.asList("-Xlint:all,-processing,-static", "-Werror"); - } else { - return Arrays.asList("-proc:none", "-Xlint:all,-static", "-Werror"); - } - } + boolean noStatic = klass.equals(GenericReturnTest.class) || + klass.equals(PublicStaticBenchmarkTest.class) || + klass.equals(PublicSynchronizedStaticBenchmarkStateBenchmarkTest.class); - // Regular tests should compile with full lint and Werror. - if (annProc) { - return Arrays.asList("-Xlint:all,-processing", "-Werror"); - } else { - return Arrays.asList("-proc:none", "-Xlint:all", "-Werror"); - } + // JDK 17 introduces a new warning about unnecessary strictfp use. + boolean noStrictFPChecks = JDKVersion.parseMajor(System.getProperty("java.version")) >= 17; + + result.add("-Xlint:all" + + (annProc ? ",-processing" : "") + + (noStatic ? ",-static" : "") + + (noStrictFPChecks ? ",-strictfp" : "")); + + return result; } public static boolean doTestOther(Class klass, GeneratorSource source, InMemoryGeneratorDestination destination) { From 3f720717ab6837d75d0df041d8b1afbaac903960 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 2 Aug 2021 06:33:02 +0000 Subject: [PATCH 273/342] 7903001: JMH: The interrupt to time-outing benchmark can be delivered to warmdown latches Reviewed-by: ecaspole --- .../InterruptibleInterruptTest.java | 68 ++++++++++++++++++ .../NonInterruptibleInterruptTest.java | 69 +++++++++++++++++++ .../generators/core/BenchmarkGenerator.java | 18 ++--- .../org/openjdk/jmh/runner/InfraControl.java | 26 +++++-- 4 files changed, 165 insertions(+), 16 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/InterruptibleInterruptTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/NonInterruptibleInterruptTest.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/InterruptibleInterruptTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/InterruptibleInterruptTest.java new file mode 100644 index 000000000..7e10b2e23 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/InterruptibleInterruptTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2021, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.interrupts; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +public class InterruptibleInterruptTest { + + @Benchmark + public void test() { + try { + Thread.sleep(5_000); + } catch (InterruptedException e) { + // Harness delivered, just exit. + } + } + + @Test + public void invokeAPI() throws RunnerException { + for (Mode m : Mode.values()) { + if (m != Mode.All) continue; + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .mode(m) + .timeout(TimeValue.seconds(1)) + .build(); + + new Runner(opt).run(); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/NonInterruptibleInterruptTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/NonInterruptibleInterruptTest.java new file mode 100644 index 000000000..283fc7f9c --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/NonInterruptibleInterruptTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.interrupts; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.it.Fixtures; +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 java.util.concurrent.TimeUnit; + +@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS) +@Fork(1) +public class NonInterruptibleInterruptTest { + + @Benchmark + public void test() { + // This method deliberately does not check interrupt status. + long start = System.currentTimeMillis(); + long end = start + 5_000; + while (System.currentTimeMillis() < end) { + Blackhole.consumeCPU(10_000); + } + } + + @Test + public void invokeAPI() throws RunnerException { + for (Mode m : Mode.values()) { + if (m != Mode.All) continue; + Options opt = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .shouldFailOnError(true) + .mode(m) + .timeout(TimeValue.seconds(1)) + .build(); + + new Runner(opt).run(); + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index d870a9b94..999bd1b7c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -595,10 +595,10 @@ private void generateThroughput(PrintWriter writer, Mode benchmarkKind, MethodGr writer.println(ident(5) + "res.allOps++;"); writer.println(ident(4) + "}"); - writer.println(ident(4) + "control.preTearDown();"); - writer.println(ident(3) + "} catch (InterruptedException ie) {"); - writer.println(ident(4) + "control.preTearDownForce();"); + writer.println(ident(3) + "} catch (Throwable e) {"); + writer.println(ident(4) + "if (!(e instanceof InterruptedException)) throw e;"); writer.println(ident(3) + "}"); + writer.println(ident(3) + "control.preTearDown();"); // iteration prolog iterationEpilog(writer, 3, method, states); @@ -728,10 +728,10 @@ private void generateAverageTime(PrintWriter writer, Mode benchmarkKind, MethodG writer.println(ident(5) + "res.allOps++;"); writer.println(ident(4) + "}"); - writer.println(ident(4) + "control.preTearDown();"); - writer.println(ident(3) + "} catch (InterruptedException ie) {"); - writer.println(ident(4) + "control.preTearDownForce();"); + writer.println(ident(3) + "} catch (Throwable e) {"); + writer.println(ident(4) + "if (!(e instanceof InterruptedException)) throw e;"); writer.println(ident(3) + "}"); + writer.println(ident(3) + "control.preTearDown();"); iterationEpilog(writer, 3, method, states); @@ -891,10 +891,10 @@ private void generateSampleTime(PrintWriter writer, Mode benchmarkKind, MethodGr writer.println(ident(5) + "res.allOps++;"); writer.println(ident(4) + "}"); - writer.println(ident(4) + "control.preTearDown();"); - writer.println(ident(3) + "} catch (InterruptedException ie) {"); - writer.println(ident(4) + "control.preTearDownForce();"); + writer.println(ident(3) + "} catch (Throwable e) {"); + writer.println(ident(4) + "if (!(e instanceof InterruptedException)) throw e;"); writer.println(ident(3) + "}"); + writer.println(ident(3) + "control.preTearDown();"); iterationEpilog(writer, 3, method, states); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java index ac0743674..8bc6e019a 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java @@ -77,17 +77,29 @@ public long getDuration(TimeUnit unit) { } public void preSetup() { - try { - preSetup.countDown(); - preSetup.await(); - } catch (InterruptedException e) { - throw new IllegalStateException(e); + preSetup.countDown(); + + while (true) { + try { + preSetup.await(); + return; + } catch (InterruptedException e) { + // Do not accept interrupts here. + } } } - public void preTearDown() throws InterruptedException { + public void preTearDown() { preTearDown.countDown(); - preTearDown.await(); + + while (true) { + try { + preTearDown.await(); + return; + } catch (InterruptedException e) { + // Do not accept interrupts here. + } + } } public void preSetupForce() { From dd6e9636173ab7512031132c5ff74eb4d428e884 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 2 Aug 2021 16:05:31 +0000 Subject: [PATCH 274/342] 7903003: JMH: Print a single interruption message per iteration Reviewed-by: ecaspole --- .../main/java/org/openjdk/jmh/runner/BenchmarkHandler.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index dd7ecc69e..2e47856b2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -361,19 +361,20 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa control.awaitWarmdownReady(); // Wait for the result, handling timeouts + int interrupts = 0; while (completed.size() < numThreads) { try { long waitFor = Math.max(TimeUnit.MILLISECONDS.toNanos(100), waitDeadline - System.nanoTime()); Future fr = srv.poll(waitFor, TimeUnit.NANOSECONDS); if (fr == null) { // We are in the timeout mode now, kick all the still running threads. - out.print("(*interrupt*) "); for (BenchmarkTask task : runners) { Thread runner = task.runner; if (runner != null) { runner.interrupt(); } } + interrupts++; } else { completed.add(fr); } @@ -382,6 +383,10 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa } } + if (interrupts > 0) { + out.print("(benchmark timed out, interrupted " + interrupts + " times) "); + } + // Process the results: we get here after all worker threads have quit, // either normally or abnormally. This means, Future.get() would never block. long allOps = 0; From b8f1d778a46bb8d949bbfff6ee8e238d3b4455b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Fri, 6 Aug 2021 10:19:30 +0300 Subject: [PATCH 275/342] 7903004: JMH: Compiler Blackholes auto-detection --- .../org/openjdk/jmh/runner/CompilerHints.java | 153 ++++++++++++++++-- .../jmh/runner/format/TextReportFormat.java | 4 +- 2 files changed, 143 insertions(+), 14 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java index 8eaa53935..eecf0a643 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java @@ -25,7 +25,7 @@ package org.openjdk.jmh.runner; import org.openjdk.jmh.util.FileUtils; -import org.openjdk.jmh.util.JDKVersion; +import org.openjdk.jmh.util.Utils; import java.io.*; import java.util.*; @@ -46,7 +46,14 @@ public class CompilerHints extends AbstractResourceReader { static final String XX_COMPILE_COMMAND_FILE = "-XX:CompileCommandFile="; - static final String BLACKHOLE_PROP_NAME = "jmh.blackhole.mode"; + static final String BLACKHOLE_MODE_NAME = "jmh.blackhole.mode"; + static final String BLACKHOLE_AUTODETECT_NAME = "jmh.blackhole.autoDetect"; + static final String BLACKHOLE_DEBUG_NAME = "jmh.blackhole.debug"; + + static final boolean BLACKHOLE_MODE_AUTODETECT = + Boolean.parseBoolean(System.getProperty(BLACKHOLE_AUTODETECT_NAME, "false")); + static final boolean BLACKHOLE_MODE_DEBUG = + Boolean.parseBoolean(System.getProperty(BLACKHOLE_DEBUG_NAME, "false")); public static CompilerHints defaultList() { if (defaultList == null) { @@ -237,28 +244,60 @@ private static String mergeHintFiles(List compileCommandFiles) { } } + private static BlackholeMode blackholeMode; + private static BlackholeSelect blackholeSelect; + private static BlackholeMode blackholeMode() { - String prop = System.getProperty(BLACKHOLE_PROP_NAME); - if (prop != null) { + if (blackholeMode != null) { + return blackholeMode; + } + + // Forced mode takes precedence. + String propMode = System.getProperty(BLACKHOLE_MODE_NAME); + if (propMode != null) { try { - return BlackholeMode.valueOf(prop); + blackholeMode = BlackholeMode.valueOf(propMode); + blackholeSelect = BlackholeSelect.FORCED; + + // Extra safety: If user requested compiler blackholes, check + // if they are available and fail otherwise. + if (blackholeMode.shouldBlackhole() && !compilerBlackholesAvailable()) { + throw new IllegalStateException("Compiler Blackholes are not available in current VM"); + } + + return blackholeMode; } catch (IllegalArgumentException iae) { - throw new IllegalStateException("Unknown Blackhole mode: " + prop); + throw new IllegalStateException("Unknown Blackhole mode: " + propMode); + } + } + + // Try to autodetect blackhole mode, fail if not available + if (BLACKHOLE_MODE_AUTODETECT) { + if (compilerBlackholesAvailable()) { + blackholeMode = BlackholeMode.COMPILER; + blackholeSelect = BlackholeSelect.AUTO; + } else { + blackholeMode = BlackholeMode.FULL_DONTINLINE; + blackholeSelect = BlackholeSelect.FALLBACK; } + return blackholeMode; } - return BlackholeMode.FULL_DONTINLINE; + + // Not forced, not auto-detected, default + blackholeMode = BlackholeMode.FULL_DONTINLINE; + blackholeSelect = BlackholeSelect.DEFAULT; + return blackholeMode; } - public static void printBlackholeMode(PrintStream out) { - BlackholeMode mode = blackholeMode(); - out.print("# Blackhole mode: " + mode.desc()); - out.println(); + private static BlackholeSelect blackholeSelect() { + blackholeMode(); + return blackholeSelect; } private enum BlackholeMode { - COMPILER(true, false, "compiler-assisted (EXPERIMENTAL, check generated code)"), + COMPILER(true, false, "compiler"), FULL_DONTINLINE(false, true, "full + dont-inline hint"), - FULL(false, false, "full (DIAGNOSTIC)"), + FULL(false, false, "full"), ; private final boolean shouldBlackhole; @@ -282,4 +321,92 @@ public boolean shouldNotInline() { public String desc() { return desc; } } + private enum BlackholeSelect { + DEFAULT("default, use -D" + BLACKHOLE_AUTODETECT_NAME + "=true to auto-detect"), + AUTO("auto-detected"), + FALLBACK("fallback, use -D" + BLACKHOLE_MODE_NAME + " to force"), + FORCED("forced"), + ; + + final String desc; + + BlackholeSelect(String desc) { + this.desc = desc; + } + + public String desc() { + return desc; + } + } + + private static boolean compilerBlackholesAvailable() { + // Step 1. See if there were any error messages from CompilerOracle + { + List cmd = new ArrayList<>(); + cmd.add(Utils.getCurrentJvm()); + cmd.add("-XX:+UnlockExperimentalVMOptions"); + cmd.add("-XX:CompileCommand=quiet"); + cmd.add("-XX:CompileCommand=blackhole,some/fake/Class.method"); + cmd.add("-version"); + + debug("Blackhole command errors test:"); + + Collection log = Utils.runWith(cmd); + for (String l : log) { + debug(l); + if (l.contains("CompilerOracle") || l.contains("CompileCommand")) { + debug("Found the suspected error line, no compiler blackholes."); + return false; + } + } + } + + // Step 2. See that CompilerOracle accepted the command explicitly + { + List cmd = new ArrayList<>(); + cmd.add(Utils.getCurrentJvm()); + cmd.add("-XX:+UnlockExperimentalVMOptions"); + cmd.add("-XX:CompileCommand=blackhole,some/fake/Class.method"); + cmd.add("-version"); + + debug("Blackhole command acceptance test:"); + + Collection log = Utils.runWith(cmd); + for (String l : log) { + debug(l); + if (l.contains("CompilerOracle") || l.contains("CompileCommand")) { + debug("Found the acceptance line, compiler blackholes are available."); + return true; + } + } + } + + // Err on the side of the caution: compiler blackholes are not available. + debug("Compiler blackholes are not available."); + return false; + } + + private static void debug(String msg) { + if (BLACKHOLE_MODE_DEBUG) { + System.out.println(msg); + } + } + + public static void printBlackhole(PrintStream out) { + BlackholeMode mode = blackholeMode(); + out.print("# Blackhole mode: " + mode.desc() + " (" + blackholeSelect().desc() + ")"); + out.println(); + } + + public static void printWarnings(PrintStream out) { + if (blackholeMode() == BlackholeMode.COMPILER) { + out.println("NOTE: Current JVM experimentally supports Compiler Blackholes, and they are in use. Please exercise"); + out.println("extra caution when trusting the results, look into the generated code to check the benchmark still"); + out.println("works, and factor in a small probability of new VM bugs. Additionally, while comparisons between"); + out.println("different JVMs are already problematic, the performance difference caused by different Blackhole"); + out.println("modes can be very significant. Please make sure you use the consistent Blackhole mode for comparisons."); + out.println(); + } + } + } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java index 33b7b58c6..505bdd8f7 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/format/TextReportFormat.java @@ -81,7 +81,7 @@ public void startBenchmark(BenchmarkParams params) { println("# VM invoker: " + params.getJvm()); println("# VM options: " + opts); - CompilerHints.printBlackholeMode(out); + CompilerHints.printBlackhole(out); IterationParams warmup = params.getWarmup(); if (warmup.getCount() > 0) { @@ -241,6 +241,8 @@ public void endRun(Collection runResults) { out.println("Do not assume the numbers tell you what you want them to tell."); out.println(); + CompilerHints.printWarnings(out); + ResultFormatFactory.getInstance(ResultFormatType.TEXT, out).writeOut(runResults); } From 066da6a9e8627e097c1c6f253acf74b10e32defe Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 9 Aug 2021 12:22:21 +0300 Subject: [PATCH 276/342] JMH v1.33. --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index a34bd0663..1a462592b 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.33-SNAPSHOT + 1.33 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 069865081..d5d30b810 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.33-SNAPSHOT + 1.33 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 95aa6add7..ca82a79e3 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.33-SNAPSHOT + 1.33 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 7fa8100ad..678e5ad13 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.33-SNAPSHOT + 1.33 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index dbd9a5747..c6b5fb1a0 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index fa3483429..6abfb3a8f 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 886966cb3..6892cc6b7 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 750d911ec..6bd3bed03 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 41541d802..14e84fa71 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 3ba45e52e..849b7718e 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 836beb31f..a229aa230 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 23bf1f37d..bedb528a9 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 2a0d98a70..8151323a2 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index c77b07028..dc75ada45 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.33-SNAPSHOT + 1.33 JMH Samples diff --git a/pom.xml b/pom.xml index 97abfc407..edd4b3e60 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.33-SNAPSHOT + 1.33 Java Microbenchmark Harness Parent From fa8dec9bdfafb21c1895eb596255a90b48da8248 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 9 Aug 2021 12:22:52 +0300 Subject: [PATCH 277/342] Continue in 1.34-SNAPSHOT --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index 1a462592b..ba276c6c8 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.33 + 1.34-SNAPSHOT jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index d5d30b810..1f5ac49aa 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.33 + 1.34-SNAPSHOT jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index ca82a79e3..4bdf943f8 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.33 + 1.34-SNAPSHOT jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index 678e5ad13..fbe674c84 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.33 + 1.34-SNAPSHOT jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index c6b5fb1a0..af7f0ccc6 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 6abfb3a8f..6b61fc14f 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 6892cc6b7..65c2dd141 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index 6bd3bed03..b3c2e1c28 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 14e84fa71..d57e7310c 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 849b7718e..bf115b74a 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index a229aa230..21dae171c 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index bedb528a9..59bb32d88 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 8151323a2..91f97ae0d 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index dc75ada45..aaaed0cd3 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.33 + 1.34-SNAPSHOT JMH Samples diff --git a/pom.xml b/pom.xml index edd4b3e60..08c70fc2e 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.33 + 1.34-SNAPSHOT Java Microbenchmark Harness Parent From cc45ba26e0b8e046559353330ca61f4fd7eb207e Mon Sep 17 00:00:00 2001 From: Ian Kerins Date: Wed, 1 Sep 2021 07:21:44 +0000 Subject: [PATCH 278/342] 7903000: JMH: Fix error message for @Setup helpers on a class missing @State Reviewed-by: shade --- .../org/openjdk/jmh/generators/core/StateObjectHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java index 86b0edf34..e5b36db19 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java @@ -531,7 +531,7 @@ private void checkHelpers(MethodInfo mi, Class annClass) { if (BenchmarkGeneratorUtils.getAnnSuper(mi.getDeclaringClass(), State.class) == null) { if (!mi.getDeclaringClass().isAbstract()) { throw new GenerationException( - "@" + TearDown.class.getSimpleName() + " annotation is placed within " + + "@" + annClass.getSimpleName() + " annotation is placed within " + "the class not having @" + State.class.getSimpleName() + " annotation. " + "This has no behavioral effect, and prohibited.", mi); From 6f151470c8db1d8f2d3cd0e4d1ac24c314b461a4 Mon Sep 17 00:00:00 2001 From: Oliver Eikemeier Date: Wed, 1 Sep 2021 08:10:27 +0000 Subject: [PATCH 279/342] Update JOpt Simple to 5.0.4 Reviewed-by: shade --- THIRD-PARTY | 44 ++++++++++--------- jmh-ant-sample/THIRD-PARTY | 44 ++++++++++--------- jmh-archetypes/THIRD-PARTY | 44 ++++++++++--------- .../THIRD-PARTY | 44 ++++++++++--------- .../src/main/resources/THIRD-PARTY | 44 ++++++++++--------- .../jmh-java-benchmark-archetype/THIRD-PARTY | 44 ++++++++++--------- .../src/main/resources/THIRD-PARTY | 44 ++++++++++--------- .../THIRD-PARTY | 44 ++++++++++--------- .../src/main/resources/THIRD-PARTY | 44 ++++++++++--------- .../jmh-scala-benchmark-archetype/THIRD-PARTY | 44 ++++++++++--------- .../src/main/resources/THIRD-PARTY | 44 ++++++++++--------- jmh-core-benchmarks/THIRD-PARTY | 44 ++++++++++--------- jmh-core-benchmarks/src/main/THIRD-PARTY | 44 ++++++++++--------- jmh-core/THIRD-PARTY | 44 ++++++++++--------- .../runner/options/IntegerValueConverter.java | 2 +- .../runner/options/ThreadsValueConverter.java | 2 +- jmh-core/src/main/resources/THIRD-PARTY | 44 ++++++++++--------- .../jmh/runner/options/TestOptions.java | 22 +++++----- jmh-generator-annprocess/THIRD-PARTY | 44 ++++++++++--------- .../src/main/resources/THIRD-PARTY | 44 ++++++++++--------- jmh-generator-asm/THIRD-PARTY | 44 ++++++++++--------- .../src/main/resources/THIRD-PARTY | 44 ++++++++++--------- jmh-generator-bytecode/THIRD-PARTY | 44 ++++++++++--------- .../src/main/resources/THIRD-PARTY | 44 ++++++++++--------- jmh-generator-reflection/THIRD-PARTY | 44 ++++++++++--------- .../src/main/resources/THIRD-PARTY | 44 ++++++++++--------- jmh-samples/THIRD-PARTY | 44 ++++++++++--------- jmh-samples/src/main/resources/THIRD-PARTY | 44 ++++++++++--------- pom.xml | 2 +- 29 files changed, 589 insertions(+), 539 deletions(-) diff --git a/THIRD-PARTY b/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/THIRD-PARTY +++ b/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-ant-sample/THIRD-PARTY b/jmh-ant-sample/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-ant-sample/THIRD-PARTY +++ b/jmh-ant-sample/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-archetypes/THIRD-PARTY b/jmh-archetypes/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-archetypes/THIRD-PARTY +++ b/jmh-archetypes/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/THIRD-PARTY b/jmh-archetypes/jmh-groovy-benchmark-archetype/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/THIRD-PARTY +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/THIRD-PARTY b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/THIRD-PARTY +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/THIRD-PARTY b/jmh-archetypes/jmh-java-benchmark-archetype/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/THIRD-PARTY +++ b/jmh-archetypes/jmh-java-benchmark-archetype/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/THIRD-PARTY b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/THIRD-PARTY +++ b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/THIRD-PARTY b/jmh-archetypes/jmh-kotlin-benchmark-archetype/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/THIRD-PARTY +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/THIRD-PARTY b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/THIRD-PARTY +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/THIRD-PARTY b/jmh-archetypes/jmh-scala-benchmark-archetype/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/THIRD-PARTY +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/THIRD-PARTY b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/THIRD-PARTY +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-core-benchmarks/THIRD-PARTY b/jmh-core-benchmarks/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-core-benchmarks/THIRD-PARTY +++ b/jmh-core-benchmarks/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-core-benchmarks/src/main/THIRD-PARTY b/jmh-core-benchmarks/src/main/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-core-benchmarks/src/main/THIRD-PARTY +++ b/jmh-core-benchmarks/src/main/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-core/THIRD-PARTY b/jmh-core/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-core/THIRD-PARTY +++ b/jmh-core/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/IntegerValueConverter.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/IntegerValueConverter.java index 430c5ac7d..83be90fe1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/IntegerValueConverter.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/IntegerValueConverter.java @@ -66,7 +66,7 @@ public Integer convert(String value) { } @Override - public Class valueType() { + public Class valueType() { return TO_INT_CONVERTER.valueType(); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ThreadsValueConverter.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ThreadsValueConverter.java index c88f876ac..c032eac3e 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ThreadsValueConverter.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/ThreadsValueConverter.java @@ -42,7 +42,7 @@ public Integer convert(String value) { } @Override - public Class valueType() { + public Class valueType() { return IntegerValueConverter.POSITIVE.valueType(); } diff --git a/jmh-core/src/main/resources/THIRD-PARTY b/jmh-core/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-core/src/main/resources/THIRD-PARTY +++ b/jmh-core/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java index c3f8f97dc..4c19e760e 100644 --- a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java +++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java @@ -244,7 +244,7 @@ public void testThreads_Zero() { new CommandLineOptions("-t", "0"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '0' of option ['t']. The given value 0 should be positive", e.getMessage()); + Assert.assertEquals("Cannot parse argument '0' of option t. The given value 0 should be positive", e.getMessage()); } } @@ -264,7 +264,7 @@ public void testThreads_MinusOne() { new CommandLineOptions("-t", "-1"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '-1' of option ['t']. The given value -1 should be positive", e.getMessage()); + Assert.assertEquals("Cannot parse argument '-1' of option t. The given value -1 should be positive", e.getMessage()); } } @@ -274,7 +274,7 @@ public void testThreads_Minus42() { new CommandLineOptions("-t", "-42"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '-42' of option ['t']. The given value -42 should be positive", e.getMessage()); + Assert.assertEquals("Cannot parse argument '-42' of option t. The given value -42 should be positive", e.getMessage()); } } @@ -337,7 +337,7 @@ public void testThreadGroups_WithNegative() { new CommandLineOptions("-tg", "-1,-2"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '-1' of option ['tg']. The given value -1 should be non-negative", e.getMessage()); + Assert.assertEquals("Cannot parse argument '-1' of option tg. The given value -1 should be non-negative", e.getMessage()); } } @@ -395,7 +395,7 @@ public void testWarmupIterations_MinusOne() { new CommandLineOptions("-wi", "-1"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '-1' of option ['wi']. The given value -1 should be non-negative", e.getMessage()); + Assert.assertEquals("Cannot parse argument '-1' of option wi. The given value -1 should be non-negative", e.getMessage()); } } @@ -439,7 +439,7 @@ public void testRuntimeIterations_Zero() { new CommandLineOptions("-i", "0"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '0' of option ['i']. The given value 0 should be positive", e.getMessage()); + Assert.assertEquals("Cannot parse argument '0' of option i. The given value 0 should be positive", e.getMessage()); } } @@ -515,7 +515,7 @@ public void testOPI_Zero() { new CommandLineOptions("-opi", "0"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '0' of option ['opi']. The given value 0 should be positive", e.getMessage()); + Assert.assertEquals("Cannot parse argument '0' of option opi. The given value 0 should be positive", e.getMessage()); } } @@ -559,7 +559,7 @@ public void testFork_MinusOne() { new CommandLineOptions("-f", "-1"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '-1' of option ['f']. The given value -1 should be non-negative", e.getMessage()); + Assert.assertEquals("Cannot parse argument '-1' of option f. The given value -1 should be non-negative", e.getMessage()); } } @@ -598,7 +598,7 @@ public void testWarmupFork_MinusOne() { new CommandLineOptions("-wf", "-1"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '-1' of option ['wf']. The given value -1 should be non-negative", e.getMessage()); + Assert.assertEquals("Cannot parse argument '-1' of option wf. The given value -1 should be non-negative", e.getMessage()); } } @@ -678,7 +678,7 @@ public void testBatchSize_Zero() { new CommandLineOptions("-bs", "0"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '0' of option ['bs']. The given value 0 should be positive", e.getMessage()); + Assert.assertEquals("Cannot parse argument '0' of option bs. The given value 0 should be positive", e.getMessage()); } } @@ -710,7 +710,7 @@ public void testWarmupBatchSize_Zero() { new CommandLineOptions("-wbs", "0"); Assert.fail(); } catch (CommandLineOptionException e) { - Assert.assertEquals("Cannot parse argument '0' of option ['wbs']. The given value 0 should be positive", e.getMessage()); + Assert.assertEquals("Cannot parse argument '0' of option wbs. The given value 0 should be positive", e.getMessage()); } } diff --git a/jmh-generator-annprocess/THIRD-PARTY b/jmh-generator-annprocess/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-generator-annprocess/THIRD-PARTY +++ b/jmh-generator-annprocess/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-generator-annprocess/src/main/resources/THIRD-PARTY b/jmh-generator-annprocess/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-generator-annprocess/src/main/resources/THIRD-PARTY +++ b/jmh-generator-annprocess/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-generator-asm/THIRD-PARTY b/jmh-generator-asm/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-generator-asm/THIRD-PARTY +++ b/jmh-generator-asm/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-generator-asm/src/main/resources/THIRD-PARTY b/jmh-generator-asm/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-generator-asm/src/main/resources/THIRD-PARTY +++ b/jmh-generator-asm/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-generator-bytecode/THIRD-PARTY b/jmh-generator-bytecode/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-generator-bytecode/THIRD-PARTY +++ b/jmh-generator-bytecode/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-generator-bytecode/src/main/resources/THIRD-PARTY b/jmh-generator-bytecode/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-generator-bytecode/src/main/resources/THIRD-PARTY +++ b/jmh-generator-bytecode/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-generator-reflection/THIRD-PARTY b/jmh-generator-reflection/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-generator-reflection/THIRD-PARTY +++ b/jmh-generator-reflection/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-generator-reflection/src/main/resources/THIRD-PARTY b/jmh-generator-reflection/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-generator-reflection/src/main/resources/THIRD-PARTY +++ b/jmh-generator-reflection/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-samples/THIRD-PARTY b/jmh-samples/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-samples/THIRD-PARTY +++ b/jmh-samples/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/jmh-samples/src/main/resources/THIRD-PARTY b/jmh-samples/src/main/resources/THIRD-PARTY index 49b55b874..7de6bce97 100644 --- a/jmh-samples/src/main/resources/THIRD-PARTY +++ b/jmh-samples/src/main/resources/THIRD-PARTY @@ -1,30 +1,32 @@ DO NOT TRANSLATE OR LOCALIZE. ----------------------------- -%% This notice is provided with respect to JOpt-Simple v4.6 +%% This notice is provided with respect to JOpt Simple v5.0.4 --- begin of LICENSE --- -Copyright (c) SourceForge - -The MIT License Copyright (c) Permission is hereby granted, free of -charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, copy, -modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. + The MIT License + + Copyright (c) 2004-2021 Paul R. Holser, Jr. + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- end of LICENSE --- diff --git a/pom.xml b/pom.xml index 97abfc407..bbd516654 100644 --- a/pom.xml +++ b/pom.xml @@ -271,7 +271,7 @@ questions. net.sf.jopt-simple jopt-simple - 4.6 + 5.0.4 org.apache.commons From 730f02b2af7fe23af5f22c33e36070987788b2de Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Thu, 14 Oct 2021 08:24:08 +0000 Subject: [PATCH 280/342] 7903023: Update Kotlin in Maven archetypes to the latest stable version Reviewed-by: shade --- .../src/main/resources/archetype-resources/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml index b60991728..2c8a04334 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/src/main/resources/archetype-resources/pom.xml @@ -75,7 +75,7 @@ THE POSSIBILITY OF SUCH DAMAGE. Available versions are listed here: http://kotlinlang.org/docs/reference/using-maven.html#plugin-and-versions --> - 1.0.2 + 1.5.30 + -Djmh.ignoreLock=true -Xms256m -Xmx256m -Djmh.core.it.profile=${jmh.core.it.profile} @@ -66,8 +68,7 @@ questions. org.apache.maven.plugins maven-surefire-plugin - - -Djmh.ignoreLock=true -Xms256m -Xmx256m -Djmh.core.it.profile=${jmh.core.it.profile} + ${jmh.testjvmargs} 1C false @@ -125,6 +126,96 @@ questions. + + executor-virtual + + executor-virtual + + + + org.openjdk.jmh + jmh-generator-annprocess + ${project.version} + provided + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + ${jmh.testjvmargs} -Djmh.executor=VIRTUAL + + + + + + + + executor-fjp + + executor-fjp + + + + org.openjdk.jmh + jmh-generator-annprocess + ${project.version} + provided + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + ${jmh.testjvmargs} -Djmh.executor=FJP + + + + + + + + executor-custom + + executor-custom + + + + org.openjdk.jmh + jmh-generator-annprocess + ${project.version} + provided + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + ${jmh.testjvmargs} -Djmh.executor=CUSTOM -Djmh.executor.class=org.openjdk.jmh.it.CustomExecutorService + + + + + + asm diff --git a/jmh-core-it/src/main/java/org/openjdk/jmh/it/CustomExecutorService.java b/jmh-core-it/src/main/java/org/openjdk/jmh/it/CustomExecutorService.java new file mode 100644 index 000000000..4723b84a8 --- /dev/null +++ b/jmh-core-it/src/main/java/org/openjdk/jmh/it/CustomExecutorService.java @@ -0,0 +1,108 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.*; + +/** + * Synthetic executor service to test the corner case where executor always starts + * the task in the separate thread. Tests JMH invariants to the limit. + */ +public class CustomExecutorService implements ExecutorService { + public CustomExecutorService(int maxThreads, String prefix) { + // Do nothing + } + + @Override + public void shutdown() { + // Do nothing + } + + @Override + public List shutdownNow() { + return new ArrayList<>(); + } + + @Override + public boolean isShutdown() { + return false; + } + + @Override + public boolean isTerminated() { + return false; + } + + @Override + public boolean awaitTermination(long timeout, TimeUnit unit) { + return true; + } + + @Override + public Future submit(Callable task) { + FutureTask ft = new FutureTask<>(task); + new Thread(ft).start(); + return ft; + } + + @Override + public void execute(Runnable command) { + new Thread(command).start(); + } + + @Override + public Future submit(Runnable task, T result) { + throw new UnsupportedOperationException(); + } + + @Override + public Future submit(Runnable task) { + throw new UnsupportedOperationException(); + } + + @Override + public List> invokeAll(Collection> tasks) { + throw new UnsupportedOperationException(); + } + + @Override + public List> invokeAll(Collection> tasks, long timeout, TimeUnit unit) { + throw new UnsupportedOperationException(); + } + + @Override + public T invokeAny(Collection> tasks) { + throw new UnsupportedOperationException(); + } + + @Override + public T invokeAny(Collection> tasks, long timeout, TimeUnit unit) { + throw new UnsupportedOperationException(); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/Fixtures.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/Fixtures.java index 64b268a63..23731ab5f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/Fixtures.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/Fixtures.java @@ -24,11 +24,27 @@ */ package org.openjdk.jmh.it; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.concurrent.TimeUnit; public class Fixtures { - private static final int REPS = Integer.getInteger("jmh.it.reps", 1); + private static final int REPS; + private static final String PROFILE; + + static { + REPS = AccessController.doPrivileged(new PrivilegedAction() { + public Integer run() { + return Integer.getInteger("jmh.it.reps", 1); + } + }); + PROFILE = AccessController.doPrivileged(new PrivilegedAction() { + public String run() { + return System.getProperty("jmh.core.it.profile"); + } + }); + } public static int repetitionCount() { return REPS; @@ -47,4 +63,12 @@ public static void work() { } } + public static boolean expectStableThreads() { + return isDefaultProfile(); + } + + public static boolean isDefaultProfile() { + return PROFILE.equals("default"); + } + } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java index ed318919d..8c5e705f2 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero1ThreadCountTest.java @@ -26,17 +26,7 @@ import org.junit.Assert; import org.junit.Test; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.Fork; -import org.openjdk.jmh.annotations.Group; -import org.openjdk.jmh.annotations.GroupThreads; -import org.openjdk.jmh.annotations.Measurement; -import org.openjdk.jmh.annotations.Mode; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; -import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.it.Fixtures; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; @@ -61,7 +51,11 @@ public class Zero1ThreadCountTest { @TearDown public void check() { Assert.assertEquals(0, test1threads.size()); - Assert.assertEquals(2, test2threads.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(2, test2threads.size()); + } else { + Assert.assertTrue(test2threads.size() >= 2); + } } @Benchmark diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java index fb8f97033..80e8e0031 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/asymm/Zero2ThreadCountTest.java @@ -60,7 +60,11 @@ public class Zero2ThreadCountTest { @TearDown public void check() { - Assert.assertEquals(1, test1threads.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(1, test1threads.size()); + } else { + Assert.assertTrue(test1threads.size() >= 1); + } Assert.assertEquals(0, test2threads.size()); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java index c960cbac8..4395af8b6 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java @@ -68,6 +68,12 @@ public void testAll() throws RunnerException { } private void testWith(String initLine) throws RunnerException { + if (!Fixtures.expectStableThreads()) { + // This test assumes threads survive until the end of run to get their + // allocation data. + return; + } + Options opts = new OptionsBuilder() .include(Fixtures.getTestMask(this.getClass())) .addProfiler(GCProfiler.class, initLine) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/SecurityManagerTestUtils.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/SecurityManagerTestUtils.java index 3a6696d0a..0ab492dd2 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/SecurityManagerTestUtils.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/security/SecurityManagerTestUtils.java @@ -24,11 +24,19 @@ */ package org.openjdk.jmh.it.security; +import java.security.AccessController; +import java.security.PrivilegedAction; + public class SecurityManagerTestUtils { public static void install() { try { - System.setSecurityManager(new SecurityManager()); + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { + System.setSecurityManager(new SecurityManager()); + return null; + } + }); } catch (UnsupportedOperationException uoe) { // Probably modern JDK without SecurityManager support. } @@ -36,7 +44,12 @@ public static void install() { public static void remove() { try { - System.setSecurityManager(null); + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { + System.setSecurityManager(null); + return null; + } + }); } catch (UnsupportedOperationException uoe) { // Probably modern JDK without SecurityManager support. } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkBenchSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkBenchSharingTest.java index eda7f3459..9936cface 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkBenchSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkBenchSharingTest.java @@ -55,7 +55,11 @@ public class BenchmarkBenchSharingTest { @TearDown(Level.Trial) public void tearDown() { - Assert.assertEquals("All the threads have visited this state", 2, visitors.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(2, visitors.size()); + } else { + Assert.assertTrue(visitors.size() >= 2); + } } @Benchmark diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkStateSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkStateSharingTest.java index c57b85f7f..dae263fbe 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkStateSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/BenchmarkStateSharingTest.java @@ -56,7 +56,11 @@ public static class MyState { @TearDown(Level.Trial) public void tearDown() { - Assert.assertEquals("All the threads have visited this state", 2, visitors.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(2, visitors.size()); + } else { + Assert.assertTrue(visitors.size() >= 2); + } } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupBenchSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupBenchSharingTest.java index 9c63f5a22..8f8457211 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupBenchSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupBenchSharingTest.java @@ -56,7 +56,11 @@ public class GroupBenchSharingTest { @TearDown(Level.Trial) public void tearDown() { - Assert.assertEquals("All the threads have visited this state", 4, visitors.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(4, visitors.size()); + } else { + Assert.assertTrue(visitors.size() >= 4); + } } @Benchmark diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java index 2e9bdf34b..61f2981aa 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultBenchSharingTest.java @@ -56,7 +56,11 @@ public class GroupDefaultBenchSharingTest { @TearDown(Level.Trial) public void tearDown() { - Assert.assertEquals("All the threads have visited this state", 2, visitors.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(2, visitors.size()); + } else { + Assert.assertTrue(visitors.size() >= 2); + } } @Benchmark diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java index ccab9d836..48174c89f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupDefaultStateSharingTest.java @@ -57,7 +57,11 @@ public static class MyState { @TearDown(Level.Trial) public void tearDown() { - Assert.assertEquals("All the threads have visited this state", 2, visitors.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(2, visitors.size()); + } else { + Assert.assertTrue(visitors.size() >= 2); + } } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupStateSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupStateSharingTest.java index d72f47df9..225684fb8 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupStateSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/GroupStateSharingTest.java @@ -57,7 +57,11 @@ public static class MyState { @TearDown(Level.Trial) public void tearDown() { - Assert.assertEquals("All the threads have visited this state", 4, visitors.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(4, visitors.size()); + } else { + Assert.assertTrue(visitors.size() >= 4); + } } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadBenchSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadBenchSharingTest.java index fe1e5a2f5..7810ce217 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadBenchSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadBenchSharingTest.java @@ -55,7 +55,11 @@ public class ThreadBenchSharingTest { @TearDown(Level.Trial) public void tearDown() { - Assert.assertEquals("Single thread have visited this state", 1, visitors.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(1, visitors.size()); + } else { + Assert.assertTrue(visitors.size() >= 1); + } } @Benchmark diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadStateSharingTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadStateSharingTest.java index bdcc8ba39..998a67fc6 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadStateSharingTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/sharing/ThreadStateSharingTest.java @@ -56,7 +56,11 @@ public static class MyState { @TearDown(Level.Trial) public void tearDown() { - Assert.assertEquals("Single thread has visited this state", 1, visitors.size()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(1, visitors.size()); + } else { + Assert.assertTrue(visitors.size() >= 1); + } } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java index b88d62a49..71ac647ea 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/MaxThreadCountTest.java @@ -56,7 +56,11 @@ public class MaxThreadCountTest { @TearDown(Level.Iteration) public void tearDown() { - Assert.assertEquals("amount of threads should be Runtime.getRuntime().availableProcessors()", threads.size(), Runtime.getRuntime().availableProcessors()); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(threads.size(), Runtime.getRuntime().availableProcessors()); + } else { + Assert.assertTrue(threads.size() >= Runtime.getRuntime().availableProcessors()); + } } @Benchmark diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java index 26baf63e8..1fe30f3f3 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/OneThreadCountTest.java @@ -56,7 +56,11 @@ public class OneThreadCountTest { @TearDown(Level.Iteration) public void tearDown() { - Assert.assertEquals("amount of threads should be 1", threads.size(), 1); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(1, threads.size()); + } else { + Assert.assertTrue(threads.size() >= 1); + } } @Benchmark diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadBenchSameThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadBenchSameThreadTest.java index f97f0af97..fcb82c5d4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadBenchSameThreadTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadBenchSameThreadTest.java @@ -44,6 +44,9 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.TimeUnit; /** @@ -52,70 +55,57 @@ @State(Scope.Thread) public class ThreadBenchSameThreadTest { - private Thread setupRunThread; - private Thread setupIterationThread; - private Thread setupInvocationThread; - private Thread teardownRunThread; - private Thread teardownIterationThread; - private Thread tearDownInvocationThread; - private Thread testInvocationThread; + private final Set setupRunThread = Collections.synchronizedSet(new HashSet<>()); + private final Set setupIterationThread = Collections.synchronizedSet(new HashSet<>()); + private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet<>()); + private final Set teardownRunThread = Collections.synchronizedSet(new HashSet<>()); + private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet<>()); + private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet<>()); + private final Set testInvocationThread = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Trial) public void setupRun() { - if (setupRunThread == null) { - setupRunThread = Thread.currentThread(); - } - Assert.assertEquals("setupRun", setupRunThread, Thread.currentThread()); + setupRunThread.add(Thread.currentThread()); } @Setup(Level.Iteration) public void setupIteration() { - if (setupIterationThread == null) { - setupIterationThread = Thread.currentThread(); - } - Assert.assertEquals("setupIteration", setupIterationThread, Thread.currentThread()); + setupIterationThread.add(Thread.currentThread()); } @Setup(Level.Invocation) public void setupInvocation() { - if (setupInvocationThread == null) { - setupInvocationThread = Thread.currentThread(); - } - Assert.assertEquals("setupInvocation", setupInvocationThread, Thread.currentThread()); + setupInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void tearDownRun() { - if (teardownRunThread == null) { - teardownRunThread = Thread.currentThread(); + teardownRunThread.add(Thread.currentThread()); + + // Threads can change iteration to iteration + if (Fixtures.expectStableThreads()) { + Assert.assertEquals("test == setupRun", testInvocationThread, setupRunThread); + Assert.assertEquals("test == teardownRun", testInvocationThread, teardownRunThread); + } else { + Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread)); + Assert.assertTrue("test <: teardownRunThread", testInvocationThread.containsAll(teardownRunThread)); } - Assert.assertEquals("teardownRun", teardownRunThread, Thread.currentThread()); } @TearDown(Level.Iteration) public void tearDownIteration() { - if (teardownIterationThread == null) { - teardownIterationThread = Thread.currentThread(); - } - Assert.assertEquals("teardownIteration", teardownIterationThread, Thread.currentThread()); + teardownIterationThread.add(Thread.currentThread()); + + // Within iteration, expect the same thread + Assert.assertEquals("test == setupIteration", testInvocationThread, setupIterationThread); + Assert.assertEquals("test == teardownIteration", testInvocationThread, teardownIterationThread); + Assert.assertEquals("test == setupInvocation", testInvocationThread, setupInvocationThread); + Assert.assertEquals("test == teardownInvocation", testInvocationThread, teardownInvocationThread); } @TearDown(Level.Invocation) public void tearDownInvocation() { - if (tearDownInvocationThread == null) { - tearDownInvocationThread = Thread.currentThread(); - } - Assert.assertEquals("tearDownInvocation", tearDownInvocationThread, Thread.currentThread()); - } - - @TearDown(Level.Trial) - public void teardownZZZ() { // should perform last - Assert.assertEquals("test != setupRun", testInvocationThread, setupRunThread); - Assert.assertEquals("test != setupIteration", testInvocationThread, setupIterationThread); - Assert.assertEquals("test != setupInvocation", testInvocationThread, setupInvocationThread); - Assert.assertEquals("test != teardownRun", testInvocationThread, teardownRunThread); - Assert.assertEquals("test != teardownIteration", testInvocationThread, teardownIterationThread); - Assert.assertEquals("test != teardownInvocation", testInvocationThread, tearDownInvocationThread); + teardownInvocationThread.add(Thread.currentThread()); } @Benchmark @@ -125,10 +115,7 @@ public void teardownZZZ() { // should perform last @Fork(1) @Threads(4) public void test() { - if (testInvocationThread == null) { - testInvocationThread = Thread.currentThread(); - } - Assert.assertEquals("test", testInvocationThread, Thread.currentThread()); + testInvocationThread.add(Thread.currentThread()); Fixtures.work(); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadStateSameThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadStateSameThreadTest.java index becd481be..5b2b28a0f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadStateSameThreadTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/ThreadStateSameThreadTest.java @@ -44,6 +44,9 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.TimeUnit; /** @@ -54,70 +57,57 @@ public class ThreadStateSameThreadTest { @State(Scope.Thread) public static class MyState { - private Thread setupRunThread; - private Thread setupIterationThread; - private Thread setupInvocationThread; - private Thread teardownRunThread; - private Thread teardownIterationThread; - private Thread teardownInvocationThread; - private Thread testInvocationThread; + private final Set setupRunThread = Collections.synchronizedSet(new HashSet<>()); + private final Set setupIterationThread = Collections.synchronizedSet(new HashSet<>()); + private final Set setupInvocationThread = Collections.synchronizedSet(new HashSet<>()); + private final Set teardownRunThread = Collections.synchronizedSet(new HashSet<>()); + private final Set teardownIterationThread = Collections.synchronizedSet(new HashSet<>()); + private final Set teardownInvocationThread = Collections.synchronizedSet(new HashSet<>()); + private final Set testInvocationThread = Collections.synchronizedSet(new HashSet<>()); @Setup(Level.Trial) public void setupRun() { - if (setupRunThread == null) { - setupRunThread = Thread.currentThread(); - } - Assert.assertEquals("setupRun", setupRunThread, Thread.currentThread()); + setupRunThread.add(Thread.currentThread()); } @Setup(Level.Iteration) public void setupIteration() { - if (setupIterationThread == null) { - setupIterationThread = Thread.currentThread(); - } - Assert.assertEquals("setupIteration", setupIterationThread, Thread.currentThread()); + setupIterationThread.add(Thread.currentThread()); } @Setup(Level.Invocation) public void setupInvocation() { - if (setupInvocationThread == null) { - setupInvocationThread = Thread.currentThread(); - } - Assert.assertEquals("setupInvocation", setupInvocationThread, Thread.currentThread()); + setupInvocationThread.add(Thread.currentThread()); } @TearDown(Level.Trial) public void tearDownRun() { - if (teardownRunThread == null) { - teardownRunThread = Thread.currentThread(); + teardownRunThread.add(Thread.currentThread()); + + // Threads can change iteration to iteration + if (Fixtures.expectStableThreads()) { + Assert.assertEquals("test == setupRun", testInvocationThread, setupRunThread); + Assert.assertEquals("test == teardownRun", testInvocationThread, teardownRunThread); + } else { + Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread)); + Assert.assertTrue("test <: teardownRunThread", testInvocationThread.containsAll(teardownRunThread)); } - Assert.assertEquals("teardownRun", teardownRunThread, Thread.currentThread()); } @TearDown(Level.Iteration) public void tearDownIteration() { - if (teardownIterationThread == null) { - teardownIterationThread = Thread.currentThread(); - } - Assert.assertEquals("teardownIteration", teardownIterationThread, Thread.currentThread()); + teardownIterationThread.add(Thread.currentThread()); + + // Within iteration, expect the same thread + Assert.assertEquals("test == setupIteration", testInvocationThread, setupIterationThread); + Assert.assertEquals("test == teardownIteration", testInvocationThread, teardownIterationThread); + Assert.assertEquals("test == setupInvocation", testInvocationThread, setupInvocationThread); + Assert.assertEquals("test == teardownInvocation", testInvocationThread, teardownInvocationThread); } @TearDown(Level.Invocation) public void tearDownInvocation() { - if (teardownInvocationThread == null) { - teardownInvocationThread = Thread.currentThread(); - } - Assert.assertEquals("tearDownInvocation", teardownInvocationThread, Thread.currentThread()); - } - - @TearDown(Level.Trial) - public void teardownZZZ() { // should perform last - Assert.assertEquals("test != setupRun", testInvocationThread, setupRunThread); - Assert.assertEquals("test != setupIteration", testInvocationThread, setupIterationThread); - Assert.assertEquals("test != setupInvocation", testInvocationThread, setupInvocationThread); - Assert.assertEquals("test != teardownRun", testInvocationThread, teardownRunThread); - Assert.assertEquals("test != teardownIteration", testInvocationThread, teardownIterationThread); - Assert.assertEquals("test != teardownInvocation", testInvocationThread, teardownInvocationThread); + teardownInvocationThread.add(Thread.currentThread()); } } @@ -128,10 +118,7 @@ public void teardownZZZ() { // should perform last @Fork(1) @Threads(4) public void test(MyState state) { - if (state.testInvocationThread == null) { - state.testInvocationThread = Thread.currentThread(); - } - Assert.assertEquals("test", state.testInvocationThread, Thread.currentThread()); + state.testInvocationThread.add(Thread.currentThread()); Fixtures.work(); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java index be2e92cd3..b841caccd 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/threads/TwoThreadCountTest.java @@ -56,7 +56,11 @@ public class TwoThreadCountTest { @TearDown(Level.Iteration) public void tearDown() { - Assert.assertEquals("amount of threads should be 2", threads.size(), 2); + if (Fixtures.expectStableThreads()) { + Assert.assertEquals(2, threads.size()); + } else { + Assert.assertTrue(threads.size() >= 2); + } } @Benchmark diff --git a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java index b6bc77aba..c418de8f9 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java @@ -27,6 +27,8 @@ import org.openjdk.jmh.util.Utils; import java.lang.ref.WeakReference; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Random; /* @@ -251,9 +253,15 @@ public final class Blackhole extends BlackholeL4 { * AND LOTS OF TIME OVER THAT. ADJUST YOUR PLANS ACCORDINGLY. */ - private static final boolean COMPILER_BLACKHOLE = Boolean.getBoolean("compilerBlackholesEnabled"); + private static final boolean COMPILER_BLACKHOLE; static { + COMPILER_BLACKHOLE = AccessController.doPrivileged(new PrivilegedAction() { + public Boolean run() { + return Boolean.getBoolean("compilerBlackholesEnabled"); + } + }); + Utils.check(Blackhole.class, "b1", "b2"); Utils.check(Blackhole.class, "bool1", "bool2"); Utils.check(Blackhole.class, "c1", "c2"); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java index 0f2642a05..086415559 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BaseRunner.java @@ -257,8 +257,9 @@ protected void runBenchmark(BenchmarkParams benchParams, BenchmarkHandler handle } out.iteration(benchParams, wp, i); + boolean isFirstIteration = (i == 1); boolean isLastIteration = (benchParams.getMeasurement().getCount() == 0); - IterationResult ir = handler.runIteration(benchParams, wp, isLastIteration); + IterationResult ir = handler.runIteration(benchParams, wp, isFirstIteration, isLastIteration); out.iterationResult(benchParams, wp, i, ir); allWarmup += ir.getMetadata().getAllOps(); @@ -277,8 +278,9 @@ protected void runBenchmark(BenchmarkParams benchParams, BenchmarkHandler handle // run benchmark iteration out.iteration(benchParams, mp, i); + boolean isFirstIteration = (benchParams.getWarmup().getCount() == 0) && (i == 1); boolean isLastIteration = (i == mp.getCount()); - IterationResult ir = handler.runIteration(benchParams, mp, isLastIteration); + IterationResult ir = handler.runIteration(benchParams, mp, isFirstIteration, isLastIteration); out.iterationResult(benchParams, mp, i, ir); allMeasurement += ir.getMetadata().getAllOps(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java index e018f5e1e..736239375 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkException.java @@ -40,7 +40,9 @@ public BenchmarkException(Throwable ex) { public BenchmarkException(String msg, Collection errors) { super(msg); for (Throwable err : errors) { - addSuppressed(err); + if (err != null) { + addSuppressed(err); + } } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index cb83f3bd2..53a4ab309 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -53,7 +53,10 @@ class BenchmarkHandler { */ private final ExecutorService executor; + private final CyclicBarrier workerDataBarrier; private final ConcurrentMap workerData; + private final BlockingQueue unusedWorkerData; + private final BlockingQueue tps; private final OutputFormat out; @@ -74,14 +77,18 @@ public BenchmarkHandler(OutputFormat out, Options options, BenchmarkParams execu profilersRev = new ArrayList<>(profilers); Collections.reverse(profilersRev); - tps = new ArrayBlockingQueue<>(executionParams.getThreads()); - tps.addAll(distributeThreads(executionParams.getThreads(), executionParams.getThreadGroups())); + int threads = executionParams.getThreads(); + + tps = new ArrayBlockingQueue<>(threads); + tps.addAll(distributeThreads(threads, executionParams.getThreadGroups())); + workerDataBarrier = new CyclicBarrier(threads, this::captureUnusedWorkerData); workerData = new ConcurrentHashMap<>(); + unusedWorkerData = new ArrayBlockingQueue<>(threads); this.out = out; try { - executor = EXECUTOR_TYPE.createExecutor(executionParams.getThreads(), executionParams.getBenchmark()); + executor = EXECUTOR_TYPE.createExecutor(threads, executionParams.getBenchmark()); } catch (Exception e) { throw new IllegalStateException(e); } @@ -182,6 +189,11 @@ private enum ExecutorType { ExecutorService createExecutor(int maxThreads, String prefix) { return Executors.newFixedThreadPool(maxThreads, WorkerThreadFactories.platformWorkerFactory(prefix)); } + + @Override + boolean stableThreads() { + return true; + } }, /** @@ -204,6 +216,9 @@ ExecutorService createExecutor(int maxThreads, String prefix) { } }, + /** + * Use custom executor + */ CUSTOM { @Override ExecutorService createExecutor(int maxThreads, String prefix) throws Exception { @@ -216,6 +231,11 @@ ExecutorService createExecutor(int maxThreads, String prefix) throws Exception { ; abstract ExecutorService createExecutor(int maxThreads, String prefix) throws Exception; + + /** + * @return Executor always reuses the same threads? + */ + boolean stableThreads() { return false; } } protected void startProfilers(BenchmarkParams benchmarkParams, IterationParams iterationParams) { @@ -271,10 +291,12 @@ public void shutdown() { * * @param benchmarkParams Benchmark parameters * @param params Iteration parameters - * @param last Should this iteration considered to be the last + * @param isFirstIteration Should this iteration considered to be the first + * @param isLastIteration Should this iteration considered to be the last * @return IterationResult */ - public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationParams params, boolean last) { + public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationParams params, + boolean isFirstIteration, boolean isLastIteration) { int numThreads = benchmarkParams.getThreads(); TimeValue runtime = params.getTime(); @@ -285,7 +307,8 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa List iterationResults = new ArrayList<>(); InfraControl control = new InfraControl(benchmarkParams, params, - preSetupBarrier, preTearDownBarrier, last, + preSetupBarrier, preTearDownBarrier, + isFirstIteration, isLastIteration, new Control()); // preparing the worker runnables @@ -376,8 +399,14 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa allOps += btr.getAllOps(); measuredOps += btr.getMeasuredOps(); } catch (ExecutionException ex) { - // unwrap: ExecutionException -> Throwable-wrapper -> InvocationTargetException - Throwable cause = ex.getCause().getCause().getCause(); + // Unwrap at most three exceptions through benchmark-thrown exception: + // ExecutionException -> Throwable-wrapper -> InvocationTargetException + // + // Infrastructural exceptions come with shorter causal chains. + Throwable cause = ex; + for (int c = 0; (c < 3) && (cause.getCause() != null); c++) { + cause = cause.getCause(); + } // record exception, unless it is the assist exception if (!(cause instanceof FailureAssistException)) { @@ -403,12 +432,46 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa return result; } - private WorkerData newWorkerData(Thread worker) { - WorkerData wd = workerData.get(worker); - if (wd != null) { - return wd; + + private WorkerData getWorkerData(Thread worker) { + // See if there is a good worker data for us already, use it. + WorkerData wd = workerData.remove(worker); + + // Wait for all threads to roll to this synchronization point. + // If there is any thread without assignment, the barrier action + // would dump the unused worker data for claiming. + try { + workerDataBarrier.await(); + } catch (InterruptedException | BrokenBarrierException e) { + throw new IllegalStateException("Worker data barrier error ", e); + } + + if (wd == null) { + // Odd mode, no worker task recorded for the thread. Pull the worker data + // from the unused queue. This can only happen with executors with unstable threads. + if (EXECUTOR_TYPE.stableThreads()) { + throw new IllegalStateException("Worker data assignment failed for executor with stable threads"); + } + + wd = unusedWorkerData.poll(); + if (wd == null) { + throw new IllegalStateException("Cannot get another thread working data"); + } } + WorkerData exist = workerData.put(worker, wd); + if (exist != null) { + throw new IllegalStateException("Duplicate thread data"); + } + return wd; + } + + private void captureUnusedWorkerData() { + unusedWorkerData.addAll(workerData.values()); + workerData.clear(); + } + + private WorkerData newWorkerData(Thread worker) { try { Object o = clazz.getConstructor().newInstance(); ThreadParams t = tps.poll(); @@ -416,7 +479,7 @@ private WorkerData newWorkerData(Thread worker) { throw new IllegalStateException("Cannot get another thread params"); } - wd = new WorkerData(o, t); + WorkerData wd = new WorkerData(o, t); WorkerData exist = workerData.put(worker, wd); if (exist != null) { throw new IllegalStateException("Duplicate thread data"); @@ -446,7 +509,7 @@ public BenchmarkTaskResult call() throws Exception { runner = Thread.currentThread(); // poll the current data, or instantiate in this thread, if needed - WorkerData wd = newWorkerData(runner); + WorkerData wd = control.firstIteration ? newWorkerData(runner) : getWorkerData(runner); return (BenchmarkTaskResult) method.invoke(wd.instance, control, wd.params); } catch (Throwable e) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java index 8bc6e019a..7baf11895 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java @@ -47,6 +47,7 @@ public class InfraControl extends InfraControlL4 { Utils.check(InfraControl.class, "isDone", "isFailing"); Utils.check(InfraControl.class, "volatileSpoiler"); Utils.check(InfraControl.class, "preSetup", "preTearDown"); + Utils.check(InfraControl.class, "firstIteration"); Utils.check(InfraControl.class, "lastIteration"); Utils.check(InfraControl.class, "warmupVisited", "warmdownVisited"); Utils.check(InfraControl.class, "warmupShouldWait", "warmdownShouldWait"); @@ -56,9 +57,10 @@ public class InfraControl extends InfraControlL4 { } public InfraControl(BenchmarkParams benchmarkParams, IterationParams iterationParams, - CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, + CountDownLatch preSetup, CountDownLatch preTearDown, + boolean firstIteration, boolean lastIteration, Control notifyControl) { - super(benchmarkParams, iterationParams, preSetup, preTearDown, lastIteration, notifyControl); + super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, notifyControl); } /** @@ -161,6 +163,7 @@ abstract class InfraControlL2 extends InfraControlL1 { public final CountDownLatch preSetup; public final CountDownLatch preTearDown; + public final boolean firstIteration; public final boolean lastIteration; public final AtomicInteger warmupVisited, warmdownVisited; @@ -175,7 +178,8 @@ abstract class InfraControlL2 extends InfraControlL1 { private final int threads; public InfraControlL2(BenchmarkParams benchmarkParams, IterationParams iterationParams, - CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, + CountDownLatch preSetup, CountDownLatch preTearDown, + boolean firstIteration, boolean lastIteration, Control notifyControl) { warmupVisited = new AtomicInteger(); warmdownVisited = new AtomicInteger(); @@ -193,6 +197,7 @@ public InfraControlL2(BenchmarkParams benchmarkParams, IterationParams iteration this.preSetup = preSetup; this.preTearDown = preTearDown; + this.firstIteration = firstIteration; this.lastIteration = lastIteration; this.benchmarkParams = benchmarkParams; this.iterationParams = iterationParams; @@ -274,9 +279,10 @@ abstract class InfraControlL3 extends InfraControlL2 { private boolean q171, q172, q173, q174, q175, q176, q177, q178; public InfraControlL3(BenchmarkParams benchmarkParams, IterationParams iterationParams, - CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, + CountDownLatch preSetup, CountDownLatch preTearDown, + boolean firstIteration, boolean lastIteration, Control notifyControl) { - super(benchmarkParams, iterationParams, preSetup, preTearDown, lastIteration, notifyControl); + super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, notifyControl); } } @@ -284,9 +290,10 @@ abstract class InfraControlL4 extends InfraControlL3 { private int markerEnd; public InfraControlL4(BenchmarkParams benchmarkParams, IterationParams iterationParams, - CountDownLatch preSetup, CountDownLatch preTearDown, boolean lastIteration, + CountDownLatch preSetup, CountDownLatch preTearDown, + boolean firstIteration, boolean lastIteration, Control notifyControl) { - super(benchmarkParams, iterationParams, preSetup, preTearDown, lastIteration, notifyControl); + super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, notifyControl); } } From 93843626500b0c320fca23efe4c9ff8a2f368add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 6 Jun 2023 15:53:21 +0200 Subject: [PATCH 332/342] 7903484: JMH: Use ThreadMXBean.getTotalThreadAllocatedBytes for -prof gc --- .github/workflows/pre-integration.yml | 3 +- .../GCProfilerSeparateThreadTest.java | 96 +++++++++++++++++++ .../org/openjdk/jmh/profile/GCProfiler.java | 93 ++++++++++++++---- 3 files changed, 171 insertions(+), 21 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java diff --git a/.github/workflows/pre-integration.yml b/.github/workflows/pre-integration.yml index 440675290..7410e71f7 100644 --- a/.github/workflows/pre-integration.yml +++ b/.github/workflows/pre-integration.yml @@ -28,9 +28,10 @@ jobs: - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v3 with: - distribution: zulu + distribution: temurin java-version: ${{ matrix.java }} cache: maven + check-latest: true - name: Run build with tests (Default) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java new file mode 100644 index 000000000..6a42a377a --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java @@ -0,0 +1,96 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.GCProfiler; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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.util.JDKVersion; + +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(value = 1, jvmArgs = {"-Xms1g", "-Xmx1g", "-XX:+UseParallelGC"}) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +public class GCProfilerSeparateThreadTest { + + static final int SIZE = 1_000_000; + + @Benchmark + public void separateAlloc(Blackhole bh) throws InterruptedException { + Thread t = new Thread(() -> bh.consume(new byte[SIZE])); + t.start(); + t.join(); + } + + @Test + public void testDefault() throws RunnerException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(GCProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + double allocRateNormB = sr.get("·gc.alloc.rate.norm").getScore(); + + String msg = "Reported by profiler: " + allocRateNormB + ", target: " + SIZE; + + // Allow 1% slack + if (accurateProfiler() && (Math.abs(1 - allocRateNormB / SIZE) > 0.01)) { + Assert.fail("Allocation rate failure. Reported by profiler: " + allocRateNormB + ", target: " + SIZE); + } + + System.out.println(msg); + } + + private boolean accurateProfiler() { + // Change to this version-sensing code after JDK 21 releases: + // return JDKVersion.parseMajor(System.getProperty("java.version")) >= 21; + + // Try to sense the existence of the accurate method: + try { + Class.forName("com.sun.management.ThreadMXBean").getMethod("getTotalThreadAllocatedBytes"); + return true; + } catch (Exception e) { + // Fall through + } + + return false; + } +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java index 5373d2fa7..ddbf29e06 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java @@ -36,7 +36,6 @@ import org.openjdk.jmh.util.Multiset; import javax.management.ListenerNotFoundException; -import javax.management.Notification; import javax.management.NotificationEmitter; import javax.management.NotificationListener; import javax.management.openmbean.CompositeData; @@ -151,9 +150,9 @@ public Collection afterIteration(BenchmarkParams benchmarkPara } if (allocEnabled) { - if (beforeAllocated != HotspotAllocationSnapshot.EMPTY) { + if (beforeAllocated != null) { HotspotAllocationSnapshot newSnapshot = VMSupport.getSnapshot(); - long allocated = newSnapshot.subtract(beforeAllocated); + long allocated = newSnapshot.difference(beforeAllocated); // When no allocations measured, we still need to report results to avoid user confusion results.add(new ScalarResult(Defaults.PREFIX + "gc.alloc.rate", (afterTime != beforeTime) ? @@ -204,13 +203,40 @@ public Collection afterIteration(BenchmarkParams benchmarkPara return results; } - static class HotspotAllocationSnapshot { - public final static HotspotAllocationSnapshot EMPTY = new HotspotAllocationSnapshot(new long[0], new long[0]); + interface HotspotAllocationSnapshot { + long difference(HotspotAllocationSnapshot before); + } + + static class GlobalHotspotAllocationSnapshot implements HotspotAllocationSnapshot { + private final long allocatedBytes; + + public GlobalHotspotAllocationSnapshot(long allocatedBytes) { + this.allocatedBytes = allocatedBytes; + } + @Override + public long difference(HotspotAllocationSnapshot before) { + if (!(before instanceof GlobalHotspotAllocationSnapshot)) { + throw new IllegalArgumentException(); + } + + GlobalHotspotAllocationSnapshot other = (GlobalHotspotAllocationSnapshot) before; + + long beforeAllocs = other.allocatedBytes; + if (allocatedBytes >= beforeAllocs) { + return allocatedBytes - beforeAllocs; + } else { + // Do not allow negative values + return 0; + } + } + } + + static class PerThreadHotspotAllocationSnapshot implements HotspotAllocationSnapshot { private final long[] threadIds; private final long[] allocatedBytes; - private HotspotAllocationSnapshot(long[] threadIds, long[] allocatedBytes) { + private PerThreadHotspotAllocationSnapshot(long[] threadIds, long[] allocatedBytes) { this.threadIds = threadIds; this.allocatedBytes = allocatedBytes; } @@ -224,7 +250,13 @@ private HotspotAllocationSnapshot(long[] threadIds, long[] allocatedBytes) { * * @return estimated number of allocated bytes between profiler calls */ - public long subtract(HotspotAllocationSnapshot other) { + public long difference(HotspotAllocationSnapshot before) { + if (!(before instanceof PerThreadHotspotAllocationSnapshot)) { + throw new IllegalArgumentException(); + } + + PerThreadHotspotAllocationSnapshot other = (PerThreadHotspotAllocationSnapshot) before; + HashMap prevIndex = new HashMap<>(); for (int i = 0; i < other.threadIds.length; i++) { long id = other.threadIds[i]; @@ -254,7 +286,8 @@ public long subtract(HotspotAllocationSnapshot other) { */ static class VMSupport { private static ThreadMXBean ALLOC_MX_BEAN; - private static Method ALLOC_MX_BEAN_GETTER; + private static Method ALLOC_MX_BEAN_GETTER_PER_THREAD; + private static Method ALLOC_MX_BEAN_GETTER_GLOBAL; private static NotificationListener LISTENER; private static Multiset CHURN; @@ -272,9 +305,19 @@ private static boolean tryInitAlloc() { } ALLOC_MX_BEAN = bean; - ALLOC_MX_BEAN_GETTER = internalIntf.getMethod("getThreadAllocatedBytes", long[].class); - getAllocatedBytes(bean.getAllThreadIds()); + // See if global getter is available in this JVM + try { + ALLOC_MX_BEAN_GETTER_GLOBAL = internalIntf.getMethod("getTotalThreadAllocatedBytes"); + getSnapshot(); + return true; + } catch (Exception e) { + // Fall through + } + + // See if per-thread getter is available in this JVM + ALLOC_MX_BEAN_GETTER_PER_THREAD = internalIntf.getMethod("getThreadAllocatedBytes", long[].class); + getSnapshot(); return true; } catch (Throwable e) { System.out.println("Allocation profiling is not available: " + e.getMessage()); @@ -299,14 +342,6 @@ private static boolean tryInitChurn() { return false; } - private static long[] getAllocatedBytes(long[] threadIds) { - try { - return (long[]) ALLOC_MX_BEAN_GETTER.invoke(ALLOC_MX_BEAN, (Object) threadIds); - } catch (InvocationTargetException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - } - private static NotificationListener newListener() { try { final Class infoKlass = Class.forName("com.sun.management.GarbageCollectionNotificationInfo"); @@ -343,9 +378,27 @@ private static NotificationListener newListener() { } public static HotspotAllocationSnapshot getSnapshot() { + // Try the global getter first, if available + if (ALLOC_MX_BEAN_GETTER_GLOBAL != null) { + try { + long allocatedBytes = (long) ALLOC_MX_BEAN_GETTER_GLOBAL.invoke(ALLOC_MX_BEAN); + if (allocatedBytes == -1L) { + throw new IllegalStateException("getTotalThreadAllocatedBytes is disabled"); + } + return new GlobalHotspotAllocationSnapshot(allocatedBytes); + } catch (InvocationTargetException | IllegalAccessException e) { + throw new IllegalStateException(e); + } + } + + // Fall back to per-thread getter long[] threadIds = ALLOC_MX_BEAN.getAllThreadIds(); - long[] allocatedBytes = getAllocatedBytes(threadIds); - return new HotspotAllocationSnapshot(threadIds, allocatedBytes); + try { + long[] allocatedBytes = (long[]) ALLOC_MX_BEAN_GETTER_PER_THREAD.invoke(ALLOC_MX_BEAN, (Object) threadIds); + return new PerThreadHotspotAllocationSnapshot(threadIds, allocatedBytes); + } catch (InvocationTargetException | IllegalAccessException e) { + throw new IllegalStateException(e); + } } public static synchronized void startChurnProfile() { From bf8db38250af9435a13dde822df22c3aee6dc2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 8 Jun 2023 11:16:38 +0200 Subject: [PATCH 333/342] 7903487: JMH: Make sure JMH profilers work on all tested configurations --- .github/workflows/pre-integration.yml | 7 ++ .../java/org/openjdk/jmh/it/Fixtures.java | 3 + .../it/profilers/AbstractAsmProfilerTest.java | 70 +++++++++++ .../it/profilers/ClassloadProfilerTest.java | 102 ++++++++++++++++ .../it/profilers/CompilerProfilerTest.java | 78 ++++++++++++ .../it/profilers/DTraceAsmProfilerTest.java | 65 ++++++++++ .../it/profilers/GCProfilerAllocRateTest.java | 4 +- .../GCProfilerSeparateThreadTest.java | 2 +- .../JavaFlightRecorderProfilerTest.java | 62 ++++++++++ .../profilers/LinuxPerfAsmProfilerTest.java | 65 ++++++++++ .../profilers/LinuxPerfC2CProfilerTest.java | 80 ++++++++++++ .../profilers/LinuxPerfNormProfilerTest.java | 95 +++++++++++++++ .../it/profilers/LinuxPerfProfilerTest.java | 91 ++++++++++++++ .../jmh/it/profilers/MemPoolProfilerTest.java | 90 ++++++++++++++ .../jmh/it/profilers/ProfilerTestUtils.java | 53 ++++++++ .../it/profilers/SafepointsProfilerTest.java | 115 ++++++++++++++++++ .../jmh/it/profilers/StackProfilerTest.java | 78 ++++++++++++ .../it/profilers/WinPerfAsmProfilerTest.java | 65 ++++++++++ .../jmh/profile/DTraceAsmProfiler.java | 2 +- .../jmh/profile/LinuxPerfAsmProfiler.java | 11 +- .../jmh/profile/LinuxPerfC2CProfiler.java | 5 + .../jmh/profile/LinuxPerfNormProfiler.java | 29 ++++- .../openjdk/jmh/profile/MemPoolProfiler.java | 2 +- .../org/openjdk/jmh/profile/PerfSupport.java | 11 ++ .../main/java/org/openjdk/jmh/util/Utils.java | 4 + 25 files changed, 1177 insertions(+), 12 deletions(-) create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractAsmProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/JavaFlightRecorderProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ProfilerTestUtils.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java create mode 100644 jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java diff --git a/.github/workflows/pre-integration.yml b/.github/workflows/pre-integration.yml index 7410e71f7..7ec1069bb 100644 --- a/.github/workflows/pre-integration.yml +++ b/.github/workflows/pre-integration.yml @@ -32,6 +32,13 @@ jobs: java-version: ${{ matrix.java }} cache: maven check-latest: true + - name: Set up perf (Linux) + run: | + sudo apt-get update + sudo apt-get install -y linux-tools-common linux-tools-generic linux-tools-`uname -r` + echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid + perf stat echo 1 + if: (runner.os == 'Linux') - name: Run build with tests (Default) run: mvn clean install -P ${{ matrix.profile }} -B --file pom.xml diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/Fixtures.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/Fixtures.java index 23731ab5f..b5c3ab849 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/Fixtures.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/Fixtures.java @@ -71,4 +71,7 @@ public static boolean isDefaultProfile() { return PROFILE.equals("default"); } + public static boolean isVirtualExecutor() { + return PROFILE.contains("executor-virtual"); + } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractAsmProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractAsmProfilerTest.java new file mode 100644 index 000000000..7cd74d080 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractAsmProfilerTest.java @@ -0,0 +1,70 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.util.JDKVersion; + +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +@State(Scope.Thread) +public abstract class AbstractAsmProfilerTest { + + private static final int SIZE = 10_000; + + private byte[] src, dst; + + @Setup + public void setup() { + src = new byte[SIZE]; + dst = new byte[SIZE]; + } + + @Benchmark + public void work() { + // Call something that definitely results in calling a native stub. + // This should work on environments where hsdis is not available. + System.arraycopy(src, 0, dst, 0, SIZE); + } + + public static boolean checkDisassembly(String out) { + if (JDKVersion.parseMajor(System.getProperty("java.version")) >= 17) { + // Should always print, since abstract assembler is available + return out.contains("StubRoutines::"); + } else { + if (out.contains("StubRoutines::")) { + // hsdis is enabled, good + return true; + } else { + // hsdis is not enabled, okay + return out.contains(""); + } + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java new file mode 100644 index 000000000..a48acfeaf --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java @@ -0,0 +1,102 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.ClassloaderProfiler; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +public class ClassloadProfilerTest { + + // Simplest Dummy class + static final byte[] CLASS = new byte[] { + (byte) 0xca, (byte) 0xfe, (byte) 0xba, (byte) 0xbe, + 0x00, 0x00, 0x00, 0x34, + 0x00, 0x0a, 0x0a, 0x00, 0x02, 0x00, 0x03, 0x07, + 0x00, 0x04, 0x0c, 0x00, 0x05, 0x00, 0x06, 0x01, + 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, + 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, + 0x69, 0x74, 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, + 0x56, 0x07, 0x00, 0x08, 0x01, 0x00, 0x05, 0x44, + 0x75, 0x6d, 0x6d, 0x79, 0x01, 0x00, 0x04, 0x43, + 0x6f, 0x64, 0x65, 0x00, 0x21, 0x00, 0x07, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x05, 0x00, 0x06, 0x00, 0x01, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, (byte) 0xb7, 0x00, + 0x01, (byte) 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + static class MyClassLoader extends ClassLoader { + public Class loadClass(String name) throws ClassNotFoundException { + if (name.equals("Dummy")) { + return defineClass(name, CLASS, 0, CLASS.length, null); + } else { + return super.loadClass(name); + } + } + } + + @Benchmark + public Class work() throws Exception { + Fixtures.work(); + ClassLoader loader = new MyClassLoader(); + return Class.forName("Dummy", true, loader); + } + + @Test + public void test() throws RunnerException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(ClassloaderProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + double classLoad = ProfilerTestUtils.checkedGet(sr, "·class.load.norm").getScore(); + + // Allow 5% slack + if (Math.abs(1 - classLoad) > 0.05) { + Assert.fail("Class loading rate is incorrect. Reported by profiler: " + classLoad); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java new file mode 100644 index 000000000..3d19df700 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java @@ -0,0 +1,78 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.CompilerProfiler; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +public class CompilerProfilerTest { + + @Benchmark + public void work() { + Fixtures.work(); + } + + @Test + public void test() throws RunnerException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(CompilerProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + double timeTotal = ProfilerTestUtils.checkedGet(sr, "·compiler.time.total").getScore(); + double timeProfiled = ProfilerTestUtils.checkedGet(sr, "·compiler.time.profiled").getScore(); + + if (timeProfiled > timeTotal) { + throw new IllegalStateException("Profiled time is larger than total time. " + + "Total: " + timeTotal + ", Profiled: " + timeProfiled); + } + + if (timeProfiled <= 0) { + throw new IllegalStateException("Should have profiled time: " + timeProfiled); + } + + if (timeTotal <= 0) { + throw new IllegalStateException("Should have total time: " + timeTotal); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java new file mode 100644 index 000000000..6c21d981e --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java @@ -0,0 +1,65 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Test; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.DTraceAsmProfiler; +import org.openjdk.jmh.profile.ProfilerException; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; + +public class DTraceAsmProfilerTest extends AbstractAsmProfilerTest { + + @Test + public void test() throws RunnerException { + try { + new DTraceAsmProfiler(""); + } catch (ProfilerException e) { + System.out.println("Profiler is not supported or cannot be enabled, skipping test"); + return; + } + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(DTraceAsmProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + String out = ProfilerTestUtils.checkedGet(sr, "·asm").extendedInfo(); + if (!checkDisassembly(out)) { + throw new IllegalStateException("Profile does not contain the required frame: " + out); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java index 4395af8b6..4d543ee6b 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java @@ -84,8 +84,8 @@ private void testWith(String initLine) throws RunnerException { double opsPerSec = rr.getPrimaryResult().getScore(); Map sr = rr.getSecondaryResults(); - double allocRateMB = sr.get("·gc.alloc.rate").getScore(); - double allocRateNormB = sr.get("·gc.alloc.rate.norm").getScore(); + double allocRateMB = ProfilerTestUtils.checkedGet(sr, "·gc.alloc.rate").getScore(); + double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "·gc.alloc.rate.norm").getScore(); double allocRatePrimaryMB = opsPerSec * allocRateNormB / 1024 / 1024; // Allow 20% slack diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java index 6a42a377a..a10f9f4e9 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java @@ -67,7 +67,7 @@ public void testDefault() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - double allocRateNormB = sr.get("·gc.alloc.rate.norm").getScore(); + double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "·gc.alloc.rate.norm").getScore(); String msg = "Reported by profiler: " + allocRateNormB + ", target: " + SIZE; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/JavaFlightRecorderProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/JavaFlightRecorderProfilerTest.java new file mode 100644 index 000000000..d2641cb55 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/JavaFlightRecorderProfilerTest.java @@ -0,0 +1,62 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.CompilerProfiler; +import org.openjdk.jmh.profile.JavaFlightRecorderProfiler; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +public class JavaFlightRecorderProfilerTest { + + @Benchmark + public void work() { + Fixtures.work(); + } + + @Test + public void test() throws RunnerException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(JavaFlightRecorderProfiler.class) + .build(); + + new Runner(opts).runSingle(); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java new file mode 100644 index 000000000..0964fe687 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java @@ -0,0 +1,65 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Test; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.LinuxPerfAsmProfiler; +import org.openjdk.jmh.profile.ProfilerException; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; + +public class LinuxPerfAsmProfilerTest extends AbstractAsmProfilerTest { + + @Test + public void test() throws RunnerException { + try { + new LinuxPerfAsmProfiler(""); + } catch (ProfilerException e) { + System.out.println("Profiler is not supported or cannot be enabled, skipping test"); + return; + } + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(LinuxPerfAsmProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + String out = ProfilerTestUtils.checkedGet(sr, "·asm").extendedInfo(); + if (!checkDisassembly(out)) { + throw new IllegalStateException("Profile does not contain the required frame: " + out); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java new file mode 100644 index 000000000..1dbef346a --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java @@ -0,0 +1,80 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.LinuxPerfC2CProfiler; +import org.openjdk.jmh.profile.ProfilerException; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +public class LinuxPerfC2CProfilerTest { + + @Benchmark + public void work() { + somethingInTheMiddle(); + } + + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void somethingInTheMiddle() { + Fixtures.work(); + } + + @Test + public void test() throws RunnerException { + try { + new LinuxPerfC2CProfiler(); + } catch (ProfilerException e) { + System.out.println("Profiler is not supported or cannot be enabled, skipping test"); + return; + } + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(LinuxPerfC2CProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + String text = ProfilerTestUtils.checkedGet(sr, "·perfc2c").extendedInfo(); + + Assert.assertNotNull(text); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java new file mode 100644 index 000000000..a1fc91552 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java @@ -0,0 +1,95 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.LinuxPerfNormProfiler; +import org.openjdk.jmh.profile.ProfilerException; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +public class LinuxPerfNormProfilerTest { + + @Benchmark + public void work() { + somethingInTheMiddle(); + } + + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void somethingInTheMiddle() { + Blackhole.consumeCPU(1); + } + + @Test + public void test() throws RunnerException { + try { + new LinuxPerfNormProfiler(""); + } catch (ProfilerException e) { + System.out.println("Profiler is not supported or cannot be enabled, skipping test"); + return; + } + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(LinuxPerfNormProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + double instructions = ProfilerTestUtils.checkedGet(sr, "instructions", "instructions:u").getScore(); + double cycles = ProfilerTestUtils.checkedGet(sr, "cycles", "cycles:u").getScore(); + double branches = ProfilerTestUtils.checkedGet(sr, "branches", "branches:u").getScore(); + + Assert.assertNotEquals(0, instructions); + Assert.assertNotEquals(0, cycles); + Assert.assertNotEquals(0, branches); + + if (branches > instructions) { + throw new IllegalStateException(String.format("Branches (%.2f) larger than instructions (%.3f)", branches, instructions)); + } + + double ipc = ProfilerTestUtils.checkedGet(sr, "IPC").getScore(); + double cpi = ProfilerTestUtils.checkedGet(sr, "CPI").getScore(); + + Assert.assertNotEquals(0, ipc); + Assert.assertNotEquals(0, cpi); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java new file mode 100644 index 000000000..e713bc52e --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java @@ -0,0 +1,91 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.LinuxPerfAsmProfiler; +import org.openjdk.jmh.profile.LinuxPerfProfiler; +import org.openjdk.jmh.profile.ProfilerException; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +public class LinuxPerfProfilerTest { + + @Benchmark + public void work() { + somethingInTheMiddle(); + } + + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void somethingInTheMiddle() { + Blackhole.consumeCPU(1); + } + + @Test + public void test() throws RunnerException { + try { + new LinuxPerfProfiler(""); + } catch (ProfilerException e) { + System.out.println("Profiler is not supported or cannot be enabled, skipping test"); + return; + } + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(LinuxPerfProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + String msg = ProfilerTestUtils.checkedGet(sr, "·perf").extendedInfo(); + + if (sr.containsKey("·ipc")) { + double ipc = ProfilerTestUtils.checkedGet(sr, "·ipc").getScore(); + double cpi = ProfilerTestUtils.checkedGet(sr, "·cpi").getScore(); + Assert.assertNotEquals(0, ipc); + Assert.assertNotEquals(0, cpi); + } + + Assert.assertTrue(msg.contains("cycles")); + Assert.assertTrue(msg.contains("instructions")); + Assert.assertTrue(msg.contains("branches")); + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java new file mode 100644 index 000000000..3e6bc9877 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java @@ -0,0 +1,90 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.CompilerProfiler; +import org.openjdk.jmh.profile.MemPoolProfiler; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +public class MemPoolProfilerTest { + + @Benchmark + public void work() { + Fixtures.work(); + } + + @Test + public void test() throws RunnerException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(MemPoolProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + + double usedMetaspace = ProfilerTestUtils.checkedGet(sr, "·mempool.Metaspace.used").getScore(); + double usedTotal = ProfilerTestUtils.checkedGet(sr, "·mempool.total.used").getScore(); + double usedTotalCodeheap = ProfilerTestUtils.checkedGet(sr, "·mempool.total.codeheap.used").getScore(); + + if (usedMetaspace == 0) { + throw new IllegalStateException("Metaspace used is zero"); + } + + if (usedTotal == 0) { + throw new IllegalStateException("Total used is zero"); + } + + if (usedTotalCodeheap == 0) { + throw new IllegalStateException("Total codeheap used is zero"); + } + + if (usedMetaspace > usedTotal) { + throw new IllegalStateException("Metaspace size is larger than total size. " + + "Total: " + usedTotal + ", Metaspace: " + usedMetaspace); + } + + if (usedTotalCodeheap > usedTotal) { + throw new IllegalStateException("Codeheap size is larger than total size. " + + "Total: " + usedTotal + ", Codeheap: " + usedTotalCodeheap); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ProfilerTestUtils.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ProfilerTestUtils.java new file mode 100644 index 000000000..bf37cfab6 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ProfilerTestUtils.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.openjdk.jmh.results.Result; + +import java.util.Arrays; +import java.util.Map; + +public class ProfilerTestUtils { + + public static Result checkedGet(Map sr, String... names) { + for (String name : names) { + Result r = sr.get(name); + if (r != null) { + return r; + } + } + + StringBuilder sb = new StringBuilder(); + for (String k : sr.keySet()) { + sb.append(k); + sb.append(" = "); + sb.append(sr.get(k)); + sb.append(System.lineSeparator()); + } + throw new IllegalStateException("Cannot find the result for " + Arrays.toString(names) + "\". Available entries: " + sb); + } + + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java new file mode 100644 index 000000000..9b0868725 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java @@ -0,0 +1,115 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Assert; +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.MemPoolProfiler; +import org.openjdk.jmh.profile.SafepointsProfiler; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(value = 1, jvmArgsAppend = {"-Xms1g", "-Xmx1g"}) +public class SafepointsProfilerTest { + + @Benchmark + public int[] allocate() { + return new int[1_000_000]; + } + + @Test + public void test() throws RunnerException { + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(SafepointsProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + + double interval = ProfilerTestUtils.checkedGet(sr, "·safepoints.interval").getScore(); + double pauseTotal = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause").getScore(); + double ttspTotal = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp").getScore(); + + double pauseCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.count").getScore(); + double ttspCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.count").getScore(); + + Assert.assertNotEquals(pauseTotal, 0); + Assert.assertNotEquals(ttspTotal, 0); + + Assert.assertNotEquals(pauseCount, 0); + Assert.assertNotEquals(ttspCount, 0); + Assert.assertEquals(ttspCount, pauseCount, 0); + + if (interval < 3000) { + throw new IllegalStateException("Interval time is too low. " + + " Interval: " + interval); + } + + if (ttspTotal > interval) { + throw new IllegalStateException("TTSP time is larger than interval time. " + + "TTSP: " + ttspTotal + ", Interval: " + interval); + } + + if (pauseTotal > interval) { + throw new IllegalStateException("Pause time is larger than interval time. " + + "Pause: " + pauseTotal + ", Interval: " + interval); + } + + if (ttspTotal > pauseTotal) { + throw new IllegalStateException("TTSP time is larger than pause time. " + + "TTSP: " + ttspTotal + ", Pause: " + pauseTotal); + } + + double lastPause = 0; + double lastTTSP = 0; + for (String suff : new String[] {"0.00", "0.50", "0.90", "0.95", "0.99", "0.999", "0.9999", "1.00"}) { + double curPause = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.p" + suff).getScore(); + double curTTSP = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.p" + suff).getScore(); + if (curPause < lastPause) { + throw new IllegalStateException("pause.p" + suff + " is not monotonic"); + } + if (curTTSP < lastTTSP) { + throw new IllegalStateException("ttsp.p" + suff + " is not monotonic"); + } + lastPause = curPause; + lastTTSP = curTTSP; + } + + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java new file mode 100644 index 000000000..990e23689 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java @@ -0,0 +1,78 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Test; +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.JavaFlightRecorderProfiler; +import org.openjdk.jmh.profile.StackProfiler; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +public class StackProfilerTest { + + @Benchmark + public void work() { + somethingInTheMiddle(); + } + + @CompilerControl(CompilerControl.Mode.DONT_INLINE) + public void somethingInTheMiddle() { + Fixtures.work(); + } + + @Test + public void test() throws RunnerException { + if (Fixtures.isVirtualExecutor()) { + System.out.println("Stack profiler is not reliable with virtual threads"); + return; + } + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(StackProfiler.class, "lines=10") + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + String out = ProfilerTestUtils.checkedGet(sr, "·stack").extendedInfo(); + if (!out.contains(StackProfilerTest.class.getCanonicalName() + ".somethingInTheMiddle")) { + throw new IllegalStateException("Profile does not contain the required frame: " + out); + } + } + +} diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java new file mode 100644 index 000000000..b64449161 --- /dev/null +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java @@ -0,0 +1,65 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.it.profilers; + +import org.junit.Test; +import org.openjdk.jmh.it.Fixtures; +import org.openjdk.jmh.profile.ProfilerException; +import org.openjdk.jmh.profile.WinPerfAsmProfiler; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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 java.util.Map; + +public class WinPerfAsmProfilerTest extends AbstractAsmProfilerTest { + + @Test + public void test() throws RunnerException { + try { + new WinPerfAsmProfiler(""); + } catch (ProfilerException e) { + System.out.println("Profiler is not supported or cannot be enabled, skipping test"); + return; + } + + Options opts = new OptionsBuilder() + .include(Fixtures.getTestMask(this.getClass())) + .addProfiler(WinPerfAsmProfiler.class) + .build(); + + RunResult rr = new Runner(opts).runSingle(); + + Map sr = rr.getSecondaryResults(); + String out = ProfilerTestUtils.checkedGet(sr, "·asm").extendedInfo(); + if (!checkDisassembly(out)) { + throw new IllegalStateException("Profile does not contain the required frame: " + out); + } + } + +} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java index fbb0d4d7e..f4c8388fa 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/DTraceAsmProfiler.java @@ -94,7 +94,7 @@ public Collection afterTrial(BenchmarkResult br, long pid, Fil throw new IllegalStateException("Cannot determine dtrace process PID"); } - Collection messages = Utils.tryWith("sudo", "kill", "-TERM", Long.toString(dtracePid)); + Collection messages = Utils.tryWith("sudo", "-n", "kill", "-TERM", Long.toString(dtracePid)); if (!messages.isEmpty()) { throw new IllegalStateException(messages.toString()); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java index fa383c673..c948532f2 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java @@ -46,11 +46,20 @@ public class LinuxPerfAsmProfiler extends AbstractPerfAsmProfiler { public LinuxPerfAsmProfiler(String initLine) throws ProfilerException { super(initLine, "cycles"); - Collection failMsg = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "echo", "1"); + String[] senseCmd = { PerfSupport.PERF_EXEC, "stat", "--event", Utils.join(requestedEventNames, ","), "--log-fd", "2", "echo", "1" }; + + Collection failMsg = Utils.tryWith(senseCmd); if (!failMsg.isEmpty()) { throw new ProfilerException(failMsg.toString()); } + Collection passMsg = Utils.runWith(senseCmd); + for (String ev : requestedEventNames) { + if (PerfSupport.containsUnsupported(passMsg, ev)) { + throw new ProfilerException("Unsupported event: " + ev); + } + } + try { sampleFrequency = set.valueOf(optFrequency); } catch (OptionException e) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfC2CProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfC2CProfiler.java index 6d2fdaf35..46fdfbdc1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfC2CProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfC2CProfiler.java @@ -44,6 +44,11 @@ public final class LinuxPerfC2CProfiler implements ExternalProfiler { protected final TempFile perfBinData; public LinuxPerfC2CProfiler() throws ProfilerException { + Collection failMsg = Utils.tryWith(PerfSupport.PERF_EXEC, "c2c", "record", "echo", "1"); + if (!failMsg.isEmpty()) { + throw new ProfilerException(failMsg.toString()); + } + try { perfBinData = FileUtils.weakTempFile("perf-c2c-bin"); } catch (IOException e) { diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index abe55575e..bb0c37cbc 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -118,21 +118,32 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { Collection incremental = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--interval-print", String.valueOf(incrementInterval), "echo", "1"); isIncrementable = incremental.isEmpty(); + Collection candidateEvents = new ArrayList<>(); if (userEvents != null) { for (String ev : userEvents) { if (ev.trim().isEmpty()) continue; - supportedEvents.add(ev); + candidateEvents.add(ev); } } if (supportedEvents.isEmpty()) { - for (String ev : interestingEvents) { - Collection res = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--event", ev, "echo", "1"); - if (res.isEmpty()) { + candidateEvents.addAll(Arrays.asList(interestingEvents)); + } + + for (String ev : candidateEvents) { + String[] senseCmd = { PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--event", ev, "echo", "1" }; + Collection res = Utils.tryWith(senseCmd); + if (res.isEmpty()) { + Collection out = Utils.runWith(senseCmd); + if (!PerfSupport.containsUnsupported(out, ev)) { supportedEvents.add(ev); } } } + + if (!useDefaultStats && supportedEvents.isEmpty()) { + throw new ProfilerException("No supported events."); + } } @Override @@ -331,8 +342,14 @@ private Collection process(BenchmarkResult br, File stdOut, Fi // Also figure out IPC/CPI, if enough counters available: { - long cycles = events.count("cycles"); - long instructions = events.count("instructions"); + long c1 = events.count("cycles"); + long c2 = events.count("cycles:u"); + + long i1 = events.count("instructions"); + long i2 = events.count("instructions:u"); + + long cycles = (c1 != 0) ? c1 : c2; + long instructions = (i1 != 0) ? i1 : i2; if (cycles != 0 && instructions != 0) { results.add(new PerfResult("CPI", "clks/insn", 1.0 * cycles / instructions)); results.add(new PerfResult("IPC", "insns/clk", 1.0 * instructions / cycles)); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/MemPoolProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/MemPoolProfiler.java index 7bded8be8..07b7be50f 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/MemPoolProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/MemPoolProfiler.java @@ -57,7 +57,7 @@ public Collection afterIteration(BenchmarkParams benchmarkPara long sum = 0L; for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) { long used = bean.getPeakUsage().getUsed(); - if (bean.getName().contains("CodeHeap")) { + if (bean.getName().contains("CodeHeap") || bean.getName().contains("Code Cache")) { sumCodeHeap += used; } sum += used; diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/PerfSupport.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/PerfSupport.java index b286fde73..03fcad5a1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/PerfSupport.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/PerfSupport.java @@ -24,6 +24,8 @@ */ package org.openjdk.jmh.profile; +import java.util.Collection; + class PerfSupport { static final String PERF_EXEC; @@ -33,4 +35,13 @@ class PerfSupport { PERF_EXEC = (perf == null) ? "perf" : perf; } + public static boolean containsUnsupported(Collection msgs, String event) { + for (String m : msgs) { + if (m.contains(event) && m.contains("")) { + return true; + } + } + return false; + } + } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java index 07a87a6e5..232122d9c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java @@ -528,6 +528,10 @@ public static Process runAsync(String... cmd) { } } + public static Collection runWith(String... cmds) { + return runWith(Arrays.asList(cmds)); + } + public static Collection runWith(List cmd) { Collection messages = new ArrayList<>(); try { From 9a9755714746f76bfaaa067e777457ce6ef64bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Fri, 9 Jun 2023 13:43:10 +0200 Subject: [PATCH 334/342] 7903490: JMH: The interrupt to time-outing benchmark can be delivered to worker data barrier --- .../org/openjdk/jmh/runner/BenchmarkHandler.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index 53a4ab309..4fe29f844 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -433,18 +433,19 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa } - private WorkerData getWorkerData(Thread worker) { + private WorkerData getWorkerData(Thread worker) throws Exception { // See if there is a good worker data for us already, use it. WorkerData wd = workerData.remove(worker); // Wait for all threads to roll to this synchronization point. // If there is any thread without assignment, the barrier action // would dump the unused worker data for claiming. - try { - workerDataBarrier.await(); - } catch (InterruptedException | BrokenBarrierException e) { - throw new IllegalStateException("Worker data barrier error ", e); - } + // + // In face of interruptions, the barrier can either throw the interrupted + // exception if this thread caughts it and breaks the barrier, + // or broken barrier exception if other threads were waiting on this + // barrier. Bubble up both exceptions, and let the caller handle. + workerDataBarrier.await(); if (wd == null) { // Odd mode, no worker task recorded for the thread. Pull the worker data From 482561a2be24e47f1c3a855b3ce69f56130ec57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Fri, 9 Jun 2023 14:43:19 +0200 Subject: [PATCH 335/342] 7903492: JMH: Infrastructure code should yield occasionally for virtual executor to make progress --- .../openjdk/jmh/it/control/ControlStopTest.java | 4 ++-- .../jmh/generators/core/BenchmarkGenerator.java | 6 ++++++ .../org/openjdk/jmh/runner/BenchmarkHandler.java | 11 +++++++++++ .../java/org/openjdk/jmh/runner/InfraControl.java | 14 +++++++++++--- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStopTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStopTest.java index 1d5c74117..2f824bf98 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStopTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/control/ControlStopTest.java @@ -43,7 +43,7 @@ public class ControlStopTest { @Group("pingpong") public void ping(Control cnt) { while (!cnt.stopMeasurement) { - // this body is intentionally left blank + Thread.yield(); } } @@ -51,7 +51,7 @@ public void ping(Control cnt) { @Group("pingpong") public void pong(Control cnt) { while (!cnt.stopMeasurement) { - // this body is intentionally left blank + Thread.yield(); } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java index bcbbedb2a..8d4f694cd 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java @@ -568,6 +568,7 @@ private void generateThroughput(PrintWriter writer, Mode benchmarkKind, MethodGr writer.println(ident(4) + emitCall(method, states) + ';'); invocationEpilog(writer, 4, method, states, false); + writer.println(ident(4) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(4) + "res.allOps++;"); writer.println(ident(3) + "}"); writer.println(); @@ -593,6 +594,7 @@ private void generateThroughput(PrintWriter writer, Mode benchmarkKind, MethodGr writer.println(ident(5) + emitCall(method, states) + ';'); invocationEpilog(writer, 5, method, states, false); + writer.println(ident(5) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(5) + "res.allOps++;"); writer.println(ident(4) + "}"); writer.println(ident(3) + "} catch (Throwable e) {"); @@ -702,6 +704,7 @@ private void generateAverageTime(PrintWriter writer, Mode benchmarkKind, MethodG writer.println(ident(4) + emitCall(method, states) + ';'); invocationEpilog(writer, 4, method, states, false); + writer.println(ident(4) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(4) + "res.allOps++;"); writer.println(ident(3) + "}"); writer.println(); @@ -726,6 +729,7 @@ private void generateAverageTime(PrintWriter writer, Mode benchmarkKind, MethodG writer.println(ident(5) + emitCall(method, states) + ';'); invocationEpilog(writer, 5, method, states, false); + writer.println(ident(5) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(5) + "res.allOps++;"); writer.println(ident(4) + "}"); writer.println(ident(3) + "} catch (Throwable e) {"); @@ -860,6 +864,7 @@ private void generateSampleTime(PrintWriter writer, Mode benchmarkKind, MethodGr writer.println(ident(4) + emitCall(method, states) + ';'); invocationEpilog(writer, 4, method, states, false); + writer.println(ident(4) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(4) + "res.allOps++;"); writer.println(ident(3) + "}"); writer.println(); @@ -889,6 +894,7 @@ private void generateSampleTime(PrintWriter writer, Mode benchmarkKind, MethodGr writer.println(ident(5) + emitCall(method, states) + ';'); invocationEpilog(writer, 5, method, states, false); + writer.println(ident(5) + "if (control.shouldYield) Thread.yield();"); writer.println(ident(5) + "res.allOps++;"); writer.println(ident(4) + "}"); writer.println(ident(3) + "} catch (Throwable e) {"); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index 4fe29f844..e5a147d20 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -204,6 +204,11 @@ boolean stableThreads() { ExecutorService createExecutor(int maxThreads, String prefix) { return Executors.newFixedThreadPool(maxThreads, WorkerThreadFactories.virtualWorkerFactory(prefix)); } + + @Override + boolean shouldYield() { + return true; + } }, /** @@ -236,6 +241,11 @@ ExecutorService createExecutor(int maxThreads, String prefix) throws Exception { * @return Executor always reuses the same threads? */ boolean stableThreads() { return false; } + + /** + * @return Executing threads should yield occasionally to guarantee progress? + */ + boolean shouldYield() { return false; } } protected void startProfilers(BenchmarkParams benchmarkParams, IterationParams iterationParams) { @@ -309,6 +319,7 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa InfraControl control = new InfraControl(benchmarkParams, params, preSetupBarrier, preTearDownBarrier, isFirstIteration, isLastIteration, + EXECUTOR_TYPE.shouldYield(), new Control()); // preparing the worker runnables diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java index 7baf11895..49e64d8e8 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/InfraControl.java @@ -49,6 +49,7 @@ public class InfraControl extends InfraControlL4 { Utils.check(InfraControl.class, "preSetup", "preTearDown"); Utils.check(InfraControl.class, "firstIteration"); Utils.check(InfraControl.class, "lastIteration"); + Utils.check(InfraControl.class, "shouldYield"); Utils.check(InfraControl.class, "warmupVisited", "warmdownVisited"); Utils.check(InfraControl.class, "warmupShouldWait", "warmdownShouldWait"); Utils.check(InfraControl.class, "warmupDone", "warmdownDone"); @@ -59,8 +60,9 @@ public class InfraControl extends InfraControlL4 { public InfraControl(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean firstIteration, boolean lastIteration, + boolean shouldYield, Control notifyControl) { - super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, notifyControl); + super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, shouldYield, notifyControl); } /** @@ -165,6 +167,7 @@ abstract class InfraControlL2 extends InfraControlL1 { public final CountDownLatch preTearDown; public final boolean firstIteration; public final boolean lastIteration; + public final boolean shouldYield; public final AtomicInteger warmupVisited, warmdownVisited; public volatile boolean warmupShouldWait, warmdownShouldWait; @@ -180,6 +183,7 @@ abstract class InfraControlL2 extends InfraControlL1 { public InfraControlL2(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean firstIteration, boolean lastIteration, + boolean shouldYield, Control notifyControl) { warmupVisited = new AtomicInteger(); warmdownVisited = new AtomicInteger(); @@ -199,6 +203,8 @@ public InfraControlL2(BenchmarkParams benchmarkParams, IterationParams iteration this.preTearDown = preTearDown; this.firstIteration = firstIteration; this.lastIteration = lastIteration; + this.shouldYield = shouldYield; + this.benchmarkParams = benchmarkParams; this.iterationParams = iterationParams; } @@ -281,8 +287,9 @@ abstract class InfraControlL3 extends InfraControlL2 { public InfraControlL3(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean firstIteration, boolean lastIteration, + boolean shouldYield, Control notifyControl) { - super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, notifyControl); + super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, shouldYield, notifyControl); } } @@ -292,8 +299,9 @@ abstract class InfraControlL4 extends InfraControlL3 { public InfraControlL4(BenchmarkParams benchmarkParams, IterationParams iterationParams, CountDownLatch preSetup, CountDownLatch preTearDown, boolean firstIteration, boolean lastIteration, + boolean shouldYield, Control notifyControl) { - super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, notifyControl); + super(benchmarkParams, iterationParams, preSetup, preTearDown, firstIteration, lastIteration, shouldYield, notifyControl); } } From 47f651b72d05c2c335f8ced5ed33f2fb0dd26720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 20 Jun 2023 10:23:12 +0200 Subject: [PATCH 336/342] 7903498: JMH: Reset worker interrupt status after iteration --- .../org/openjdk/jmh/runner/BenchmarkHandler.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java index e5a147d20..a418d1903 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkHandler.java @@ -451,11 +451,6 @@ private WorkerData getWorkerData(Thread worker) throws Exception { // Wait for all threads to roll to this synchronization point. // If there is any thread without assignment, the barrier action // would dump the unused worker data for claiming. - // - // In face of interruptions, the barrier can either throw the interrupted - // exception if this thread caughts it and breaks the barrier, - // or broken barrier exception if other threads were waiting on this - // barrier. Bubble up both exceptions, and let the caller handle. workerDataBarrier.await(); if (wd == null) { @@ -520,6 +515,12 @@ public BenchmarkTaskResult call() throws Exception { // bind the executor thread runner = Thread.currentThread(); + // Clear the interruption status for the thread before going into the infra. + // Normally, the interrupts would be cleared at the end of benchmark, but + // there is a tiny window when harness could deliver another interrupt after + // we left. + boolean unused = Thread.interrupted(); + // poll the current data, or instantiate in this thread, if needed WorkerData wd = control.firstIteration ? newWorkerData(runner) : getWorkerData(runner); @@ -552,6 +553,11 @@ public BenchmarkTaskResult call() throws Exception { } finally { // unbind the executor thread runner = null; + + // Clear the interruption status for the thread after leaving the benchmark method. + // If any InterruptedExceptions happened, they should have been handled by now. + // This prepares the runner thread for another iteration. + boolean unused = Thread.interrupted(); } } From d88f901b2a50539e276aa409b5d7ce1eb3e1bfc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 6 Jul 2023 15:26:27 +0200 Subject: [PATCH 337/342] 7903504: JMH: Fix new Sonar warnings --- .../org/openjdk/jmh/validation/AffinitySupport.java | 4 +++- .../jmh/it/profilers/LinuxPerfNormProfilerTest.java | 10 +++++----- .../jmh/it/profilers/LinuxPerfProfilerTest.java | 4 ++-- .../jmh/it/profilers/SafepointsProfilerTest.java | 10 +++++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java index 775d844b0..4b77c46e1 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java @@ -87,7 +87,9 @@ public static List prepare() { // Need to rename the file to the proper name, otherwise JNA would not discover it File proper = new File(bootLibraryPath + '/' + System.mapLibraryName("jnidispatch")); - file.renameTo(proper); + if (!file.renameTo(proper)) { + throw new IllegalStateException("Failed to rename " + file + " to " + proper); + } return Arrays.asList( "-Djna.nounpack=true", // Should not unpack itself, but use predefined path diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java index a1fc91552..7780c028f 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java @@ -77,9 +77,9 @@ public void test() throws RunnerException { double cycles = ProfilerTestUtils.checkedGet(sr, "cycles", "cycles:u").getScore(); double branches = ProfilerTestUtils.checkedGet(sr, "branches", "branches:u").getScore(); - Assert.assertNotEquals(0, instructions); - Assert.assertNotEquals(0, cycles); - Assert.assertNotEquals(0, branches); + Assert.assertNotEquals(0D, instructions, 0D); + Assert.assertNotEquals(0D, cycles, 0D); + Assert.assertNotEquals(0D, branches, 0D); if (branches > instructions) { throw new IllegalStateException(String.format("Branches (%.2f) larger than instructions (%.3f)", branches, instructions)); @@ -88,8 +88,8 @@ public void test() throws RunnerException { double ipc = ProfilerTestUtils.checkedGet(sr, "IPC").getScore(); double cpi = ProfilerTestUtils.checkedGet(sr, "CPI").getScore(); - Assert.assertNotEquals(0, ipc); - Assert.assertNotEquals(0, cpi); + Assert.assertNotEquals(0D, ipc, 0D); + Assert.assertNotEquals(0D, cpi, 0D); } } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java index e713bc52e..41ad2c4be 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java @@ -79,8 +79,8 @@ public void test() throws RunnerException { if (sr.containsKey("·ipc")) { double ipc = ProfilerTestUtils.checkedGet(sr, "·ipc").getScore(); double cpi = ProfilerTestUtils.checkedGet(sr, "·cpi").getScore(); - Assert.assertNotEquals(0, ipc); - Assert.assertNotEquals(0, cpi); + Assert.assertNotEquals(0D, ipc, 0D); + Assert.assertNotEquals(0D, cpi, 0D); } Assert.assertTrue(msg.contains("cycles")); diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java index 9b0868725..e9e474e30 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java @@ -68,12 +68,12 @@ public void test() throws RunnerException { double pauseCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.count").getScore(); double ttspCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.count").getScore(); - Assert.assertNotEquals(pauseTotal, 0); - Assert.assertNotEquals(ttspTotal, 0); + Assert.assertNotEquals(0D, pauseTotal, 0D); + Assert.assertNotEquals(0D, ttspTotal, 0D); - Assert.assertNotEquals(pauseCount, 0); - Assert.assertNotEquals(ttspCount, 0); - Assert.assertEquals(ttspCount, pauseCount, 0); + Assert.assertNotEquals(0D, pauseCount, 0D); + Assert.assertNotEquals(0D, ttspCount, 0D); + Assert.assertEquals(ttspCount, pauseCount, 0D); if (interval < 3000) { throw new IllegalStateException("Interval time is too low. " + From 6b09724579b8ae58554e15a1bc5badb543da5bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Tue, 25 Jul 2023 19:00:17 +0200 Subject: [PATCH 338/342] 7903450: JMH: Improve -prof perfnorm accuracy with robust estimations --- .../jmh/profile/LinuxPerfNormProfiler.java | 251 ++++++++---------- 1 file changed, 118 insertions(+), 133 deletions(-) diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java index bb0c37cbc..cbea88dc6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfNormProfiler.java @@ -60,9 +60,8 @@ public class LinuxPerfNormProfiler implements ExternalProfiler { private final int delayMs; private final int lengthMs; private final boolean useDefaultStats; - private final long highPassFilter; private final int incrementInterval; - private final boolean isIncrementable; + private final boolean doFilter; private final Collection supportedEvents = new ArrayList<>(); @@ -87,9 +86,9 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { "Lower values may improve accuracy, while increasing the profiling overhead.") .withRequiredArg().ofType(Integer.class).describedAs("ms").defaultsTo(100); - OptionSpec optHighPassFilter = parser.accepts("highPassFilter", - "Ignore event increments larger that this.") - .withRequiredArg().ofType(Long.class).describedAs("#").defaultsTo(100_000_000_000L); + OptionSpec optFilter = parser.accepts("filter", + "Filter problematic samples from infrastructure and perf itself.") + .withRequiredArg().ofType(Boolean.class).describedAs("bool").defaultsTo(true); OptionSpec optDefaultStat = parser.accepts("useDefaultStat", "Use \"perf stat -d -d -d\" instead of explicit counter list.") @@ -103,7 +102,7 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { delayMs = set.valueOf(optDelay); lengthMs = set.valueOf(optLength); incrementInterval = set.valueOf(optIncrementInterval); - highPassFilter = set.valueOf(optHighPassFilter); + doFilter = set.valueOf(optFilter); useDefaultStats = set.valueOf(optDefaultStat); userEvents = set.valuesOf(optEvents); } catch (OptionException e) { @@ -116,7 +115,9 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { } Collection incremental = Utils.tryWith(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--interval-print", String.valueOf(incrementInterval), "echo", "1"); - isIncrementable = incremental.isEmpty(); + if (!incremental.isEmpty()) { + throw new ProfilerException("\\\"perf\\\" is too old, needs incremental mode (-I)."); + } Collection candidateEvents = new ArrayList<>(); if (userEvents != null) { @@ -126,7 +127,7 @@ public LinuxPerfNormProfiler(String initLine) throws ProfilerException { } } - if (supportedEvents.isEmpty()) { + if (candidateEvents.isEmpty()) { candidateEvents.addAll(Arrays.asList(interestingEvents)); } @@ -154,9 +155,7 @@ public Collection addJVMInvokeOptions(BenchmarkParams params) { } else { cmd.addAll(Arrays.asList(PerfSupport.PERF_EXEC, "stat", "--log-fd", "2", "--field-separator", ",", "--event", Utils.join(supportedEvents, ","))); } - if (isIncrementable) { - cmd.addAll(Arrays.asList("-I", String.valueOf(incrementInterval))); - } + cmd.addAll(Arrays.asList("-I", String.valueOf(incrementInterval))); return cmd; } @@ -190,8 +189,17 @@ public String getDescription() { return "Linux perf statistics, normalized by operation count"; } + private static class EventRecord { + final double time; + final double value; + public EventRecord(double time, double value) { + this.time = time; + this.value = value; + } + } + private Collection process(BenchmarkResult br, File stdOut, File stdErr) { - Multiset events = new HashMultiset<>(); + Multimap eventRecords = new HashMultimap<>(); try (FileReader fr = new FileReader(stdErr); BufferedReader reader = new BufferedReader(fr)) { @@ -211,161 +219,138 @@ private Collection process(BenchmarkResult br, File stdOut, Fi } double readFrom = skipMs / 1000D; - double softTo = (skipMs + lenMs) / 1000D; double readTo = (skipMs + lenMs + incrementInterval) / 1000D; NumberFormat nf = NumberFormat.getInstance(); String line; - nextline: while ((line = reader.readLine()) != null) { if (line.startsWith("#")) continue; - if (isIncrementable) { - String[] split = line.split(","); - - String time; - String count; - String event; - - if (split.length == 3) { - // perf 3.13: time,count,event - time = split[0].trim(); - count = split[1].trim(); - event = split[2].trim(); - } else if (split.length >= 4) { - // perf >3.13: time,count,,event, - time = split[0].trim(); - count = split[1].trim(); - event = split[3].trim(); - } else { - // Malformed line, ignore - continue nextline; - } + String[] split = line.split(","); + + String time; + String count; + String event; + + if (split.length == 3) { + // perf 3.13: time,count,event + time = split[0].trim(); + count = split[1].trim(); + event = split[2].trim(); + } else if (split.length >= 4) { + // perf >3.13: time,count,,event, + time = split[0].trim(); + count = split[1].trim(); + event = split[3].trim(); + } else { + // Malformed line, ignore + continue; + } - double multiplier = 1D; - try { - double timeSec = nf.parse(time).doubleValue(); - if (timeSec < readFrom) { - // warmup, ignore - continue nextline; - } - if (timeSec > readTo) { - // post-run, ignore - continue nextline; - } - - // Handle partial events: - double intervalSec = incrementInterval / 1000D; - if (timeSec - intervalSec < readFrom) { - // Event _starts_ before the measurement window - // .............[============|============ - // readFrom timeSec - // [<----------------->| // event - // incrementInterval - // - // Only count the tail after readFrom: - - multiplier = (timeSec - readFrom) / intervalSec; - } - if (timeSec > softTo) { - // Event is past the measurement window - // =============].............|............ - // softTo timeSec - // [<----------------->| // event - // incrementInterval - // - // Only count the head before softTo: - multiplier = 1 - (timeSec - softTo) / intervalSec; - } - - // Defensive, keep multiplier in bounds: - multiplier = Math.max(1D, Math.min(0D, multiplier)); - } catch (ParseException e) { - // don't care then, continue - continue nextline; - } + double timeSec = 0D; + try { + timeSec = nf.parse(time).doubleValue(); + } catch (ParseException e) { + continue; + } - try { - long lValue = nf.parse(count).longValue(); - if (lValue > highPassFilter) { - // anomalous value, pretend we did not see it - continue nextline; - } - events.add(event, (long) (lValue * multiplier)); - } catch (ParseException e) { - // do nothing, continue - continue nextline; + if (timeSec < readFrom || timeSec > readTo) { + // Outside measurement window, ignore + continue; + } - } - } else { - int idx = line.lastIndexOf(","); + long lValue = 0L; + try { + lValue = nf.parse(count).longValue(); + } catch (ParseException e) { + continue; + } - // Malformed line, ignore - if (idx == -1) continue nextline; + eventRecords.put(event, new EventRecord(timeSec, lValue)); + } - String count = line.substring(0, idx).trim(); - String event = line.substring(idx + 1).trim(); + Map finalThroughputs = new HashMap<>(); + for (String key : eventRecords.keys()) { + List countedEvents = new ArrayList<>(eventRecords.get(key)); + + // If needed and possible, filter out a few head and tail iterations. + // Head iteration potentially contains the infrastructure startup. + // That iteration would only be handled for getting time, not the counter itself. + // Trailing iterations come with both infrastructure rampdown, and the final + // profiler output on shutdown. Sometimes these manifest as two separate iterations. + final int filteredCount = countedEvents.size() - 2; + if (doFilter && filteredCount > 0) { + countedEvents = countedEvents.subList(0, filteredCount); + } + + double s = 0; + double minTime = Double.MAX_VALUE; + double maxTime = Double.MIN_VALUE; - try { - long lValue = nf.parse(count).longValue(); - events.add(event, lValue); - } catch (ParseException e) { - // do nothing, continue - continue nextline; + for (int i = 0; i < countedEvents.size(); i++) { + EventRecord v = countedEvents.get(i); + if (i != 0) { + // Do not count the first event in the series, since time interval + // does not actually include it. + s += v.value; } + minTime = Math.min(minTime, v.time); + maxTime = Math.max(maxTime, v.time); } + double thr = s / (maxTime - minTime); + finalThroughputs.put(key, thr); + } + BenchmarkResultMetaData md = br.getMetadata(); + if (md == null) { + return emptyResults(); } - if (!isIncrementable) { - System.out.println(); - System.out.println(); - System.out.println("WARNING: Your system uses old \"perf\", which cannot print data incrementally (-I).\n" + - "Therefore, perf performance data includes benchmark warmup."); + long timeMs = md.getStopTime() - md.getMeasurementTime(); + if (timeMs == 0) { + return emptyResults(); + + } + double opsThroughput = 1000D * md.getMeasurementOps() / timeMs; + if (opsThroughput == 0) { + return emptyResults(); } - long totalOpts; + Collection results = new ArrayList<>(); + for (String key : finalThroughputs.keySet()) { + results.add(new PerfResult(key, "#/op", finalThroughputs.get(key) / opsThroughput)); + } - BenchmarkResultMetaData md = br.getMetadata(); - if (md != null) { - if (isIncrementable) { - totalOpts = md.getMeasurementOps(); - } else { - totalOpts = md.getWarmupOps() + md.getMeasurementOps(); - } - Collection results = new ArrayList<>(); - for (String key : events.keys()) { - results.add(new PerfResult(key, "#/op", events.count(key) * 1.0 / totalOpts)); - } + // Also figure out IPC/CPI, if enough counters available: + { + Double c1 = finalThroughputs.get("cycles"); + Double c2 = finalThroughputs.get("cycles:u"); - // Also figure out IPC/CPI, if enough counters available: - { - long c1 = events.count("cycles"); - long c2 = events.count("cycles:u"); + Double i1 = finalThroughputs.get("instructions"); + Double i2 = finalThroughputs.get("instructions:u"); - long i1 = events.count("instructions"); - long i2 = events.count("instructions:u"); + Double cycles = (c1 != null) ? c1 : c2; + Double instructions = (i1 != null) ? i1 : i2; - long cycles = (c1 != 0) ? c1 : c2; - long instructions = (i1 != 0) ? i1 : i2; - if (cycles != 0 && instructions != 0) { - results.add(new PerfResult("CPI", "clks/insn", 1.0 * cycles / instructions)); - results.add(new PerfResult("IPC", "insns/clk", 1.0 * instructions / cycles)); - } + if (cycles != null && instructions != null && + cycles != 0 && instructions != 0) { + results.add(new PerfResult("CPI", "clks/insn", cycles / instructions)); + results.add(new PerfResult("IPC", "insns/clk", instructions / cycles)); } - - return results; - } else { - return Collections.singleton(new PerfResult("N/A", "", Double.NaN)); } + return results; } catch (IOException e) { throw new IllegalStateException(e); } } + private static Set emptyResults() { + return Collections.singleton(new PerfResult("N/A", "", Double.NaN)); + } + static class PerfResult extends ScalarResult { private static final long serialVersionUID = -1262685915873231436L; From 8bc325b2de5728077a62e9e32ea3ff15189636f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Wed, 26 Jul 2023 21:03:52 +0200 Subject: [PATCH 339/342] 7903511: JMH: Add score stability performance tests --- ...ityBench.java => BurstStabilityBench.java} | 2 +- .../jmh/benchmarks/LongStabilityBench.java | 43 +++++++++ .../java/org/openjdk/jmh/validation/Main.java | 25 ++++- ...ilityTest.java => BurstStabilityTest.java} | 8 +- .../validation/tests/LongStabilityTest.java | 93 +++++++++++++++++++ 5 files changed, 163 insertions(+), 8 deletions(-) rename jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/{ScoreStabilityBench.java => BurstStabilityBench.java} (98%) create mode 100644 jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LongStabilityBench.java rename jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/{ScoreStabilityTest.java => BurstStabilityTest.java} (94%) create mode 100644 jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/LongStabilityTest.java diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ScoreStabilityBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BurstStabilityBench.java similarity index 98% rename from jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ScoreStabilityBench.java rename to jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BurstStabilityBench.java index 8d0110358..ecc39bac3 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/ScoreStabilityBench.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/BurstStabilityBench.java @@ -35,7 +35,7 @@ @Measurement(iterations = 50) @Threads(1) @State(Scope.Thread) -public class ScoreStabilityBench { +public class BurstStabilityBench { @Param("10") private int delay; diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LongStabilityBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LongStabilityBench.java new file mode 100644 index 000000000..d0ccfd34e --- /dev/null +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/LongStabilityBench.java @@ -0,0 +1,43 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.benchmarks; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; + +import java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@Threads(1) +@State(Scope.Thread) +public class LongStabilityBench { + + @Benchmark + public void test() { + Blackhole.consumeCPU(1_000_000); + } + +} diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java index 2fa031765..c7babe03d 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java @@ -158,8 +158,26 @@ public static void main(String[] args) throws RunnerException, CommandLineOption case timing: new TimingMeasurementsTest().runWith(pw, opts); break; - case stability: - new ScoreStabilityTest().runWith(pw, opts); + case long_stability: + switch (mode) { + case flash: + new LongStabilityTest(3).runWith(pw, opts); + break; + case quick: + new LongStabilityTest(5).runWith(pw, opts); + break; + case normal: + new LongStabilityTest(18).runWith(pw, opts); + break; + case longer: + new LongStabilityTest(60).runWith(pw, opts); + break; + default: + throw new IllegalStateException(); + } + break; + case burst_stability: + new BurstStabilityTest().runWith(pw, opts); break; case compiler_hints: new CompilerHintsTest().runWith(pw, opts); @@ -242,7 +260,8 @@ public enum Test { timing, compiler_hints, thermal, - stability, + long_stability, + burst_stability, thread_scale, helpers, blackhole_cpu, diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ScoreStabilityTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BurstStabilityTest.java similarity index 94% rename from jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ScoreStabilityTest.java rename to jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BurstStabilityTest.java index 508d9b85d..bedc503aa 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/ScoreStabilityTest.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/BurstStabilityTest.java @@ -25,7 +25,7 @@ package org.openjdk.jmh.validation.tests; import org.openjdk.jmh.annotations.Mode; -import org.openjdk.jmh.benchmarks.ScoreStabilityBench; +import org.openjdk.jmh.benchmarks.BurstStabilityBench; import org.openjdk.jmh.results.Result; import org.openjdk.jmh.results.RunResult; import org.openjdk.jmh.runner.Runner; @@ -37,10 +37,10 @@ import java.io.PrintWriter; -public class ScoreStabilityTest extends ValidationTest { +public class BurstStabilityTest extends ValidationTest { @Override public void runWith(PrintWriter pw, Options parent) throws RunnerException { - pw.println("--------- SCORE STABILITY TEST"); + pw.println("--------- BURST STABILITY TEST"); pw.println(); org.openjdk.jmh.util.Utils.reflow(pw, @@ -74,7 +74,7 @@ public void runWith(PrintWriter pw, Options parent) throws RunnerException { Options opts = new OptionsBuilder() .parent(parent) .mode(m) - .include(ScoreStabilityBench.class.getCanonicalName()) + .include(BurstStabilityBench.class.getCanonicalName()) .verbosity(VerboseMode.SILENT) .param("delay", String.valueOf(delay)) .build(); diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/LongStabilityTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/LongStabilityTest.java new file mode 100644 index 000000000..1185fd256 --- /dev/null +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/LongStabilityTest.java @@ -0,0 +1,93 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.validation.tests; + +import org.openjdk.jmh.benchmarks.LongStabilityBench; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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.openjdk.jmh.runner.options.VerboseMode; +import org.openjdk.jmh.validation.ValidationTest; + +import java.io.PrintWriter; +import java.util.concurrent.ThreadLocalRandom; + +public class LongStabilityTest extends ValidationTest { + private final int tries; + + public LongStabilityTest(int tries) { + this.tries = tries; + } + + @Override + public void runWith(PrintWriter pw, Options parent) throws RunnerException { + pw.println("--------- LONG STABILITY TEST"); + pw.println(); + + org.openjdk.jmh.util.Utils.reflow(pw, + "This test verifies the performance for a single test by running it several times with some " + + "delays between the runs. The performance should be the same across all runs. " + + "If there is a significant difference between the runs, this is usually " + + "indicative of noisy environment, e.g. a busy virtualized node, or background processes " + + "interfering with the run, making the benchmarks unreliable.", + 80, 2); + pw.println(); + + for (int t = 0; t < tries; t++) { + int ms = (t == 0) ? 0 : ThreadLocalRandom.current().nextInt(5_000, 30_000); + + pw.printf(" Sleeping for %6d ms...", ms); + pw.flush(); + try { + Thread.sleep(ms); + } catch (InterruptedException e) { + // Do nothing. + } + + pw.print(" Run: "); + pw.flush(); + + Options opts = new OptionsBuilder() + .parent(parent) + .include(LongStabilityBench.class.getCanonicalName()) + .warmupIterations(5) + .warmupTime(TimeValue.seconds(1)) + .measurementIterations(5) + .measurementTime(TimeValue.seconds(1)) + .forks(1) + .verbosity(VerboseMode.SILENT) + .build(); + + RunResult result = new Runner(opts).runSingle(); + Result r = result.getPrimaryResult(); + pw.printf(" %16s", String.format("%.2f \u00b1 %.2f %s%n", r.getScore(), r.getScoreError(), r.getScoreUnit())); + pw.flush(); + } + } +} From 843f64123bc25b0402e78b863999dd7c69adb309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 27 Jul 2023 11:01:44 +0200 Subject: [PATCH 340/342] 7903510: JMH: Add core performance checking tests --- .../jmh/benchmarks/CoreStabilityBench.java | 55 ++++++++++++ .../java/org/openjdk/jmh/validation/Main.java | 4 + .../validation/tests/CoreStabilityTest.java | 83 +++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CoreStabilityBench.java create mode 100644 jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CoreStabilityTest.java diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CoreStabilityBench.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CoreStabilityBench.java new file mode 100644 index 000000000..4636fe84f --- /dev/null +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/benchmarks/CoreStabilityBench.java @@ -0,0 +1,55 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.benchmarks; + +import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.infra.Blackhole; +import org.openjdk.jmh.validation.AffinitySupport; +import org.openjdk.jmh.validation.SpinWaitSupport; + +import java.util.concurrent.TimeUnit; + +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@Threads(1) +@State(Scope.Thread) +public class CoreStabilityBench { + + @Param("-1") + int p; + + @Setup + public void setup() { + if (p == -1) { + throw new IllegalStateException("Should provide a CPU number"); + } + AffinitySupport.bind(p); + } + + @Benchmark + public void test() { + Blackhole.consumeCPU(1_000_000); + } +} diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java index c7babe03d..6c80c2f07 100644 --- a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/Main.java @@ -179,6 +179,9 @@ public static void main(String[] args) throws RunnerException, CommandLineOption case burst_stability: new BurstStabilityTest().runWith(pw, opts); break; + case core_stability: + new CoreStabilityTest().runWith(pw, opts); + break; case compiler_hints: new CompilerHintsTest().runWith(pw, opts); break; @@ -262,6 +265,7 @@ public enum Test { thermal, long_stability, burst_stability, + core_stability, thread_scale, helpers, blackhole_cpu, diff --git a/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CoreStabilityTest.java b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CoreStabilityTest.java new file mode 100644 index 000000000..6c0f531ac --- /dev/null +++ b/jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/tests/CoreStabilityTest.java @@ -0,0 +1,83 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.jmh.validation.tests; + +import org.openjdk.jmh.benchmarks.CoreStabilityBench; +import org.openjdk.jmh.results.Result; +import org.openjdk.jmh.results.RunResult; +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.VerboseMode; +import org.openjdk.jmh.util.Utils; +import org.openjdk.jmh.validation.AffinitySupport; +import org.openjdk.jmh.validation.ValidationTest; + +import java.io.PrintWriter; +import java.util.concurrent.ThreadLocalRandom; + +public class CoreStabilityTest extends ValidationTest { + + @Override + public void runWith(PrintWriter pw, Options parent) throws RunnerException { + pw.println("--------- CORE STABILITY TEST"); + pw.println(); + + org.openjdk.jmh.util.Utils.reflow(pw, + "This test verifies the performance for a single test by running it on different CPUs. " + + "For perfectly symmetric machines, the performance should be the same across all CPUs. " + + "If there is a significant difference between the CPUs, this is usually " + + "indicative of asymmetric machine, making the benchmarks that do not explicitly control " + + "affinity less reliable.", + 80, 2); + pw.println(); + + if (!AffinitySupport.isSupported()) { + pw.println(" Affinity control is not available on this machine, skipping the test."); + pw.println(); + return; + } + + int threads = Utils.figureOutHotCPUs(); + + for (int p = 0; p < threads; p++) { + pw.printf(" CPU %3d: ", p); + pw.flush(); + + Options opts = new OptionsBuilder() + .parent(parent) + .include(CoreStabilityBench.class.getCanonicalName()) + .param("p", String.valueOf(p)) + .verbosity(VerboseMode.SILENT) + .build(); + + RunResult result = new Runner(opts).runSingle(); + Result r = result.getPrimaryResult(); + pw.printf(" %16s", String.format("%.2f \u00b1 %.2f %s%n", r.getScore(), r.getScoreError(), r.getScoreUnit())); + pw.flush(); + } + } +} From 09c78d5d0752ffc409e64ca4cabe9dc7b96704d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Shipil=C3=ABv?= Date: Thu, 27 Jul 2023 11:02:02 +0200 Subject: [PATCH 341/342] 7903508: JMH: Remove the Unicode dot prefix from secondary results --- .../it/profilers/ClassloadProfilerTest.java | 2 +- .../it/profilers/CompilerProfilerTest.java | 4 +- .../it/profilers/DTraceAsmProfilerTest.java | 2 +- .../it/profilers/GCProfilerAllocRateTest.java | 4 +- .../GCProfilerSeparateThreadTest.java | 2 +- .../profilers/LinuxPerfAsmProfilerTest.java | 2 +- .../profilers/LinuxPerfC2CProfilerTest.java | 2 +- .../it/profilers/LinuxPerfProfilerTest.java | 8 +- .../jmh/it/profilers/MemPoolProfilerTest.java | 6 +- .../it/profilers/SafepointsProfilerTest.java | 14 +- .../jmh/it/profilers/StackProfilerTest.java | 2 +- .../it/profilers/WinPerfAsmProfilerTest.java | 2 +- .../jmh/profile/ClassloaderProfiler.java | 8 +- .../openjdk/jmh/profile/CompilerProfiler.java | 4 +- .../org/openjdk/jmh/profile/GCProfiler.java | 14 +- .../jmh/profile/LinuxPerfProfiler.java | 6 +- .../openjdk/jmh/profile/MemPoolProfiler.java | 6 +- .../openjdk/jmh/profile/PausesProfiler.java | 22 +-- .../jmh/profile/SafepointsProfiler.java | 24 +-- .../openjdk/jmh/profile/StackProfiler.java | 2 +- .../org/openjdk/jmh/results/Defaults.java | 31 ---- .../openjdk/jmh/results/SampleTimeResult.java | 17 +- .../org/openjdk/jmh/results/TextResult.java | 2 +- .../jmh/samples/JMHSample_35_Profilers.java | 166 +++++++++--------- .../JMHSample_36_BranchPrediction.java | 28 +-- .../jmh/samples/JMHSample_37_CacheAccess.java | 32 ++-- 26 files changed, 191 insertions(+), 221 deletions(-) delete mode 100644 jmh-core/src/main/java/org/openjdk/jmh/results/Defaults.java diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java index a48acfeaf..abe790271 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java @@ -91,7 +91,7 @@ public void test() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - double classLoad = ProfilerTestUtils.checkedGet(sr, "·class.load.norm").getScore(); + double classLoad = ProfilerTestUtils.checkedGet(sr, "class.load.norm").getScore(); // Allow 5% slack if (Math.abs(1 - classLoad) > 0.05) { diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java index 3d19df700..b0231309c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java @@ -58,8 +58,8 @@ public void test() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - double timeTotal = ProfilerTestUtils.checkedGet(sr, "·compiler.time.total").getScore(); - double timeProfiled = ProfilerTestUtils.checkedGet(sr, "·compiler.time.profiled").getScore(); + double timeTotal = ProfilerTestUtils.checkedGet(sr, "compiler.time.total").getScore(); + double timeProfiled = ProfilerTestUtils.checkedGet(sr, "compiler.time.profiled").getScore(); if (timeProfiled > timeTotal) { throw new IllegalStateException("Profiled time is larger than total time. " + diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java index 6c21d981e..e9bb4d52c 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java @@ -56,7 +56,7 @@ public void test() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - String out = ProfilerTestUtils.checkedGet(sr, "·asm").extendedInfo(); + String out = ProfilerTestUtils.checkedGet(sr, "asm").extendedInfo(); if (!checkDisassembly(out)) { throw new IllegalStateException("Profile does not contain the required frame: " + out); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java index 4d543ee6b..fb26358e4 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java @@ -84,8 +84,8 @@ private void testWith(String initLine) throws RunnerException { double opsPerSec = rr.getPrimaryResult().getScore(); Map sr = rr.getSecondaryResults(); - double allocRateMB = ProfilerTestUtils.checkedGet(sr, "·gc.alloc.rate").getScore(); - double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "·gc.alloc.rate.norm").getScore(); + double allocRateMB = ProfilerTestUtils.checkedGet(sr, "gc.alloc.rate").getScore(); + double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "gc.alloc.rate.norm").getScore(); double allocRatePrimaryMB = opsPerSec * allocRateNormB / 1024 / 1024; // Allow 20% slack diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java index a10f9f4e9..4d8aa0c2e 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java @@ -67,7 +67,7 @@ public void testDefault() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "·gc.alloc.rate.norm").getScore(); + double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "gc.alloc.rate.norm").getScore(); String msg = "Reported by profiler: " + allocRateNormB + ", target: " + SIZE; diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java index 0964fe687..73817c54d 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java @@ -56,7 +56,7 @@ public void test() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - String out = ProfilerTestUtils.checkedGet(sr, "·asm").extendedInfo(); + String out = ProfilerTestUtils.checkedGet(sr, "asm").extendedInfo(); if (!checkDisassembly(out)) { throw new IllegalStateException("Profile does not contain the required frame: " + out); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java index 1dbef346a..b9f850303 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java @@ -72,7 +72,7 @@ public void test() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - String text = ProfilerTestUtils.checkedGet(sr, "·perfc2c").extendedInfo(); + String text = ProfilerTestUtils.checkedGet(sr, "perfc2c").extendedInfo(); Assert.assertNotNull(text); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java index 41ad2c4be..4c864def1 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java @@ -74,11 +74,11 @@ public void test() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - String msg = ProfilerTestUtils.checkedGet(sr, "·perf").extendedInfo(); + String msg = ProfilerTestUtils.checkedGet(sr, "perf").extendedInfo(); - if (sr.containsKey("·ipc")) { - double ipc = ProfilerTestUtils.checkedGet(sr, "·ipc").getScore(); - double cpi = ProfilerTestUtils.checkedGet(sr, "·cpi").getScore(); + if (sr.containsKey("ipc")) { + double ipc = ProfilerTestUtils.checkedGet(sr, "ipc").getScore(); + double cpi = ProfilerTestUtils.checkedGet(sr, "cpi").getScore(); Assert.assertNotEquals(0D, ipc, 0D); Assert.assertNotEquals(0D, cpi, 0D); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java index 3e6bc9877..8de0a9aef 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java @@ -60,9 +60,9 @@ public void test() throws RunnerException { Map sr = rr.getSecondaryResults(); - double usedMetaspace = ProfilerTestUtils.checkedGet(sr, "·mempool.Metaspace.used").getScore(); - double usedTotal = ProfilerTestUtils.checkedGet(sr, "·mempool.total.used").getScore(); - double usedTotalCodeheap = ProfilerTestUtils.checkedGet(sr, "·mempool.total.codeheap.used").getScore(); + double usedMetaspace = ProfilerTestUtils.checkedGet(sr, "mempool.Metaspace.used").getScore(); + double usedTotal = ProfilerTestUtils.checkedGet(sr, "mempool.total.used").getScore(); + double usedTotalCodeheap = ProfilerTestUtils.checkedGet(sr, "mempool.total.codeheap.used").getScore(); if (usedMetaspace == 0) { throw new IllegalStateException("Metaspace used is zero"); diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java index e9e474e30..0f3c37e56 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java @@ -61,12 +61,12 @@ public void test() throws RunnerException { Map sr = rr.getSecondaryResults(); - double interval = ProfilerTestUtils.checkedGet(sr, "·safepoints.interval").getScore(); - double pauseTotal = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause").getScore(); - double ttspTotal = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp").getScore(); + double interval = ProfilerTestUtils.checkedGet(sr, "safepoints.interval").getScore(); + double pauseTotal = ProfilerTestUtils.checkedGet(sr, "safepoints.pause").getScore(); + double ttspTotal = ProfilerTestUtils.checkedGet(sr, "safepoints.ttsp").getScore(); - double pauseCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.count").getScore(); - double ttspCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.count").getScore(); + double pauseCount = ProfilerTestUtils.checkedGet(sr, "safepoints.pause.count").getScore(); + double ttspCount = ProfilerTestUtils.checkedGet(sr, "safepoints.ttsp.count").getScore(); Assert.assertNotEquals(0D, pauseTotal, 0D); Assert.assertNotEquals(0D, ttspTotal, 0D); @@ -98,8 +98,8 @@ public void test() throws RunnerException { double lastPause = 0; double lastTTSP = 0; for (String suff : new String[] {"0.00", "0.50", "0.90", "0.95", "0.99", "0.999", "0.9999", "1.00"}) { - double curPause = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.p" + suff).getScore(); - double curTTSP = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.p" + suff).getScore(); + double curPause = ProfilerTestUtils.checkedGet(sr, "safepoints.pause.p" + suff).getScore(); + double curTTSP = ProfilerTestUtils.checkedGet(sr, "safepoints.ttsp.p" + suff).getScore(); if (curPause < lastPause) { throw new IllegalStateException("pause.p" + suff + " is not monotonic"); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java index 990e23689..d66e05a12 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java @@ -69,7 +69,7 @@ public void test() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - String out = ProfilerTestUtils.checkedGet(sr, "·stack").extendedInfo(); + String out = ProfilerTestUtils.checkedGet(sr, "stack").extendedInfo(); if (!out.contains(StackProfilerTest.class.getCanonicalName() + ".somethingInTheMiddle")) { throw new IllegalStateException("Profile does not contain the required frame: " + out); } diff --git a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java index b64449161..2e5e208ad 100644 --- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java +++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java @@ -56,7 +56,7 @@ public void test() throws RunnerException { RunResult rr = new Runner(opts).runSingle(); Map sr = rr.getSecondaryResults(); - String out = ProfilerTestUtils.checkedGet(sr, "·asm").extendedInfo(); + String out = ProfilerTestUtils.checkedGet(sr, "asm").extendedInfo(); if (!checkDisassembly(out)) { throw new IllegalStateException("Profile does not contain the required frame: " + out); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java index 14a6fe88d..ea89de6a6 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/ClassloaderProfiler.java @@ -79,8 +79,8 @@ public Collection afterIteration(BenchmarkParams benchmarkPara try { long loadedClassCount = cl.getTotalLoadedClassCount(); long loaded = loadedClassCount - loadedClasses; - results.add(new ScalarResult(Defaults.PREFIX + "class.load", loaded / time, "classes/sec", AggregationPolicy.AVG)); - results.add(new ScalarResult(Defaults.PREFIX + "class.load.norm", 1.0 * loaded / allOps, "classes/op", AggregationPolicy.AVG)); + results.add(new ScalarResult("class.load", loaded / time, "classes/sec", AggregationPolicy.AVG)); + results.add(new ScalarResult("class.load.norm", 1.0 * loaded / allOps, "classes/op", AggregationPolicy.AVG)); } catch (UnsupportedOperationException e) { // do nothing } @@ -88,8 +88,8 @@ public Collection afterIteration(BenchmarkParams benchmarkPara try { long unloadedClassCount = cl.getUnloadedClassCount(); long unloaded = unloadedClassCount - unloadedClasses; - results.add(new ScalarResult(Defaults.PREFIX + "class.unload", unloaded / time, "classes/sec", AggregationPolicy.AVG)); - results.add(new ScalarResult(Defaults.PREFIX + "class.unload.norm", 1.0 * unloaded / allOps, "classes/op", AggregationPolicy.AVG)); + results.add(new ScalarResult("class.unload", unloaded / time, "classes/sec", AggregationPolicy.AVG)); + results.add(new ScalarResult("class.unload.norm", 1.0 * unloaded / allOps, "classes/op", AggregationPolicy.AVG)); } catch (UnsupportedOperationException e) { // do nothing diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/CompilerProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/CompilerProfiler.java index 705255a18..d1b1b6f2c 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/CompilerProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/CompilerProfiler.java @@ -66,8 +66,8 @@ public Collection afterIteration(BenchmarkParams benchmarkPara try { long curTime = comp.getTotalCompilationTime(); return Arrays.asList( - new ScalarResult(Defaults.PREFIX + "compiler.time.profiled", curTime - startCompTime, "ms", AggregationPolicy.SUM), - new ScalarResult(Defaults.PREFIX + "compiler.time.total", curTime, "ms", AggregationPolicy.MAX) + new ScalarResult("compiler.time.profiled", curTime - startCompTime, "ms", AggregationPolicy.SUM), + new ScalarResult("compiler.time.total", curTime, "ms", AggregationPolicy.MAX) ); } catch (UnsupportedOperationException e) { return Collections.emptyList(); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java index ddbf29e06..4580bd8d3 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java @@ -136,14 +136,14 @@ public Collection afterIteration(BenchmarkParams benchmarkPara } results.add(new ScalarResult( - Defaults.PREFIX + "gc.count", + "gc.count", gcCount - beforeGCCount, "counts", AggregationPolicy.SUM)); if (gcCount != beforeGCCount || gcTime != beforeGCTime) { results.add(new ScalarResult( - Defaults.PREFIX + "gc.time", + "gc.time", gcTime - beforeGCTime, "ms", AggregationPolicy.SUM)); @@ -154,14 +154,14 @@ public Collection afterIteration(BenchmarkParams benchmarkPara HotspotAllocationSnapshot newSnapshot = VMSupport.getSnapshot(); long allocated = newSnapshot.difference(beforeAllocated); // When no allocations measured, we still need to report results to avoid user confusion - results.add(new ScalarResult(Defaults.PREFIX + "gc.alloc.rate", + results.add(new ScalarResult("gc.alloc.rate", (afterTime != beforeTime) ? 1.0 * allocated / 1024 / 1024 * TimeUnit.SECONDS.toNanos(1) / (afterTime - beforeTime) : Double.NaN, "MB/sec", AggregationPolicy.AVG)); if (allocated != 0) { long allOps = iResult.getMetadata().getAllOps(); - results.add(new ScalarResult(Defaults.PREFIX + "gc.alloc.rate.norm", + results.add(new ScalarResult("gc.alloc.rate.norm", (allOps != 0) ? 1.0 * allocated / allOps : Double.NaN, @@ -169,7 +169,7 @@ public Collection afterIteration(BenchmarkParams benchmarkPara } } else { // When allocation profiling fails, make sure it is distinguishable in report - results.add(new ScalarResult(Defaults.PREFIX + "gc.alloc.rate", + results.add(new ScalarResult("gc.alloc.rate", Double.NaN, "MB/sec", AggregationPolicy.AVG)); } @@ -187,13 +187,13 @@ public Collection afterIteration(BenchmarkParams benchmarkPara String spaceName = space.replaceAll(" ", "_"); results.add(new ScalarResult( - Defaults.PREFIX + "gc.churn." + spaceName + "", + "gc.churn." + spaceName + "", churnRate, "MB/sec", AggregationPolicy.AVG)); results.add(new ScalarResult( - Defaults.PREFIX + "gc.churn." + spaceName + ".norm", + "gc.churn." + spaceName + ".norm", churnNorm, "B/op", AggregationPolicy.AVG)); diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java index d957ed1a7..e578848c1 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfProfiler.java @@ -206,7 +206,7 @@ static class PerfResult extends Result { private final long instructions; public PerfResult(String output, long cycles, long instructions) { - super(ResultRole.SECONDARY, Defaults.PREFIX + "perf", of(Double.NaN), "---", AggregationPolicy.AVG); + super(ResultRole.SECONDARY, "perf", of(Double.NaN), "---", AggregationPolicy.AVG); this.output = output; this.cycles = cycles; this.instructions = instructions; @@ -226,8 +226,8 @@ protected Aggregator getIterationAggregator() { protected Collection getDerivativeResults() { List res = new ArrayList<>(); if (cycles != 0 && instructions != 0) { - res.add(new ScalarDerivativeResult(Defaults.PREFIX + "ipc", 1.0 * instructions / cycles, "insns/clk", AggregationPolicy.AVG)); - res.add(new ScalarDerivativeResult(Defaults.PREFIX + "cpi", 1.0 * cycles / instructions, "clks/insn", AggregationPolicy.AVG)); + res.add(new ScalarDerivativeResult("ipc", 1.0 * instructions / cycles, "insns/clk", AggregationPolicy.AVG)); + res.add(new ScalarDerivativeResult("cpi", 1.0 * cycles / instructions, "clks/insn", AggregationPolicy.AVG)); } return res; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/MemPoolProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/MemPoolProfiler.java index 07b7be50f..a052371ba 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/MemPoolProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/MemPoolProfiler.java @@ -62,11 +62,11 @@ public Collection afterIteration(BenchmarkParams benchmarkPara } sum += used; - results.add(new ScalarResult(Defaults.PREFIX + "mempool." + bean.getName() + ".used", used / BYTES_PER_KIB, "KiB", AggregationPolicy.MAX)); + results.add(new ScalarResult("mempool." + bean.getName() + ".used", used / BYTES_PER_KIB, "KiB", AggregationPolicy.MAX)); } - results.add(new ScalarResult(Defaults.PREFIX + "mempool.total.codeheap.used", sumCodeHeap / BYTES_PER_KIB, "KiB", AggregationPolicy.MAX)); - results.add(new ScalarResult(Defaults.PREFIX + "mempool.total.used", sum / BYTES_PER_KIB, "KiB", AggregationPolicy.MAX)); + results.add(new ScalarResult("mempool.total.codeheap.used", sumCodeHeap / BYTES_PER_KIB, "KiB", AggregationPolicy.MAX)); + results.add(new ScalarResult("mempool.total.used", sum / BYTES_PER_KIB, "KiB", AggregationPolicy.MAX)); return results; } } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java index 5dcb21ce9..48999daaf 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java @@ -159,7 +159,7 @@ static class PausesProfilerResult extends Result { private final SampleBuffer buffer; public PausesProfilerResult(SampleBuffer buffer) { - super(ResultRole.SECONDARY, Defaults.PREFIX + "pauses", buffer.getStatistics(1D / 1_000_000), "ms", AggregationPolicy.SUM); + super(ResultRole.SECONDARY, "pauses", buffer.getStatistics(1D / 1_000_000), "ms", AggregationPolicy.SUM); this.buffer = buffer; } @@ -176,16 +176,16 @@ protected Aggregator getIterationAggregator() { @Override protected Collection getDerivativeResults() { return Arrays.asList( - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.avg", statistics.getMean(), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.count", statistics.getN(), "#", AggregationPolicy.SUM), - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.00", statistics.getMin(), "ms", AggregationPolicy.MIN), - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.50", statistics.getPercentile(50), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.90", statistics.getPercentile(90), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.95", statistics.getPercentile(95), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.99", statistics.getPercentile(99), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.999", statistics.getPercentile(99.9), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p0.9999", statistics.getPercentile(99.99),"ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "pauses.p1.00", statistics.getMax(), "ms", AggregationPolicy.MAX) + new ScalarDerivativeResult("pauses.avg", statistics.getMean(), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("pauses.count", statistics.getN(), "#", AggregationPolicy.SUM), + new ScalarDerivativeResult("pauses.p0.00", statistics.getMin(), "ms", AggregationPolicy.MIN), + new ScalarDerivativeResult("pauses.p0.50", statistics.getPercentile(50), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("pauses.p0.90", statistics.getPercentile(90), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("pauses.p0.95", statistics.getPercentile(95), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("pauses.p0.99", statistics.getPercentile(99), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("pauses.p0.999", statistics.getPercentile(99.9), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("pauses.p0.9999", statistics.getPercentile(99.99),"ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("pauses.p1.00", statistics.getMax(), "ms", AggregationPolicy.MAX) ); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java index f08262a07..eeaa03a7b 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/SafepointsProfiler.java @@ -115,7 +115,7 @@ public Collection afterTrial(BenchmarkResult br, long pid, Fil Collection results = new ArrayList<>(); - results.add(new ScalarResult(Defaults.PREFIX + "safepoints.interval", + results.add(new ScalarResult("safepoints.interval", measuredTimeMs, "ms", AggregationPolicy.SUM)); results.add(new SafepointProfilerResult("pause", pauseBuff)); @@ -153,7 +153,7 @@ static class SafepointProfilerResult extends Result { private final SampleBuffer buffer; public SafepointProfilerResult(String suffix, SampleBuffer buffer) { - super(ResultRole.SECONDARY, Defaults.PREFIX + "safepoints." + suffix, buffer.getStatistics(1D / 1_000_000), "ms", AggregationPolicy.SUM); + super(ResultRole.SECONDARY, "safepoints." + suffix, buffer.getStatistics(1D / 1_000_000), "ms", AggregationPolicy.SUM); this.suffix = suffix; this.buffer = buffer; } @@ -171,16 +171,16 @@ protected Aggregator getIterationAggregator() { @Override protected Collection getDerivativeResults() { return Arrays.asList( - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".avg", statistics.getMean(), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".count", statistics.getN(), "#", AggregationPolicy.SUM), - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.00", statistics.getMin(), "ms", AggregationPolicy.MIN), - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.50", statistics.getPercentile(50), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.90", statistics.getPercentile(90), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.95", statistics.getPercentile(95), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.99", statistics.getPercentile(99), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.999", statistics.getPercentile(99.9), "ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p0.9999", statistics.getPercentile(99.99),"ms", AggregationPolicy.AVG), - new ScalarDerivativeResult(Defaults.PREFIX + "safepoints." + suffix + ".p1.00", statistics.getMax(), "ms", AggregationPolicy.MAX) + new ScalarDerivativeResult("safepoints." + suffix + ".avg", statistics.getMean(), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("safepoints." + suffix + ".count", statistics.getN(), "#", AggregationPolicy.SUM), + new ScalarDerivativeResult("safepoints." + suffix + ".p0.00", statistics.getMin(), "ms", AggregationPolicy.MIN), + new ScalarDerivativeResult("safepoints." + suffix + ".p0.50", statistics.getPercentile(50), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("safepoints." + suffix + ".p0.90", statistics.getPercentile(90), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("safepoints." + suffix + ".p0.95", statistics.getPercentile(95), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("safepoints." + suffix + ".p0.99", statistics.getPercentile(99), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("safepoints." + suffix + ".p0.999", statistics.getPercentile(99.9), "ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("safepoints." + suffix + ".p0.9999", statistics.getPercentile(99.99),"ms", AggregationPolicy.AVG), + new ScalarDerivativeResult("safepoints." + suffix + ".p1.00", statistics.getMax(), "ms", AggregationPolicy.MAX) ); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java index 7bd26ab8b..a2053ced0 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/StackProfiler.java @@ -252,7 +252,7 @@ public static class StackResult extends Result { private final int topStacks; public StackResult(Map> stacks, int topStacks) { - super(ResultRole.SECONDARY, Defaults.PREFIX + "stack", of(Double.NaN), "---", AggregationPolicy.AVG); + super(ResultRole.SECONDARY, "stack", of(Double.NaN), "---", AggregationPolicy.AVG); this.stacks = stacks; this.topStacks = topStacks; } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/Defaults.java b/jmh-core/src/main/java/org/openjdk/jmh/results/Defaults.java deleted file mode 100644 index fabd43df9..000000000 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/Defaults.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.jmh.results; - -public class Defaults { - - public static final String PREFIX = "\u00b7"; - -} diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java index 40e7f4fc0..a80a90352 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/SampleTimeResult.java @@ -64,15 +64,16 @@ private static Statistics of(SampleBuffer buffer, TimeUnit outputTimeUnit) { @Override protected Collection getDerivativeResults() { + String s = role.isPrimary() ? "" : (label + ":"); return Arrays.asList( - new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.00", statistics.getPercentile(0), getScoreUnit(), AggregationPolicy.AVG), - new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.50", statistics.getPercentile(50), getScoreUnit(), AggregationPolicy.AVG), - new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.90", statistics.getPercentile(90), getScoreUnit(), AggregationPolicy.AVG), - new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.95", statistics.getPercentile(95), getScoreUnit(), AggregationPolicy.AVG), - new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.99", statistics.getPercentile(99), getScoreUnit(), AggregationPolicy.AVG), - new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.999", statistics.getPercentile(99.9), getScoreUnit(), AggregationPolicy.AVG), - new ScalarDerivativeResult(label + Defaults.PREFIX + "p0.9999", statistics.getPercentile(99.99), getScoreUnit(), AggregationPolicy.AVG), - new ScalarDerivativeResult(label + Defaults.PREFIX + "p1.00", statistics.getPercentile(100), getScoreUnit(), AggregationPolicy.AVG) + new ScalarDerivativeResult(s + "p0.00", statistics.getPercentile(0), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(s + "p0.50", statistics.getPercentile(50), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(s + "p0.90", statistics.getPercentile(90), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(s + "p0.95", statistics.getPercentile(95), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(s + "p0.99", statistics.getPercentile(99), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(s + "p0.999", statistics.getPercentile(99.9), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(s + "p0.9999", statistics.getPercentile(99.99), getScoreUnit(), AggregationPolicy.AVG), + new ScalarDerivativeResult(s + "p1.00", statistics.getPercentile(100), getScoreUnit(), AggregationPolicy.AVG) ); } diff --git a/jmh-core/src/main/java/org/openjdk/jmh/results/TextResult.java b/jmh-core/src/main/java/org/openjdk/jmh/results/TextResult.java index 7cd888c80..cf3c14188 100644 --- a/jmh-core/src/main/java/org/openjdk/jmh/results/TextResult.java +++ b/jmh-core/src/main/java/org/openjdk/jmh/results/TextResult.java @@ -31,7 +31,7 @@ public class TextResult extends Result { final String label; public TextResult(String output, String label) { - super(ResultRole.SECONDARY, Defaults.PREFIX + label, of(Double.NaN), "---", AggregationPolicy.AVG); + super(ResultRole.SECONDARY, label, of(Double.NaN), "---", AggregationPolicy.AVG); this.output = output; this.label = label; } diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java index e74d6b4a4..5541070a8 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java @@ -169,27 +169,27 @@ public static void main(String[] args) throws RunnerException { Next up, GC profiler. Running with -prof gc will yield: - Benchmark (type) Mode Cnt Score Error Units - - JMHSample_35_Profilers.Maps.test hashmap avgt 5 1553.201 ± 6.199 ns/op - JMHSample_35_Profilers.Maps.test:·gc.alloc.rate hashmap avgt 5 1257.046 ± 5.675 MB/sec - JMHSample_35_Profilers.Maps.test:·gc.alloc.rate.norm hashmap avgt 5 2048.001 ± 0.001 B/op - JMHSample_35_Profilers.Maps.test:·gc.churn.PS_Eden_Space hashmap avgt 5 1259.148 ± 315.277 MB/sec - JMHSample_35_Profilers.Maps.test:·gc.churn.PS_Eden_Space.norm hashmap avgt 5 2051.519 ± 520.324 B/op - JMHSample_35_Profilers.Maps.test:·gc.churn.PS_Survivor_Space hashmap avgt 5 0.175 ± 0.386 MB/sec - JMHSample_35_Profilers.Maps.test:·gc.churn.PS_Survivor_Space.norm hashmap avgt 5 0.285 ± 0.629 B/op - JMHSample_35_Profilers.Maps.test:·gc.count hashmap avgt 5 29.000 counts - JMHSample_35_Profilers.Maps.test:·gc.time hashmap avgt 5 16.000 ms - - JMHSample_35_Profilers.Maps.test treemap avgt 5 5177.065 ± 361.278 ns/op - JMHSample_35_Profilers.Maps.test:·gc.alloc.rate treemap avgt 5 377.251 ± 26.188 MB/sec - JMHSample_35_Profilers.Maps.test:·gc.alloc.rate.norm treemap avgt 5 2048.003 ± 0.001 B/op - JMHSample_35_Profilers.Maps.test:·gc.churn.PS_Eden_Space treemap avgt 5 392.743 ± 174.156 MB/sec - JMHSample_35_Profilers.Maps.test:·gc.churn.PS_Eden_Space.norm treemap avgt 5 2131.767 ± 913.941 B/op - JMHSample_35_Profilers.Maps.test:·gc.churn.PS_Survivor_Space treemap avgt 5 0.131 ± 0.215 MB/sec - JMHSample_35_Profilers.Maps.test:·gc.churn.PS_Survivor_Space.norm treemap avgt 5 0.709 ± 1.125 B/op - JMHSample_35_Profilers.Maps.test:·gc.count treemap avgt 5 25.000 counts - JMHSample_35_Profilers.Maps.test:·gc.time treemap avgt 5 26.000 ms + Benchmark (type) Mode Cnt Score Error Units + + JMHSample_35_Profilers.Maps.test hashmap avgt 5 1553.201 ± 6.199 ns/op + JMHSample_35_Profilers.Maps.test:gc.alloc.rate hashmap avgt 5 1257.046 ± 5.675 MB/sec + JMHSample_35_Profilers.Maps.test:gc.alloc.rate.norm hashmap avgt 5 2048.001 ± 0.001 B/op + JMHSample_35_Profilers.Maps.test:gc.churn.PS_Eden_Space hashmap avgt 5 1259.148 ± 315.277 MB/sec + JMHSample_35_Profilers.Maps.test:gc.churn.PS_Eden_Space.norm hashmap avgt 5 2051.519 ± 520.324 B/op + JMHSample_35_Profilers.Maps.test:gc.churn.PS_Survivor_Space hashmap avgt 5 0.175 ± 0.386 MB/sec + JMHSample_35_Profilers.Maps.test:gc.churn.PS_Survivor_Space.norm hashmap avgt 5 0.285 ± 0.629 B/op + JMHSample_35_Profilers.Maps.test:gc.count hashmap avgt 5 29.000 counts + JMHSample_35_Profilers.Maps.test:gc.time hashmap avgt 5 16.000 ms + + JMHSample_35_Profilers.Maps.test treemap avgt 5 5177.065 ± 361.278 ns/op + JMHSample_35_Profilers.Maps.test:gc.alloc.rate treemap avgt 5 377.251 ± 26.188 MB/sec + JMHSample_35_Profilers.Maps.test:gc.alloc.rate.norm treemap avgt 5 2048.003 ± 0.001 B/op + JMHSample_35_Profilers.Maps.test:gc.churn.PS_Eden_Space treemap avgt 5 392.743 ± 174.156 MB/sec + JMHSample_35_Profilers.Maps.test:gc.churn.PS_Eden_Space.norm treemap avgt 5 2131.767 ± 913.941 B/op + JMHSample_35_Profilers.Maps.test:gc.churn.PS_Survivor_Space treemap avgt 5 0.131 ± 0.215 MB/sec + JMHSample_35_Profilers.Maps.test:gc.churn.PS_Survivor_Space.norm treemap avgt 5 0.709 ± 1.125 B/op + JMHSample_35_Profilers.Maps.test:gc.count treemap avgt 5 25.000 counts + JMHSample_35_Profilers.Maps.test:gc.time treemap avgt 5 26.000 ms There, we can see that the tests are producing quite some garbage. "gc.alloc" would say we are allocating 1257 and 377 MB of objects per second, or 2048 bytes per benchmark operation. "gc.churn" would say that GC removes @@ -287,12 +287,12 @@ public static void main(String[] args) throws RunnerException { /* Running with -prof cl will yield: - Benchmark Mode Cnt Score Error Units - JMHSample_35_Profilers.Classy.load avgt 15 34215.363 ± 545.892 ns/op - JMHSample_35_Profilers.Classy.load:·class.load avgt 15 29374.097 ± 716.743 classes/sec - JMHSample_35_Profilers.Classy.load:·class.load.norm avgt 15 1.000 ± 0.001 classes/op - JMHSample_35_Profilers.Classy.load:·class.unload avgt 15 29598.233 ± 3420.181 classes/sec - JMHSample_35_Profilers.Classy.load:·class.unload.norm avgt 15 1.008 ± 0.119 classes/op + Benchmark Mode Cnt Score Error Units + JMHSample_35_Profilers.Classy.load avgt 15 34215.363 ± 545.892 ns/op + JMHSample_35_Profilers.Classy.load:class.load avgt 15 29374.097 ± 716.743 classes/sec + JMHSample_35_Profilers.Classy.load:class.load.norm avgt 15 1.000 ± 0.001 classes/op + JMHSample_35_Profilers.Classy.load:class.unload avgt 15 29598.233 ± 3420.181 classes/sec + JMHSample_35_Profilers.Classy.load:class.unload.norm avgt 15 1.008 ± 0.119 classes/op Here, we can see the benchmark indeed load class per benchmark op, and this adds up to more than 29K classloads per second. We can also see the runtime is able to successfully keep the number of loaded classes at bay, @@ -306,10 +306,10 @@ since the class unloading happens at the same rate. Another useful profiler that could tell if compiler is doing a heavy work in background, and thus interfering with measurement, -prof comp: - Benchmark Mode Cnt Score Error Units - JMHSample_35_Profilers.Classy.load avgt 5 33523.875 ± 3026.025 ns/op - JMHSample_35_Profilers.Classy.load:·compiler.time.profiled avgt 5 5.000 ms - JMHSample_35_Profilers.Classy.load:·compiler.time.total avgt 5 479.000 ms + Benchmark Mode Cnt Score Error Units + JMHSample_35_Profilers.Classy.load avgt 5 33523.875 ± 3026.025 ns/op + JMHSample_35_Profilers.Classy.load:compiler.time.profiled avgt 5 5.000 ms + JMHSample_35_Profilers.Classy.load:compiler.time.total avgt 5 479.000 ms We seem to be at proper steady state: out of 479 ms of total compiler work, only 5 ms happen during the measurement window. It is expected to have some level of background compilation even at steady state. @@ -419,32 +419,32 @@ public static void main(String[] args) throws RunnerException { This is exactly what -prof perfnorm does: - Benchmark Mode Cnt Score Error Units - JMHSample_35_Profilers.Atomic.test avgt 15 6.551 ± 0.023 ns/op - JMHSample_35_Profilers.Atomic.test:·CPI avgt 3 0.933 ± 0.026 #/op - JMHSample_35_Profilers.Atomic.test:·L1-dcache-load-misses avgt 3 0.001 ± 0.022 #/op - JMHSample_35_Profilers.Atomic.test:·L1-dcache-loads avgt 3 12.267 ± 1.324 #/op - JMHSample_35_Profilers.Atomic.test:·L1-dcache-store-misses avgt 3 0.001 ± 0.006 #/op - JMHSample_35_Profilers.Atomic.test:·L1-dcache-stores avgt 3 4.090 ± 0.402 #/op - JMHSample_35_Profilers.Atomic.test:·L1-icache-load-misses avgt 3 0.001 ± 0.011 #/op - JMHSample_35_Profilers.Atomic.test:·LLC-loads avgt 3 0.001 ± 0.004 #/op - JMHSample_35_Profilers.Atomic.test:·LLC-stores avgt 3 ≈ 10⁻⁴ #/op - JMHSample_35_Profilers.Atomic.test:·branch-misses avgt 3 ≈ 10⁻⁴ #/op - JMHSample_35_Profilers.Atomic.test:·branches avgt 3 6.152 ± 0.385 #/op - JMHSample_35_Profilers.Atomic.test:·bus-cycles avgt 3 0.670 ± 0.048 #/op - JMHSample_35_Profilers.Atomic.test:·context-switches avgt 3 ≈ 10⁻⁶ #/op - JMHSample_35_Profilers.Atomic.test:·cpu-migrations avgt 3 ≈ 10⁻⁷ #/op - JMHSample_35_Profilers.Atomic.test:·cycles avgt 3 26.790 ± 1.393 #/op - JMHSample_35_Profilers.Atomic.test:·dTLB-load-misses avgt 3 ≈ 10⁻⁴ #/op - JMHSample_35_Profilers.Atomic.test:·dTLB-loads avgt 3 12.278 ± 0.277 #/op - JMHSample_35_Profilers.Atomic.test:·dTLB-store-misses avgt 3 ≈ 10⁻⁵ #/op - JMHSample_35_Profilers.Atomic.test:·dTLB-stores avgt 3 4.113 ± 0.437 #/op - JMHSample_35_Profilers.Atomic.test:·iTLB-load-misses avgt 3 ≈ 10⁻⁵ #/op - JMHSample_35_Profilers.Atomic.test:·iTLB-loads avgt 3 0.001 ± 0.034 #/op - JMHSample_35_Profilers.Atomic.test:·instructions avgt 3 28.729 ± 1.297 #/op - JMHSample_35_Profilers.Atomic.test:·minor-faults avgt 3 ≈ 10⁻⁷ #/op - JMHSample_35_Profilers.Atomic.test:·page-faults avgt 3 ≈ 10⁻⁷ #/op - JMHSample_35_Profilers.Atomic.test:·ref-cycles avgt 3 26.734 ± 2.081 #/op + Benchmark Mode Cnt Score Error Units + JMHSample_35_Profilers.Atomic.test avgt 15 6.551 ± 0.023 ns/op + JMHSample_35_Profilers.Atomic.test:CPI avgt 3 0.933 ± 0.026 #/op + JMHSample_35_Profilers.Atomic.test:L1-dcache-load-misses avgt 3 0.001 ± 0.022 #/op + JMHSample_35_Profilers.Atomic.test:L1-dcache-loads avgt 3 12.267 ± 1.324 #/op + JMHSample_35_Profilers.Atomic.test:L1-dcache-store-misses avgt 3 0.001 ± 0.006 #/op + JMHSample_35_Profilers.Atomic.test:L1-dcache-stores avgt 3 4.090 ± 0.402 #/op + JMHSample_35_Profilers.Atomic.test:L1-icache-load-misses avgt 3 0.001 ± 0.011 #/op + JMHSample_35_Profilers.Atomic.test:LLC-loads avgt 3 0.001 ± 0.004 #/op + JMHSample_35_Profilers.Atomic.test:LLC-stores avgt 3 ≈ 10⁻⁴ #/op + JMHSample_35_Profilers.Atomic.test:branch-misses avgt 3 ≈ 10⁻⁴ #/op + JMHSample_35_Profilers.Atomic.test:branches avgt 3 6.152 ± 0.385 #/op + JMHSample_35_Profilers.Atomic.test:bus-cycles avgt 3 0.670 ± 0.048 #/op + JMHSample_35_Profilers.Atomic.test:context-switches avgt 3 ≈ 10⁻⁶ #/op + JMHSample_35_Profilers.Atomic.test:cpu-migrations avgt 3 ≈ 10⁻⁷ #/op + JMHSample_35_Profilers.Atomic.test:cycles avgt 3 26.790 ± 1.393 #/op + JMHSample_35_Profilers.Atomic.test:dTLB-load-misses avgt 3 ≈ 10⁻⁴ #/op + JMHSample_35_Profilers.Atomic.test:dTLB-loads avgt 3 12.278 ± 0.277 #/op + JMHSample_35_Profilers.Atomic.test:dTLB-store-misses avgt 3 ≈ 10⁻⁵ #/op + JMHSample_35_Profilers.Atomic.test:dTLB-stores avgt 3 4.113 ± 0.437 #/op + JMHSample_35_Profilers.Atomic.test:iTLB-load-misses avgt 3 ≈ 10⁻⁵ #/op + JMHSample_35_Profilers.Atomic.test:iTLB-loads avgt 3 0.001 ± 0.034 #/op + JMHSample_35_Profilers.Atomic.test:instructions avgt 3 28.729 ± 1.297 #/op + JMHSample_35_Profilers.Atomic.test:minor-faults avgt 3 ≈ 10⁻⁷ #/op + JMHSample_35_Profilers.Atomic.test:page-faults avgt 3 ≈ 10⁻⁷ #/op + JMHSample_35_Profilers.Atomic.test:ref-cycles avgt 3 26.734 ± 2.081 #/op It is customary to trim the lines irrelevant to the particular benchmark. We show all of them here for completeness. @@ -455,32 +455,32 @@ public static void main(String[] args) throws RunnerException { The output would get more interesting when we run with more threads, say, -t 8: - Benchmark Mode Cnt Score Error Units - JMHSample_35_Profilers.Atomic.test avgt 15 143.595 ± 1.968 ns/op - JMHSample_35_Profilers.Atomic.test:·CPI avgt 3 17.741 ± 28.761 #/op - JMHSample_35_Profilers.Atomic.test:·L1-dcache-load-misses avgt 3 0.175 ± 0.406 #/op - JMHSample_35_Profilers.Atomic.test:·L1-dcache-loads avgt 3 11.872 ± 0.786 #/op - JMHSample_35_Profilers.Atomic.test:·L1-dcache-store-misses avgt 3 0.184 ± 0.505 #/op - JMHSample_35_Profilers.Atomic.test:·L1-dcache-stores avgt 3 4.422 ± 0.561 #/op - JMHSample_35_Profilers.Atomic.test:·L1-icache-load-misses avgt 3 0.015 ± 0.083 #/op - JMHSample_35_Profilers.Atomic.test:·LLC-loads avgt 3 0.015 ± 0.128 #/op - JMHSample_35_Profilers.Atomic.test:·LLC-stores avgt 3 1.036 ± 0.045 #/op - JMHSample_35_Profilers.Atomic.test:·branch-misses avgt 3 0.224 ± 0.492 #/op - JMHSample_35_Profilers.Atomic.test:·branches avgt 3 6.524 ± 2.873 #/op - JMHSample_35_Profilers.Atomic.test:·bus-cycles avgt 3 13.475 ± 14.502 #/op - JMHSample_35_Profilers.Atomic.test:·context-switches avgt 3 ≈ 10⁻⁴ #/op - JMHSample_35_Profilers.Atomic.test:·cpu-migrations avgt 3 ≈ 10⁻⁶ #/op - JMHSample_35_Profilers.Atomic.test:·cycles avgt 3 537.874 ± 595.723 #/op - JMHSample_35_Profilers.Atomic.test:·dTLB-load-misses avgt 3 0.001 ± 0.006 #/op - JMHSample_35_Profilers.Atomic.test:·dTLB-loads avgt 3 12.032 ± 2.430 #/op - JMHSample_35_Profilers.Atomic.test:·dTLB-store-misses avgt 3 ≈ 10⁻⁴ #/op - JMHSample_35_Profilers.Atomic.test:·dTLB-stores avgt 3 4.557 ± 0.948 #/op - JMHSample_35_Profilers.Atomic.test:·iTLB-load-misses avgt 3 ≈ 10⁻³ #/op - JMHSample_35_Profilers.Atomic.test:·iTLB-loads avgt 3 0.016 ± 0.052 #/op - JMHSample_35_Profilers.Atomic.test:·instructions avgt 3 30.367 ± 15.052 #/op - JMHSample_35_Profilers.Atomic.test:·minor-faults avgt 3 ≈ 10⁻⁵ #/op - JMHSample_35_Profilers.Atomic.test:·page-faults avgt 3 ≈ 10⁻⁵ #/op - JMHSample_35_Profilers.Atomic.test:·ref-cycles avgt 3 538.697 ± 590.183 #/op + Benchmark Mode Cnt Score Error Units + JMHSample_35_Profilers.Atomic.test avgt 15 143.595 ± 1.968 ns/op + JMHSample_35_Profilers.Atomic.test:CPI avgt 3 17.741 ± 28.761 #/op + JMHSample_35_Profilers.Atomic.test:L1-dcache-load-misses avgt 3 0.175 ± 0.406 #/op + JMHSample_35_Profilers.Atomic.test:L1-dcache-loads avgt 3 11.872 ± 0.786 #/op + JMHSample_35_Profilers.Atomic.test:L1-dcache-store-misses avgt 3 0.184 ± 0.505 #/op + JMHSample_35_Profilers.Atomic.test:L1-dcache-stores avgt 3 4.422 ± 0.561 #/op + JMHSample_35_Profilers.Atomic.test:L1-icache-load-misses avgt 3 0.015 ± 0.083 #/op + JMHSample_35_Profilers.Atomic.test:LLC-loads avgt 3 0.015 ± 0.128 #/op + JMHSample_35_Profilers.Atomic.test:LLC-stores avgt 3 1.036 ± 0.045 #/op + JMHSample_35_Profilers.Atomic.test:branch-misses avgt 3 0.224 ± 0.492 #/op + JMHSample_35_Profilers.Atomic.test:branches avgt 3 6.524 ± 2.873 #/op + JMHSample_35_Profilers.Atomic.test:bus-cycles avgt 3 13.475 ± 14.502 #/op + JMHSample_35_Profilers.Atomic.test:context-switches avgt 3 ≈ 10⁻⁴ #/op + JMHSample_35_Profilers.Atomic.test:cpu-migrations avgt 3 ≈ 10⁻⁶ #/op + JMHSample_35_Profilers.Atomic.test:cycles avgt 3 537.874 ± 595.723 #/op + JMHSample_35_Profilers.Atomic.test:dTLB-load-misses avgt 3 0.001 ± 0.006 #/op + JMHSample_35_Profilers.Atomic.test:dTLB-loads avgt 3 12.032 ± 2.430 #/op + JMHSample_35_Profilers.Atomic.test:dTLB-store-misses avgt 3 ≈ 10⁻⁴ #/op + JMHSample_35_Profilers.Atomic.test:dTLB-stores avgt 3 4.557 ± 0.948 #/op + JMHSample_35_Profilers.Atomic.test:iTLB-load-misses avgt 3 ≈ 10⁻³ #/op + JMHSample_35_Profilers.Atomic.test:iTLB-loads avgt 3 0.016 ± 0.052 #/op + JMHSample_35_Profilers.Atomic.test:instructions avgt 3 30.367 ± 15.052 #/op + JMHSample_35_Profilers.Atomic.test:minor-faults avgt 3 ≈ 10⁻⁵ #/op + JMHSample_35_Profilers.Atomic.test:page-faults avgt 3 ≈ 10⁻⁵ #/op + JMHSample_35_Profilers.Atomic.test:ref-cycles avgt 3 538.697 ± 590.183 #/op Note how this time the CPI is awfully high: 17 cycles per instruction! Indeed, we are making almost the same ~30 instructions, but now they take >530 cycles. Other counters highlight why: we now have cache diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_36_BranchPrediction.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_36_BranchPrediction.java index 8c076a12f..e1396d332 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_36_BranchPrediction.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_36_BranchPrediction.java @@ -108,20 +108,20 @@ public void unsorted(Blackhole bh1, Blackhole bh2) { case. -prof perfnorm conveniently highlights that, with larger "branch-misses", and larger "CPI" for "unsorted" case: - Benchmark Mode Cnt Score Error Units - JMHSample_36_BranchPrediction.sorted avgt 25 2.160 ± 0.049 ns/op - JMHSample_36_BranchPrediction.sorted:·CPI avgt 5 0.286 ± 0.025 #/op - JMHSample_36_BranchPrediction.sorted:·branch-misses avgt 5 ≈ 10⁻⁴ #/op - JMHSample_36_BranchPrediction.sorted:·branches avgt 5 7.606 ± 1.742 #/op - JMHSample_36_BranchPrediction.sorted:·cycles avgt 5 8.998 ± 1.081 #/op - JMHSample_36_BranchPrediction.sorted:·instructions avgt 5 31.442 ± 4.899 #/op - - JMHSample_36_BranchPrediction.unsorted avgt 25 5.943 ± 0.018 ns/op - JMHSample_36_BranchPrediction.unsorted:·CPI avgt 5 0.775 ± 0.052 #/op - JMHSample_36_BranchPrediction.unsorted:·branch-misses avgt 5 0.529 ± 0.026 #/op <--- OOPS - JMHSample_36_BranchPrediction.unsorted:·branches avgt 5 7.841 ± 0.046 #/op - JMHSample_36_BranchPrediction.unsorted:·cycles avgt 5 24.793 ± 0.434 #/op - JMHSample_36_BranchPrediction.unsorted:·instructions avgt 5 31.994 ± 2.342 #/op + Benchmark Mode Cnt Score Error Units + JMHSample_36_BranchPrediction.sorted avgt 25 2.160 ± 0.049 ns/op + JMHSample_36_BranchPrediction.sorted:CPI avgt 5 0.286 ± 0.025 #/op + JMHSample_36_BranchPrediction.sorted:branch-misses avgt 5 ≈ 10⁻⁴ #/op + JMHSample_36_BranchPrediction.sorted:branches avgt 5 7.606 ± 1.742 #/op + JMHSample_36_BranchPrediction.sorted:cycles avgt 5 8.998 ± 1.081 #/op + JMHSample_36_BranchPrediction.sorted:instructions avgt 5 31.442 ± 4.899 #/op + + JMHSample_36_BranchPrediction.unsorted avgt 25 5.943 ± 0.018 ns/op + JMHSample_36_BranchPrediction.unsorted:CPI avgt 5 0.775 ± 0.052 #/op + JMHSample_36_BranchPrediction.unsorted:branch-misses avgt 5 0.529 ± 0.026 #/op <--- OOPS + JMHSample_36_BranchPrediction.unsorted:branches avgt 5 7.841 ± 0.046 #/op + JMHSample_36_BranchPrediction.unsorted:cycles avgt 5 24.793 ± 0.434 #/op + JMHSample_36_BranchPrediction.unsorted:instructions avgt 5 31.994 ± 2.342 #/op It is an open question if you want to measure only one of these tests. In many cases, you have to measure both to get the proper best-case and worst-case estimate! diff --git a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_37_CacheAccess.java b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_37_CacheAccess.java index da2254efa..7817b9c37 100644 --- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_37_CacheAccess.java +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_37_CacheAccess.java @@ -97,22 +97,22 @@ public void rowFirst(Blackhole bh) { pulling n-th element from each of the inner array induces more cache misses, when matrix is large. -prof perfnorm conveniently highlights that, with >2 cache misses per one benchmark op: - Benchmark Mode Cnt Score Error Units - JMHSample_37_MatrixCopy.colFirst avgt 25 5.306 ± 0.020 ns/op - JMHSample_37_MatrixCopy.colFirst:·CPI avgt 5 0.621 ± 0.011 #/op - JMHSample_37_MatrixCopy.colFirst:·L1-dcache-load-misses avgt 5 2.177 ± 0.044 #/op <-- OOPS - JMHSample_37_MatrixCopy.colFirst:·L1-dcache-loads avgt 5 14.804 ± 0.261 #/op - JMHSample_37_MatrixCopy.colFirst:·LLC-loads avgt 5 2.165 ± 0.091 #/op - JMHSample_37_MatrixCopy.colFirst:·cycles avgt 5 22.272 ± 0.372 #/op - JMHSample_37_MatrixCopy.colFirst:·instructions avgt 5 35.888 ± 1.215 #/op - - JMHSample_37_MatrixCopy.rowFirst avgt 25 2.662 ± 0.003 ns/op - JMHSample_37_MatrixCopy.rowFirst:·CPI avgt 5 0.312 ± 0.003 #/op - JMHSample_37_MatrixCopy.rowFirst:·L1-dcache-load-misses avgt 5 0.066 ± 0.001 #/op - JMHSample_37_MatrixCopy.rowFirst:·L1-dcache-loads avgt 5 14.570 ± 0.400 #/op - JMHSample_37_MatrixCopy.rowFirst:·LLC-loads avgt 5 0.002 ± 0.001 #/op - JMHSample_37_MatrixCopy.rowFirst:·cycles avgt 5 11.046 ± 0.343 #/op - JMHSample_37_MatrixCopy.rowFirst:·instructions avgt 5 35.416 ± 1.248 #/op + Benchmark Mode Cnt Score Error Units + JMHSample_37_MatrixCopy.colFirst avgt 25 5.306 ± 0.020 ns/op + JMHSample_37_MatrixCopy.colFirst:CPI avgt 5 0.621 ± 0.011 #/op + JMHSample_37_MatrixCopy.colFirst:L1-dcache-load-misses avgt 5 2.177 ± 0.044 #/op <-- OOPS + JMHSample_37_MatrixCopy.colFirst:L1-dcache-loads avgt 5 14.804 ± 0.261 #/op + JMHSample_37_MatrixCopy.colFirst:LLC-loads avgt 5 2.165 ± 0.091 #/op + JMHSample_37_MatrixCopy.colFirst:cycles avgt 5 22.272 ± 0.372 #/op + JMHSample_37_MatrixCopy.colFirst:instructions avgt 5 35.888 ± 1.215 #/op + + JMHSample_37_MatrixCopy.rowFirst avgt 25 2.662 ± 0.003 ns/op + JMHSample_37_MatrixCopy.rowFirst:CPI avgt 5 0.312 ± 0.003 #/op + JMHSample_37_MatrixCopy.rowFirst:L1-dcache-load-misses avgt 5 0.066 ± 0.001 #/op + JMHSample_37_MatrixCopy.rowFirst:L1-dcache-loads avgt 5 14.570 ± 0.400 #/op + JMHSample_37_MatrixCopy.rowFirst:LLC-loads avgt 5 0.002 ± 0.001 #/op + JMHSample_37_MatrixCopy.rowFirst:cycles avgt 5 11.046 ± 0.343 #/op + JMHSample_37_MatrixCopy.rowFirst:instructions avgt 5 35.416 ± 1.248 #/op So, when comparing two different benchmarks, you have to follow up if the difference is caused by the memory locality issues. From 2effa2c8310e1d3ad03c8ee02024edca9252b46a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 3 Aug 2023 14:10:41 +0200 Subject: [PATCH 342/342] JMH v1.37. --- jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-java-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml | 2 +- jmh-archetypes/pom.xml | 2 +- jmh-core-benchmarks/pom.xml | 2 +- jmh-core-ct/pom.xml | 2 +- jmh-core-it/pom.xml | 2 +- jmh-core/pom.xml | 2 +- jmh-generator-annprocess/pom.xml | 2 +- jmh-generator-asm/pom.xml | 2 +- jmh-generator-bytecode/pom.xml | 2 +- jmh-generator-reflection/pom.xml | 2 +- jmh-samples/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml index b12cd7294..3a4d2f95d 100644 --- a/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.37-SNAPSHOT + 1.37 jmh-groovy-benchmark-archetype diff --git a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml index 2ae7e4b99..a30b91c92 100644 --- a/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-java-benchmark-archetype/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-archetypes - 1.37-SNAPSHOT + 1.37 jmh-java-benchmark-archetype diff --git a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml index 2ab9f9fc0..1a972f95c 100644 --- a/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.37-SNAPSHOT + 1.37 jmh-kotlin-benchmark-archetype diff --git a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml index f3965ff94..e1dff4c6d 100644 --- a/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml +++ b/jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml @@ -5,7 +5,7 @@ org.openjdk.jmh jmh-archetypes - 1.37-SNAPSHOT + 1.37 jmh-scala-benchmark-archetype diff --git a/jmh-archetypes/pom.xml b/jmh-archetypes/pom.xml index ac09c66b3..83e52545c 100644 --- a/jmh-archetypes/pom.xml +++ b/jmh-archetypes/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Archetypes diff --git a/jmh-core-benchmarks/pom.xml b/jmh-core-benchmarks/pom.xml index 1c10c3e04..19b1bb674 100644 --- a/jmh-core-benchmarks/pom.xml +++ b/jmh-core-benchmarks/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Core Benchmarks diff --git a/jmh-core-ct/pom.xml b/jmh-core-ct/pom.xml index 5f6e853c7..26713f9ff 100644 --- a/jmh-core-ct/pom.xml +++ b/jmh-core-ct/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Core Compilation Tests diff --git a/jmh-core-it/pom.xml b/jmh-core-it/pom.xml index b61e20043..d4fa17137 100644 --- a/jmh-core-it/pom.xml +++ b/jmh-core-it/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Core Integration Tests diff --git a/jmh-core/pom.xml b/jmh-core/pom.xml index 6c3e9a7bb..3fd80a70c 100644 --- a/jmh-core/pom.xml +++ b/jmh-core/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Core diff --git a/jmh-generator-annprocess/pom.xml b/jmh-generator-annprocess/pom.xml index 3c151f2e1..276d0257f 100644 --- a/jmh-generator-annprocess/pom.xml +++ b/jmh-generator-annprocess/pom.xml @@ -31,7 +31,7 @@ questions. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Generators: Annotation Processors diff --git a/jmh-generator-asm/pom.xml b/jmh-generator-asm/pom.xml index 59df52d7a..966a3a3c4 100644 --- a/jmh-generator-asm/pom.xml +++ b/jmh-generator-asm/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Generators: ASM diff --git a/jmh-generator-bytecode/pom.xml b/jmh-generator-bytecode/pom.xml index 4805f7f34..2e7e59378 100644 --- a/jmh-generator-bytecode/pom.xml +++ b/jmh-generator-bytecode/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Generators: Bytecode diff --git a/jmh-generator-reflection/pom.xml b/jmh-generator-reflection/pom.xml index 07b2fb965..69f9565ec 100644 --- a/jmh-generator-reflection/pom.xml +++ b/jmh-generator-reflection/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Generators: Reflection diff --git a/jmh-samples/pom.xml b/jmh-samples/pom.xml index fcd57b2b3..56dea6757 100644 --- a/jmh-samples/pom.xml +++ b/jmh-samples/pom.xml @@ -36,7 +36,7 @@ THE POSSIBILITY OF SUCH DAMAGE. org.openjdk.jmh jmh-parent - 1.37-SNAPSHOT + 1.37 JMH Samples diff --git a/pom.xml b/pom.xml index 2b0a06f5e..2d4da4358 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ questions. org.openjdk.jmh jmh-parent pom - 1.37-SNAPSHOT + 1.37 Java Microbenchmark Harness Parent