• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BenchmarkResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openjdk.jmh.results.BenchmarkResult的典型用法代码示例。如果您正苦于以下问题:Java BenchmarkResult类的具体用法?Java BenchmarkResult怎么用?Java BenchmarkResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BenchmarkResult类属于org.openjdk.jmh.results包,在下文中一共展示了BenchmarkResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: afterTrial

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的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);
}
 
开发者ID:biboudis,项目名称:jmh-profilers,代码行数:24,代码来源:FlightRecordingProfiler.java


示例2: runBenchmark

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
BenchmarkResult runBenchmark(BenchmarkParams benchParams) {
    BenchmarkHandler handler = null;
    try {
        String target = benchParams.generatedBenchmark();
        int lastDot = target.lastIndexOf('.');
        Class<?> clazz = ClassUtils.loadClass(target.substring(0, lastDot));
        Method method = BenchmarkHandlers.findBenchmarkMethod(clazz, target.substring(lastDot + 1));

        handler = BenchmarkHandlers.getInstance(out, clazz, method, benchParams, options);

        return runBenchmark(benchParams, handler);
    } catch (BenchmarkException be) {
        throw be;
    } catch (Throwable ex) {
        throw new BenchmarkException(ex);
    } finally {
        if (handler != null) {
            handler.shutdown();
        }
    }
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:22,代码来源:BaseRunner.java


示例3: createMockedRunResult

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
private RunResult createMockedRunResult(final double value) {
	final IterationResult iterationResult = new IterationResult(null, null, null);
	iterationResult.addResult(new SingleShotResult(ResultRole.PRIMARY, "", (long) value, TimeUnit.NANOSECONDS));
	final Collection<IterationResult> iterationResults = Arrays.asList(iterationResult);
	final BenchmarkResult benchmarkResult = new BenchmarkResult(null, iterationResults);
	final Collection<BenchmarkResult> benchmarkResults = Arrays.asList(benchmarkResult);
	return new RunResult(null, benchmarkResults);
}
 
开发者ID:SoerenHenning,项目名称:RadarGun,代码行数:9,代码来源:TestResultFactoryTest.java


示例4: run

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
public void run() throws IOException, ClassNotFoundException {
    ActionPlan actionPlan = link.requestPlan();

    try {
        Multimap<BenchmarkParams,BenchmarkResult> res = runBenchmarks(true, actionPlan);
        link.pushResults(res);
    } catch (BenchmarkException be) {
        link.pushException(be);
    }

    out.flush();
    out.close();
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:14,代码来源:ForkedRunner.java


示例5: runBenchmarks

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
private Collection<RunResult> runBenchmarks(SortedSet<BenchmarkListEntry> benchmarks) throws RunnerException {
    out.startRun();

    Multimap<BenchmarkParams, BenchmarkResult> results = new TreeMultimap<BenchmarkParams, BenchmarkResult>();
    List<ActionPlan> plan = getActionPlans(benchmarks);

    etaBeforeBenchmarks(plan);

    try {
        for (ActionPlan r : plan) {
            Multimap<BenchmarkParams, BenchmarkResult> res;
            switch (r.getType()) {
                case EMBEDDED:
                    res = runBenchmarks(false, r);
                    break;
                case FORKED:
                    res = runSeparate(r);
                    break;
                default:
                    throw new IllegalStateException("Unknown action plan type: " + r.getType());
            }

            for (BenchmarkParams br : res.keys()) {
                results.putAll(br, res.get(br));
            }
        }

        etaAfterBenchmarks();

        SortedSet<RunResult> runResults = mergeRunResults(results);
        out.endRun(runResults);
        return runResults;
    } catch (BenchmarkException be) {
        throw new RunnerException("Benchmark caught the exception", be.getCause());
    }
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:37,代码来源:Runner.java


示例6: mergeRunResults

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
private SortedSet<RunResult> mergeRunResults(Multimap<BenchmarkParams, BenchmarkResult> results) {
    SortedSet<RunResult> result = new TreeSet<RunResult>(RunResult.DEFAULT_SORT_COMPARATOR);
    for (BenchmarkParams key : results.keys()) {
        result.add(new RunResult(results.get(key)));
    }
    return result;
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:8,代码来源:Runner.java


示例7: BinaryLinkServer

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
public BinaryLinkServer(Options opts, OutputFormat out) throws IOException {
    this.opts = opts;
    this.out = out;
    this.methods = new HashMap<String, Method>();
    this.forbidden = new HashSet<String>();

    // enumerate methods
    for (Method m : OutputFormat.class.getMethods()) {

        // start/end run callbacks are banned, since their effects are enforced by parent instead
        if (m.getName().equals("startRun")) { forbidden.add(ClassConventions.getMethodName(m)); }
        if (m.getName().equals("endRun"))   { forbidden.add(ClassConventions.getMethodName(m)); }

        Method prev = methods.put(ClassConventions.getMethodName(m), m);
        if (prev != null) {
            out.println("WARNING: Duplicate methods: " + m + " vs. " + prev);
            throw new IllegalStateException("WARNING: Duplicate methods: " + m + " vs. " + prev);
        }
    }

    acceptor = new Acceptor();
    acceptor.start();

    handler = new AtomicReference<Handler>();
    results = new AtomicReference<Multimap<BenchmarkParams, BenchmarkResult>>(new HashMultimap<BenchmarkParams, BenchmarkResult>());
    exception = new AtomicReference<BenchmarkException>();
    plan = new AtomicReference<ActionPlan>();
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:29,代码来源:BinaryLinkServer.java


示例8: getResults

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
public Multimap<BenchmarkParams, BenchmarkResult> getResults() {
    Multimap<BenchmarkParams, BenchmarkResult> res = results.getAndSet(new HashMultimap<BenchmarkParams, BenchmarkResult>());
    if (res != null) {
        return res;
    } else {
        throw new IllegalStateException("Acquiring the null result");
    }
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:9,代码来源:BinaryLinkServer.java


示例9: endBenchmark

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
@Override
public void endBenchmark(BenchmarkResult result) {
    out.println();
    if (result != null) {
        out.println(result.getPrimaryResult().extendedInfo(null));
        for (Result r : result.getSecondaryResults().values()) {
            out.println(r.extendedInfo(r.getLabel()));
        }
        out.println();
    }
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:12,代码来源:TextReportFormat.java


示例10: getTimes

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
private List<Double> getTimes(String algorithmId,
                              String datasetId,
                              int warmUps,
                              int measurements) throws CLIWrapperException, RunnerException {
    Options options = new OptionsBuilder()
            .forks(1)
            .measurementIterations(measurements)
            .warmupIterations(warmUps)
            .param("datasetId", datasetId)
            .param("algorithmId", algorithmId)
            .include(JMHBenchmark.class.getName())
            .build();

    Collection<RunResult> results = new Runner(options).run();
    List<Double> times = new ArrayList<>();
    for (RunResult result : results) {
        for (BenchmarkResult benchmarkResult : result.getBenchmarkResults()) {
            BenchmarkParams params = benchmarkResult.getParams();
            String myDatasetId = params.getParam("datasetId");
            if (!datasetId.equals(myDatasetId)) {
                throw new CLIWrapperException("Unable to dig through JMH output: Value for 'datasetId' parameter is '"
                        + myDatasetId + "' but expected '" + datasetId + "'", null);
            }
            String myAlgorithmId = params.getParam("algorithmId");
            if (!algorithmId.equals(myAlgorithmId)) {
                throw new CLIWrapperException("Unable to dig through JMH output: Value for 'algorithmId' parameter is '"
                        + myAlgorithmId + "' but expected '" + algorithmId + "'", null);
            }
            int count = 0;
            for (IterationResult iterationResult : benchmarkResult.getIterationResults()) {
                for (Result<?> primary : iterationResult.getRawPrimaryResults()) {
                    if (primary.getStatistics().getN() != 1) {
                        throw new CLIWrapperException("Unable to dig through JMH output: getN() != 1", null);
                    }
                    if (!primary.getScoreUnit().equals("us/op")) {
                        throw new CLIWrapperException("Unable to dig through JMH output: getScoreUnit() = " + primary.getScoreUnit(), null);
                    }
                    double value = primary.getScore() / 1e6;
                    times.add(value / IdCollection.getDataset(datasetId).getNumberOfInstances());
                    ++count;
                }
            }
            if (count != measurements) {
                throw new CLIWrapperException("Unable to dig through JMH output: Expected "
                        + measurements + " measurements, found " + count, null);
            }
        }
    }
    return times;
}
 
开发者ID:mbuzdalov,项目名称:non-dominated-sorting,代码行数:51,代码来源:Benchmark.java


示例11: afterTrial

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) {
    return Collections.emptyList();
}
 
开发者ID:cglib,项目名称:cglib,代码行数:5,代码来源:FlightRecorderProfiler.java


示例12: pushResults

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
public void pushResults(Multimap<BenchmarkParams, BenchmarkResult> res) throws IOException {
    pushFrame(new ResultsFrame(res));
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:4,代码来源:BinaryLinkClient.java


示例13: ResultsFrame

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
public ResultsFrame(Multimap<BenchmarkParams, BenchmarkResult> res) {
    this.res = res;
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:4,代码来源:ResultsFrame.java


示例14: getRes

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
public Multimap<BenchmarkParams, BenchmarkResult> getRes() {
    return res;
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:4,代码来源:ResultsFrame.java


示例15: runBenchmarks

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
protected Multimap<BenchmarkParams, BenchmarkResult> runBenchmarks(boolean forked, ActionPlan actionPlan) {
    Multimap<BenchmarkParams, BenchmarkResult> results = new TreeMultimap<BenchmarkParams, BenchmarkResult>();

    for (Action action : actionPlan.getActions()) {

        BenchmarkParams params = action.getParams();
        ActionMode mode = action.getMode();

        if (!forked) {
            String opts = Utils.join(params.getJvmArgs(), " ").trim();
            String realOpts = Utils.join(ManagementFactory.getRuntimeMXBean().getInputArguments(), " ").trim();
            if (opts.isEmpty()) {
                opts = "<none>";
            }
            if (realOpts.isEmpty()) {
                realOpts = "<none>";
            }

            Version.printVersion(out);
            out.println("# VM invoker: " + params.getJvm());
            out.println("# VM invoker: " + params.getJvm());
            out.println("# VM options: " + realOpts + (opts.equals(realOpts) ? "" : " *** WARNING: some JVM options are ignored in non-forked runs ***"));

            out.startBenchmark(params);
            out.println("");
            etaBeforeBenchmark();
            out.println("# Fork: N/A, test runs in the existing VM");
        }

        BenchmarkResult r = null;
        try {
            switch (mode) {
                case WARMUP: {
                    runBenchmark(params);
                    out.println("");
                    break;
                }
                case WARMUP_MEASUREMENT:
                case MEASUREMENT: {
                    r = runBenchmark(params);
                    results.put(params, r);
                    break;
                }
                default:
                    throw new IllegalStateException("Unknown mode: " + mode);

            }
        } catch (BenchmarkException be) {
            out.println("<failure>");
            out.println("");
            out.println(Utils.throwableToString(be.getCause()));
            out.println("");

            if (options.shouldFailOnError().orElse(Defaults.FAIL_ON_ERROR)) {
                throw be;
            }
        }

        if (!forked) {
            etaAfterBenchmark(params);
            out.endBenchmark(r);
        }
    }

    return results;
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:67,代码来源:BaseRunner.java


示例16: getStub

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
private Collection<RunResult> getStub() {
    Collection<RunResult> results = new TreeSet<RunResult>(RunResult.DEFAULT_SORT_COMPARATOR);

    Random r = new Random(12345);
    for (int b = 0; b < r.nextInt(10); b++) {
        WorkloadParams ps = new WorkloadParams();
        for (int p = 0; p < 5; p++) {
            ps.put("param" + p, "value" + p, p);
        }
        BenchmarkParams params = new BenchmarkParams(
                "benchmark_" + b,
                JSONResultFormat.class.getName() + ".benchmark_" + b + "_" + Mode.Throughput,
                false,
                r.nextInt(1000),
                new int[]{ r.nextInt(1000) },
                r.nextInt(1000),
                r.nextInt(1000),
                new IterationParams(IterationType.WARMUP,      r.nextInt(1000), TimeValue.seconds(r.nextInt(1000)), 1),
                new IterationParams(IterationType.MEASUREMENT, r.nextInt(1000), TimeValue.seconds(r.nextInt(1000)), 1),
                Mode.Throughput,
                ps,
                TimeUnit.SECONDS, 1,
                Utils.getCurrentJvm(),
                Collections.<String>emptyList(),
                TimeValue.days(1));

        Collection<BenchmarkResult> benchmarkResults = new ArrayList<BenchmarkResult>();
        for (int f = 0; f < r.nextInt(10); f++) {
            Collection<IterationResult> iterResults = new ArrayList<IterationResult>();
            for (int c = 0; c < r.nextInt(10); c++) {
                IterationResult res = new IterationResult(params, params.getMeasurement());
                res.addResult(new ThroughputResult(ResultRole.PRIMARY, "test", r.nextInt(1000), 1000 * 1000, TimeUnit.MILLISECONDS));
                res.addResult(new ThroughputResult(ResultRole.SECONDARY, "secondary1", r.nextInt(1000), 1000 * 1000, TimeUnit.MILLISECONDS));
                res.addResult(new ThroughputResult(ResultRole.SECONDARY, "secondary2", r.nextInt(1000), 1000 * 1000, TimeUnit.MILLISECONDS));
                iterResults.add(res);
            }
            benchmarkResults.add(new BenchmarkResult(iterResults));
        }
        results.add(new RunResult(benchmarkResults));
    }
    return results;
}
 
开发者ID:msteindorfer,项目名称:jmh,代码行数:43,代码来源:ResultFormatTest.java


示例17: afterTrial

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
@Override public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid,
    File stdOut, File stdErr) {
  return Collections.emptyList();
}
 
开发者ID:apache,项目名称:calcite,代码行数:5,代码来源:FlightRecorderProfiler.java


示例18: afterTrial

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterTrial(final BenchmarkResult benchmarkResult, long l, final File stdOut, final File stdErr) {
    return asList(new SolarisStudioResult());
}
 
开发者ID:nicoulaj,项目名称:jmh-utils,代码行数:5,代码来源:SolarisStudioProfiler.java


示例19: afterTrial

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterTrial(BenchmarkResult benchmarkResult, long l, final File stdOut, final File stdErr) {
    return asList(new JFRResult());
}
 
开发者ID:nicoulaj,项目名称:jmh-utils,代码行数:5,代码来源:FlightRecorderProfiler.java


示例20: afterTrial

import org.openjdk.jmh.results.BenchmarkResult; //导入依赖的package包/类
@Override
public Collection<? extends Result> afterTrial(final BenchmarkResult benchmarkParams, long l, final File stdOut, final File stdErr) {
    return asList(new YourkitResult());
}
 
开发者ID:nicoulaj,项目名称:jmh-utils,代码行数:5,代码来源:YourkitProfiler.java



注:本文中的org.openjdk.jmh.results.BenchmarkResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PDone类代码示例发布时间:2022-05-23
下一篇:
Java OutputUtil类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap