本文整理汇总了Java中org.openjdk.jmh.results.Result类的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Result类属于org.openjdk.jmh.results包,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterIteration
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams,
IterationParams iterationParams,
IterationResult result) {
final ArrayList<Result> results = Lists.newArrayList();
if (metricRegistry == null) {
return results;
}
final SortedMap<String, Meter> counters = metricRegistry.getMeters((name, metric) -> {
return name.startsWith(MetricRegistry.name(Rule.class)) || name.startsWith(MetricRegistry.name(Pipeline.class));
});
counters.entrySet()
.forEach(stringCounterEntry -> result.addResult(new ScalarResult(stringCounterEntry.getKey(),
stringCounterEntry.getValue().getCount(),
"calls",
AggregationPolicy.SUM)));
return results;
}
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:20,代码来源:PipelinePerformanceBenchmarks.java
示例2: afterIteration
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
@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));
}
示例3: afterTrial
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterTrial(BenchmarkResult benchmarkResult, long l, File stdOut, File stdErr) {
String target = Paths.get(SAVE_FLIGHT_OUTPUT_TO).resolve(benchmarkResult.getParams().getBenchmark() + "-" + currentId++ + ".jfr").toAbsolutePath().toString();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try {
FileUtils.copy(jfrData, target);
pw.println("Flight Recording output saved to " + target);
} catch (IOException e) {
e.printStackTrace();
pw.println("Unable to save flight output to " + target);
pw.println("Did you miss the system property: -Djmh.jfr.saveTo ?");
}
pw.flush();
pw.close();
NoResult r = new NoResult(sw.toString());
return Collections.singleton(r);
}
示例4: afterIteration
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) {
Map<String, Long> current = counters().getCurrent();
return Arrays.asList(
new ProfilerResult("@threads.alive",
current.get("java.threads.live"),
"threads", AggregationPolicy.AVG),
new ProfilerResult("@threads.daemon",
current.get("java.threads.daemon"),
"threads", AggregationPolicy.AVG),
new ProfilerResult("@threads.started",
current.get("java.threads.started"),
"threads", AggregationPolicy.MAX)
);
}
示例5: aggregate
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
@Override
public Result aggregate(Collection<StackResult> results) {
Map<Thread.State, Multiset<StackRecord>> sum = new EnumMap<Thread.State, Multiset<StackRecord>>(Thread.State.class);
for (StackResult r : results) {
for (Map.Entry<Thread.State, Multiset<StackRecord>> entry : r.stacks.entrySet()) {
if (!sum.containsKey(entry.getKey())) {
sum.put(entry.getKey(), new HashMultiset<StackRecord>());
}
Multiset<StackRecord> sumSet = sum.get(entry.getKey());
for (StackRecord rec : entry.getValue().keys()) {
sumSet.add(rec, entry.getValue().count(rec));
}
}
}
return new StackResult(sum);
}
示例6: afterIteration
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) {
long gcTime = 0;
long gcCount = 0;
for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) {
gcCount += bean.getCollectionCount();
gcTime += bean.getCollectionTime();
}
return Arrays.asList(
new ProfilerResult("@gc.count.profiled", gcCount - beforeGCCount, "counts", AggregationPolicy.SUM),
new ProfilerResult("@gc.count.total", gcCount, "counts", AggregationPolicy.MAX),
new ProfilerResult("@gc.time.profiled", gcTime - beforeGCTime, "ms", AggregationPolicy.SUM),
new ProfilerResult("@gc.time.total", gcTime, "ms", AggregationPolicy.MAX)
);
}
示例7: generateImport
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
private void generateImport(PrintWriter writer) {
Class<?>[] imports = new Class<?>[]{
List.class, AtomicInteger.class,
Collection.class, ArrayList.class,
TimeUnit.class, Generated.class, CompilerControl.class,
InfraControl.class, ThreadParams.class,
Result.class, ThroughputResult.class, AverageTimeResult.class,
SampleTimeResult.class, SingleShotResult.class, SampleBuffer.class,
Mode.class, Fork.class, Measurement.class, Threads.class, Warmup.class,
BenchmarkMode.class, RawResults.class, ResultRole.class,
Field.class, BenchmarkParams.class, IterationParams.class
};
for (Class<?> c : imports) {
writer.println("import " + c.getName() + ';');
}
writer.println();
}
示例8: printLine
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
private void printLine(String label, BenchmarkParams benchParams, SortedSet<String> params,
Map<String, String> prefixes, boolean singleUnit, Result res) {
pw.printf("\\texttt{%s} & ", escape(prefixes.get(label)));
for (String p : params) {
pw.printf("\\texttt{%s}", escape(benchParams.getParam(p)));
pw.write(" & ");
}
pw.printf("\\texttt{%5.3f} & ", res.getScore());
pw.printf("\\scriptsize $\\pm$ \\texttt{%5.3f}", res.getScoreError());
if (!singleUnit) {
pw.printf(" & \\texttt{%s}", res.getScoreUnit());
}
pw.write(" \\\\");
pw.write("\n");
}
示例9: addLinuxVmStats
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
/**
* Parse the linux {@code /proc/self/status} and add everything prefixed with "Vm" as metric to
* the profiling result.
*/
private static void addLinuxVmStats(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 ScalarResult("+linux.proc.status." + _name, (double) Long.parseLong(sa[1]), "kB", AggregationPolicy.AVG)
);
}
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}
示例10: recordStats
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
public static void recordStats(String _statisticsString) {
if (before == null) {
throw new IllegalStateException("saveStats() needs to be called before iteration.");
}
Stat now = extract(_statisticsString);
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;
}
示例11: addLinuxVmStats
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
/**
* Parse the linux {@code /proc/self/status} and add everything prefixed with "Vm" as metric to
* the profiling result.
*/
private static void addLinuxVmStats(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 ScalarResult("+forced-gc-mem.used." + _name, (double) Long.parseLong(sa[1]), "kB", AggregationPolicy.AVG)
);
}
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}
示例12: afterIteration
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterIteration(final BenchmarkParams benchmarkParams, final IterationParams iterationParams, final IterationResult result) {
if (usedMemory <= 0) {
recordUsedMemory();
if (usedMemory <= 0) {
return Collections.emptyList();
}
}
List<Result> l = new ArrayList<>();
addLinuxVmStats(l);
l.addAll(Arrays.asList(
new ScalarResult("+forced-gc-mem.used.settled", (double) usedMemorySettled, "bytes", AggregationPolicy.AVG),
new ScalarResult("+forced-gc-mem.used.after", (double) usedMemory, "bytes", AggregationPolicy.AVG),
new ScalarResult("+forced-gc-mem.total", (double) totalMemory, "bytes", AggregationPolicy.AVG),
new ScalarResult("+forced-gc-mem.gcTimeMillis", (double) gcTimeMillis, "ms", AggregationPolicy.AVG),
new ScalarResult("+forced-gc-mem.usedHeap", (double) usedHeapMemory, "bytes", AggregationPolicy.AVG)
));
keepReference = null;
return l;
}
示例13: afterIteration
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
/**
* Run this code after a benchmark iteration finished
*
* @param benchmarkParams benchmark parameters used for current launch
* @param iterationParams iteration parameters used for current launch
* @param result iteration result
* @return profiler results
*/
@Override
public Collection<? extends Result<ProfilerResult>> afterIteration(
BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) {
String unit = "invocations";
AggregationPolicy policy = AggregationPolicy.AVG;
final ProfilerResult hashCodeResult =
new ProfilerResult("hashCode", CountingInteger.getHashcodeCounter(), unit, policy);
final ProfilerResult equalsResult =
new ProfilerResult("equals", CountingInteger.getEqualsCounter(), unit, policy);
return Arrays.asList(hashCodeResult, equalsResult);
}
示例14: afterTrial
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterTrial(BenchmarkParams benchmarkParams, File stdOut, File stdErr) {
try {
return Arrays.asList(
new LogConsumeResult("out", FileUtils.readAllLines(stdOut)),
new LogConsumeResult("err", FileUtils.readAllLines(stdErr))
);
} catch (IOException e) {
// skip
}
return Collections.emptyList();
}
示例15: aggregate
import org.openjdk.jmh.results.Result; //导入依赖的package包/类
@Override
public Result aggregate(Collection<LogConsumeResult> results) {
String label = null;
Collection<String> allLines = new ArrayList<String>();
for (LogConsumeResult r : results) {
label = r.label;
allLines.addAll(r.getLines());
}
return new LogConsumeResult(label, allLines);
}