RFR: Rework Results API

Aleksey Shipilev aleksey.shipilev at oracle.com
Thu Aug 29 12:09:26 PDT 2013


Hi again,

Please review the cleanup for the Results API in JMH:
  http://cr.openjdk.java.net/~shade/jmh/results-rework-1.webrev/
  http://cr.openjdk.java.net/~shade/jmh/results-rework-1.changesets

Overview:
  - API now publishes proper RunResult; greatly revised
RunResult/IterationResult interactions; pruned lots of redundant code
along the way
  - Results API is re-thinked in the following way: every benchmark
always has the primary result, and unlimited number of named secondary
results; this allows us to fold asymmetric benchmarks to report global
primary score, as well as per-type secondary results
  - Profiler results are available through the Results API, and we can
now think to fold some of the profiling results to the secondary
benchmark results to report them in human-readable report, fit them into
the averaging, etc.
  - OutputFormat and couple of internal classes is also retrofitted to
make the internal API cleaner

All in all, this allows me to do:

    public static void main(String[] args) throws RunnerException {
        Options opts = new OptionsBuilder()
                .include(".*")
                .warmupTime(TimeValue.milliseconds(100))
                .measurementTime(TimeValue.milliseconds(100))
                .jvmArgs("-server")
                .forks(5)
                .outputFormat(OutputFormatType.TextReport)
                .build();

        RunResult runResult = new Runner(opts).runSingle();
        Result result = runResult.getPrimaryResult();

        System.out.println();
        System.out.println("API replied benchmark score: "
                  + result.getScore() + " "
                  + result.getScoreUnit() + " over "
                  + result.getStatistics().getN()
                  + " iterations");
    }

API deserves a bit of polishing, but this is already very cool. ;)

Thanks,
Aleksey.


More information about the jmh-dev mailing list