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] 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.