org.openjdk.jmh.results.ScalarResult Java Examples
The following examples show how to use
org.openjdk.jmh.results.ScalarResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MemoryProfiler.java From customized-symspell with MIT License | 6 votes |
@Override public Collection<? extends Result> afterIteration(BenchmarkParams bp, IterationParams ip, IterationResult result) { MemoryUsage heapUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); MemoryUsage nonheapUsage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); Collection<ScalarResult> results = new ArrayList<>(); results.add( new ScalarResult(Defaults.PREFIX + "mem.heap", heapUsage.getUsed() / (1024 * 1024.0), "MB", AggregationPolicy.MAX)); results.add(new ScalarResult( Defaults.PREFIX + "mem.nonheap", nonheapUsage.getUsed() / (1024 * 1024.0), "MB", AggregationPolicy.MAX)); return results; }
Example #2
Source File: Cache2kMetricsRecorder.java From cache2k-benchmark with Apache License 2.0 | 6 votes |
public static void recordStatsAfterIteration(String _statisticsString) { Stat now = extract(_statisticsString); if (now == null) { return; } if (before == null) { throw new IllegalStateException("saveStats() needs to be called before iteration."); } long _scanCount = now.scanCount - before.scanCount; long _evictCount = now.evictCount - before.evictCount; long _getCount = now.getCount - before.getCount; List<Result> l = new ArrayList<>(); l.add(new ScalarResult(RESULT_PREFIX + "scanCount", _scanCount, "counter", AggregationPolicy.AVG)); l.add(new ScalarResult(RESULT_PREFIX + "evictCount", _evictCount, "counter", AggregationPolicy.AVG)); l.add(new ScalarResult(RESULT_PREFIX + "getCount", _getCount, "counter", AggregationPolicy.AVG)); if (_evictCount > 0) { l.add(new ScalarResult(RESULT_PREFIX + "scanPerEviction", _scanCount * 1.0D / _evictCount, "counter", AggregationPolicy.AVG)); } l.forEach(MiscResultRecorderProfiler::setResult); before = now; }
Example #3
Source File: GenesisMemoryProfiler.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@Override public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { long totalHeap = Runtime.getRuntime().totalMemory(); Collection<ScalarResult> samples = new ArrayList<>(); samples.add(new ScalarResult("Max heap", StorageUnit.BYTES.toGBs(totalHeap), "GBs", AggregationPolicy.MAX)); return samples; }
Example #4
Source File: CpuProfiler.java From apm-agent-java with Apache License 2.0 | 5 votes |
@Override public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { List<ScalarResult> results = new ArrayList<>(); long allOps = result.getMetadata().getAllOps(); long totalCpuTime = osMxBean.getProcessCpuTime() - beforeProcessCpuTime; results.add(new ScalarResult(Defaults.PREFIX + "cpu.time.norm", (allOps != 0) ? 1.0 * totalCpuTime / allOps : Double.NaN, "ns/op", AggregationPolicy.AVG)); return results; }
Example #5
Source File: ReporterProfiler.java From apm-agent-java with Apache License 2.0 | 5 votes |
@Override public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { List<ScalarResult> results = new ArrayList<>(); final TimeValue time = iterationParams.getTime(); final Reporter reporter = getReporter(); if (reporter != null) { final double iterationDurationNs = time.convertTo(TimeUnit.NANOSECONDS); final long reportedDuringThisIteration = reporter.getReported() - reportedCountStart; if (reportedDuringThisIteration > 0) { double reportsPerSecond = perSecond(iterationDurationNs, reportedDuringThisIteration); results.add(new ScalarResult(Defaults.PREFIX + "reporter.reported", reportsPerSecond, "events/s", AggregationPolicy.AVG)); } final long droppedDuringThisIteration = reporter.getDropped() - droppedCountStart; if (droppedDuringThisIteration >0) { double dropsPerSecond = perSecond(iterationDurationNs, droppedDuringThisIteration); results.add(new ScalarResult(Defaults.PREFIX + "reporter.dropped", dropsPerSecond, "events/s", AggregationPolicy.AVG)); } if (receivedBytesStart != null) { long receivedBytesDuringThisIteration = getLong("server.received.bytes") - receivedBytesStart; results.add(new ScalarResult(Defaults.PREFIX + "server.received.bytes", perSecond(iterationDurationNs, receivedBytesDuringThisIteration), "bytes/s", AggregationPolicy.AVG)); } if (receivedPayloadsStart != null) { long receivedPayloadsDuringThisIteration = getLong("server.received.payloads") - receivedPayloadsStart; results.add(new ScalarResult(Defaults.PREFIX + "server.received.payloads", perSecond(iterationDurationNs, receivedPayloadsDuringThisIteration), "payloads/s", AggregationPolicy.AVG)); } } return results; }
Example #6
Source File: MemoryProfiler.java From NNAnalytics with Apache License 2.0 | 5 votes |
@Override public Collection<? extends Result> afterIteration( final BenchmarkParams benchmarkParams, final IterationParams iterationParams, final IterationResult result) { long usedMemoryAfterIteration = getUsedMemory(); references = null; long usedMemoryInIteration = usedMemoryAfterIteration - usedMemoryBeforeIteration; double usedMemoryPerOp = ((double) usedMemoryInIteration) / result.getMetadata().getMeasuredOps(); List<Result> results = new ArrayList<Result>(); results.add(new ScalarResult("+memory.used", usedMemoryPerOp, "bytes", AggregationPolicy.AVG)); return results; }
Example #7
Source File: MiscResultRecorderProfiler.java From cache2k-benchmark with Apache License 2.0 | 5 votes |
@Override public Collection<? extends Result> afterIteration(final BenchmarkParams benchmarkParams, final IterationParams iterationParams, final IterationResult result) { List<Result<?>> all = new ArrayList<>(); counters.values().stream() .map(e -> new ScalarResult(SECONDARY_RESULT_PREFIX + e.key, (double) e.counter.get(), e.unit, e.aggregationPolicy)) .sequential().forEach(e -> all.add(e)); all.addAll(results.values()); return all; }
Example #8
Source File: MiscResultRecorderProfiler.java From cache2k-benchmark with Apache License 2.0 | 4 votes |
/** * Insert the counter value as secondary result. An existing counter value is replaced. */ public static void setResult(String key, double _result, String _unit, AggregationPolicy _aggregationPolicy) { setResult(new ScalarResult(SECONDARY_RESULT_PREFIX + key, _result, _unit, _aggregationPolicy)); }
Example #9
Source File: GcProfiler.java From cache2k-benchmark with Apache License 2.0 | 4 votes |
@Override public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult iResult) { try { Thread.sleep(567); } catch (InterruptedException ignore) { } uninstallHooks(); long afterTime = System.nanoTime(); HotspotAllocationSnapshot newSnapshot = HotspotAllocationSnapshot.create(); long gcTime = 0; long gcCount = 0; for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) { gcCount += bean.getCollectionCount(); gcTime += bean.getCollectionTime(); } List<Result<?>> results = new ArrayList<>(); if (beforeAllocated == HotspotAllocationSnapshot.EMPTY) { results.add(new ScalarResult(Defaults.PREFIX + "gc.alloc.rate", Double.NaN, "MB/sec", AggregationPolicy.AVG)); } else { long allocated = newSnapshot.subtract(beforeAllocated); 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 ScalarResult(Defaults.PREFIX + "gc.alloc.rate.norm", (allOps != 0) ? 1.0 * allocated / allOps : Double.NaN, "B/op", AggregationPolicy.AVG)); } } results.add(new ScalarResult( Defaults.PREFIX + "gc.count", gcCount - beforeGCCount, "counts", AggregationPolicy.AVG)); if (gcCount != beforeGCCount || gcTime != beforeGCTime) { results.add(new ScalarResult( Defaults.PREFIX + "gc.time", gcTime - beforeGCTime, "ms", AggregationPolicy.AVG)); } for (String space : churn.keys()) { double churnRate = (afterTime != beforeTime) ? 1.0 * churn.count(space) * TimeUnit.SECONDS.toNanos(1) / (afterTime - beforeTime) / 1024 / 1024 : Double.NaN; double churnNorm = 1.0 * churn.count(space) / iResult.getMetadata().getAllOps(); String spaceName = space.replaceAll(" ", "_"); results.add(new ScalarResult( Defaults.PREFIX + "gc.churn." + spaceName + "", churnRate, "MB/sec", AggregationPolicy.AVG)); results.add(new ScalarResult(Defaults.PREFIX + "gc.churn." + spaceName + ".norm", churnNorm, "B/op", AggregationPolicy.AVG)); } if (!usedAfterGc.isEmpty()) { Collections.sort(usedAfterGc); long _maximumUsedAfterGc = usedAfterGc.get(usedAfterGc.size() - 1); results.add(new ScalarResult(Defaults.PREFIX + "gc.maximumUsedAfterGc", _maximumUsedAfterGc, "bytes", AggregationPolicy.AVG)); System.out.println("maximumUsedAfterGc=" + _maximumUsedAfterGc); } if (!committedAfterGc.isEmpty()) { Collections.sort(committedAfterGc); long _committedUsedAfterGc = committedAfterGc.get(committedAfterGc.size() - 1); results.add(new ScalarResult(Defaults.PREFIX + "gc.maximumCommittedAfterGc", _committedUsedAfterGc, "bytes", AggregationPolicy.AVG)); System.out.println("maximumCommittedAfterGc=" + _committedUsedAfterGc); } return results; }