Skip to content

Commit

Permalink
7903508: JMH: Remove the Unicode dot prefix from secondary results
Browse files Browse the repository at this point in the history
  • Loading branch information
shipilev committed Jul 27, 2023
1 parent 843f641 commit 09c78d5
Show file tree
Hide file tree
Showing 26 changed files with 191 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void test() throws RunnerException {
RunResult rr = new Runner(opts).runSingle();

Map<String, Result> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public void test() throws RunnerException {
RunResult rr = new Runner(opts).runSingle();

Map<String, Result> 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. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void test() throws RunnerException {
RunResult rr = new Runner(opts).runSingle();

Map<String, Result> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ private void testWith(String initLine) throws RunnerException {
double opsPerSec = rr.getPrimaryResult().getScore();

Map<String, Result> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testDefault() throws RunnerException {
RunResult rr = new Runner(opts).runSingle();

Map<String, Result> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void test() throws RunnerException {
RunResult rr = new Runner(opts).runSingle();

Map<String, Result> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void test() throws RunnerException {
RunResult rr = new Runner(opts).runSingle();

Map<String, Result> sr = rr.getSecondaryResults();
String text = ProfilerTestUtils.checkedGet(sr, "·perfc2c").extendedInfo();
String text = ProfilerTestUtils.checkedGet(sr, "perfc2c").extendedInfo();

Assert.assertNotNull(text);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public void test() throws RunnerException {
RunResult rr = new Runner(opts).runSingle();

Map<String, Result> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public void test() throws RunnerException {

Map<String, Result> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void test() throws RunnerException {

Map<String, Result> 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);
Expand Down Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void test() throws RunnerException {
RunResult rr = new Runner(opts).runSingle();

Map<String, Result> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void test() throws RunnerException {
RunResult rr = new Runner(opts).runSingle();

Map<String, Result> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ public Collection<? extends Result> 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
}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public Collection<? extends Result> 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();
Expand Down
14 changes: 7 additions & 7 deletions jmh-core/src/main/java/org/openjdk/jmh/profile/GCProfiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ public Collection<? extends Result> 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));
Expand All @@ -154,22 +154,22 @@ public Collection<? extends Result> 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,
"B/op", AggregationPolicy.AVG));
}
} 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));
}
Expand All @@ -187,13 +187,13 @@ public Collection<? extends Result> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static class PerfResult extends Result<PerfResult> {
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;
Expand All @@ -226,8 +226,8 @@ protected Aggregator<PerfResult> getIterationAggregator() {
protected Collection<? extends Result> getDerivativeResults() {
List<Result> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public Collection<? extends Result> 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;
}
}
22 changes: 11 additions & 11 deletions jmh-core/src/main/java/org/openjdk/jmh/profile/PausesProfiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static class PausesProfilerResult extends Result<PausesProfilerResult> {
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;
}

Expand All @@ -176,16 +176,16 @@ protected Aggregator<PausesProfilerResult> getIterationAggregator() {
@Override
protected Collection<? extends Result> 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)
);
}

Expand Down
Loading

0 comments on commit 09c78d5

Please sign in to comment.