org.openjdk.jmh.results.Result Java Examples
The following examples show how to use
org.openjdk.jmh.results.Result.
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: MemoryProfiler.java From unsafe with BSD 2-Clause "Simplified" License | 6 votes |
@Override public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { final Runtime runtime = Runtime.getRuntime(); final long max = runtime.maxMemory(); final long total = runtime.totalMemory(); final long free = runtime.freeMemory(); final long used = total - free; return Arrays .asList(new ProfilerResult(PREFIX + "rt.mem.max", max, "bytes", AggregationPolicy.MAX), new ProfilerResult(PREFIX + "rt.mem.total", total, "bytes", AggregationPolicy.MAX), new ProfilerResult(PREFIX + "rt.mem.free", free, "bytes", AggregationPolicy.MAX), new ProfilerResult(PREFIX + "rt.mem.used", used, "bytes", AggregationPolicy.MAX)); }
Example #3
Source File: LinuxVmProfiler.java From cache2k-benchmark with Apache License 2.0 | 6 votes |
/** * Parse the linux {@code /proc/self/status} and add everything prefixed with "Vm" as metric to * the profiling result. */ public static void addLinuxVmStats(String prefix, List<Result> l) { try { LineNumberReader r = new LineNumberReader(new InputStreamReader(new FileInputStream("/proc/self/status"))); String _line; while ((_line = r.readLine()) != null) { if (!_line.startsWith("Vm")) { continue; } String[] sa = _line.split("\\s+"); if (sa.length != 3) { throw new IOException("Format error: 3 elements expected"); } if (!sa[2].equals("kB")) { throw new IOException("Format error: unit kB expected, was: " + sa[2]); } String _name = sa[0].substring(0, sa[0].length() - 1); l.add( new OptionalScalarResult(prefix + "." + _name, (double) Long.parseLong(sa[1]), "kB", AggregationPolicy.AVG) ); } } catch (IOException ex) { throw new UncheckedIOException(ex); } }
Example #4
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 #5
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 #6
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 #7
Source File: ResultExporter.java From SpringBootBucket with MIT License | 5 votes |
public static void exportResult(String titleStr, Collection<RunResult> results, String paramKey, String xunit) throws Exception { // 几个测试对象 List<String> objects = new ArrayList<>(); // 测试维度,输入值n List<String> dimensions = new ArrayList<>(); // 有几个测试对象,就有几组测试数据,每组测试数据中对应几个维度的结果 List<List<Double>> allData = new ArrayList<>(); List<Double> temp = new ArrayList<>(); for (RunResult runResult : results) { BenchmarkResult benchmarkResult = runResult.getAggregatedResult(); Result r = benchmarkResult.getPrimaryResult(); BenchmarkParams params = runResult.getParams(); if (!objects.contains(r.getLabel())) { objects.add(r.getLabel()); if (!temp.isEmpty()) { allData.add(temp); temp = new ArrayList<>(); } } temp.add(Double.parseDouble(String.format("%.2f", r.getScore()))); // 测试维度 if (!dimensions.contains("n=" + params.getParam(paramKey))) { dimensions.add("n=" + params.getParam(paramKey)); } } // 最后一组测试数据别忘记加进去了 allData.add(temp); String optionStr = generateOption(titleStr, objects, dimensions, allData, xunit); // POST到接口上 postOption(optionStr, "http://localhost:9075/api/v1/data"); }
Example #8
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 #9
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 #10
Source File: ForcedGcMemoryProfiler.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) { if (runOnlyAfterLastIteration) { if (iterationParams.getType() != IterationType.MEASUREMENT || iterationParams.getCount() != ++iterationNumber) { return Collections.emptyList(); } } recordUsedMemory(); List<Result> l = new ArrayList<>(); l.addAll(Arrays.asList( new OptionalScalarResult("+forced-gc-mem.gcTimeMillis", (double) gcTimeMillis, "ms", AggregationPolicy.AVG), new OptionalScalarResult("+forced-gc-mem.usedHeap", (double) usedHeapViaHistogram, "bytes", AggregationPolicy.AVG) )); if (usageAfterIteration != null) { // old metrics, t.b. removed l.addAll(Arrays.asList( new OptionalScalarResult("+forced-gc-mem.used.settled", (double) usageAfterSettled.getTotalUsed(), "bytes", AggregationPolicy.AVG), new OptionalScalarResult("+forced-gc-mem.used.after", (double) usageAfterIteration.getTotalUsed(), "bytes", AggregationPolicy.AVG), new OptionalScalarResult("+forced-gc-mem.total", (double) usageAfterSettled.getTotalCommitted(), "bytes", AggregationPolicy.AVG) )); l.addAll(Arrays.asList( new OptionalScalarResult("+forced-gc-mem.totalUsed", (double) usageAfterSettled.getTotalUsed(), "bytes", AggregationPolicy.AVG), new OptionalScalarResult("+forced-gc-mem.totalUsed.after", (double) usageAfterIteration.getTotalUsed(), "bytes", AggregationPolicy.AVG), new OptionalScalarResult("+forced-gc-mem.totalCommitted", (double) usageAfterSettled.getTotalCommitted(), "bytes", AggregationPolicy.AVG), new OptionalScalarResult("+forced-gc-mem.totalCommitted.after", (double) usageAfterIteration.getTotalCommitted(), "bytes", AggregationPolicy.AVG), new OptionalScalarResult("+forced-gc-mem.heapUsed", (double) usageAfterSettled.heap.getUsed(), "bytes", AggregationPolicy.AVG), new OptionalScalarResult("+forced-gc-mem.heapUsed.after", (double) usageAfterIteration.heap.getUsed(), "bytes", AggregationPolicy.AVG) )); } LinuxVmProfiler.addLinuxVmStats("+forced-gc-mem.linuxVm", l); keepReference = null; return l; }
Example #11
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 #12
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; }
Example #13
Source File: MiscResultRecorderProfiler.java From cache2k-benchmark with Apache License 2.0 | 4 votes |
/** * Add result to the JMH result data. If called multiple times with the same label only the last one will be added. */ public static void setResult(Result r) { results.put(r.getLabel(), r); }
Example #14
Source File: LinuxVmProfiler.java From cache2k-benchmark with Apache License 2.0 | 4 votes |
@Override public Collection<? extends Result> afterIteration(final BenchmarkParams benchmarkParams, final IterationParams iterationParams, final IterationResult result) { List<Result> l = new ArrayList<>(); addLinuxVmStats(PREFIX, l); return l; }
Example #15
Source File: FlightRecorderProfiler.java From calcite with Apache License 2.0 | 4 votes |
@Override public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { return Collections.emptyList(); }
Example #16
Source File: FlightRecorderProfiler.java From cglib with Apache License 2.0 | 4 votes |
@Override public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) { return Collections.emptyList(); }
Example #17
Source File: FlightRecorderProfiler.java From tlaplus with MIT License | 4 votes |
@Override public Collection<? extends Result> afterTrial(BenchmarkResult arg0, long arg1, File arg2, File arg3) { return new ArrayList<>(); }