Java Code Examples for org.openjdk.jmh.runner.options.OptionsBuilder#include()

The following examples show how to use org.openjdk.jmh.runner.options.OptionsBuilder#include() . 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: Genesis.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws RunnerException {
  CommandLine commandLine = new CommandLine(new Genesis());
  commandLine.parse(args);
  if (commandLine.isUsageHelpRequested()) {
    commandLine.usage(System.out);
    return;
  }

  OptionsBuilder optionsBuilder = new OptionsBuilder();
  if (benchmarks != null) {
    // The OptionsBuilder#include takes a regular expression as argument.
    // Therefore it is important to keep the benchmark names unique for
    // running a benchmark. For example if there are two benchmarks -
    // BenchMarkOM and BenchMarkOMClient and we include BenchMarkOM then
    // both the benchmarks will be run.
    for (String benchmark : benchmarks) {
      optionsBuilder.include(benchmark);
    }
  }
  optionsBuilder.warmupIterations(2)
      .measurementIterations(20)
      .addProfiler(StackProfiler.class)
      .addProfiler(GCProfiler.class)
      .shouldDoGC(true)
      .forks(1)
      .threads(numThreads);

  if (seconds > 0) {
    optionsBuilder.measurementTime(seconds(seconds));
  }

  new Runner(optionsBuilder.build()).run();
}
 
Example 2
Source File: JmhIdeBenchmarkRunner.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Get prepared options builder.
 *
 * @return Options builder.
 */
public OptionsBuilder optionsBuilder() {
    OptionsBuilder builder = new OptionsBuilder();

    builder.forks(forks);
    builder.warmupIterations(warmupIterations);
    builder.measurementIterations(measurementIterations);
    builder.timeUnit(outputTimeUnit);
    builder.threads(threads);

    if (benchmarkModes != null) {
        for (Mode benchmarkMode : benchmarkModes)
            builder.getBenchModes().add(benchmarkMode);
    }

    if (benchmarks != null) {
        for (Object benchmark : benchmarks) {
            if (benchmark instanceof Class)
                builder.include(((Class)benchmark).getSimpleName());
            else
                builder.include(benchmark.toString());
        }
    }

    if (jvmArgs != null)
        builder.jvmArgs(jvmArgs);

    if (output != null)
        builder.output(output);

    if (profilers != null) {
        for (Class profiler : profilers)
            builder.addProfiler(profiler);
    }

    return builder;
}
 
Example 3
Source File: QueryBenchmark.java    From rya with Apache License 2.0 4 votes vote down vote up
/**
 * Runs the query benchmarks.
 * </p>
 * Example command line:
 * <pre>
 * java -cp benchmarks.jar org.apache.rya.benchmark.query.QueryBenchmark
 * </pre>
 *
 * @param args - The command line arguments that will be fed into the benchmark.
 * @throws Exception The benchmark could not be run.
 */
public static void main(final String[] args) throws Exception {
    // Read the queries that will be benchmarked from the provided path.
    final InputStream queriesStream = Files.newInputStream( QUERY_BENCHMARK_CONFIGURATION_FILE );
    final QueriesBenchmarkConf benchmarkConf = new QueriesBenchmarkConfReader().load(queriesStream);
    final Parameters parameters = benchmarkConf.getParameters();

    // Setup the options that will be used to run the benchmark.
    final OptionsBuilder options = new OptionsBuilder();
    options.parent( new CommandLineOptions(args) );
    options.include(QueryBenchmark.class.getSimpleName());

    // Provide the SPARQL queries that will be injected into the benchmark's 'sparql' parameter.
    final List<String> sparql = parameters.getQueries().getSPARQL();
    final String[] sparqlArray = new String[ sparql.size() ];
    sparql.toArray( sparqlArray );

    // Clean up the sparql's whitespace.
    for(int i = 0; i < sparqlArray.length; i++) {
        sparqlArray[i] = sparqlArray[i].trim();
    }

    options.param("sparql", sparqlArray);

    // If numReadsRuns was specified, inject them into the benchmark's 'numReads' parameter.
    final NumReadsRuns numReadsRuns = parameters.getNumReadsRuns();
    if(numReadsRuns != null) {
        // Validate the list.
        final List<String> numReadsList = numReadsRuns.getNumReads();
        for(final String numReads : numReadsList) {
            // It may be the READ_ALL flag.
            if(numReads.equals(READ_ALL)) {
                continue;
            }

            // Or it must be a Long.
            try {
                Long.parseLong(numReads);
            } catch(final NumberFormatException e) {
                throw new RuntimeException("There is a problem with the benchmark's configuration. Encountered " +
                        "a numReads value of '" + numReads + "', which is inavlid. The value must be a Long or " +
                        "'" + READ_ALL + "'");
            }
        }

        // Configure the benchmark with the numRuns.
        final String[] numReadsArray = new String[ numReadsList.size() ];
        numReadsList.toArray( numReadsArray );
        options.param("numReads", numReadsArray);
    }

    // Execute the benchmark.
    new Runner(options.build()).run();
}
 
Example 4
Source File: PCJOptimizerBenchmark.java    From rya with Apache License 2.0 3 votes vote down vote up
/**
 * Runs the PCJOptimizer benchmarks.
 * </p>
 * Example command line:
 * <pre>
 * java -cp benchmarks.jar org.apache.rya.benchmark.query.PCJOptimizerBenchmark
 * </pre>
 *
 * @param args - The command line arguments that will be fed into the benchmark.
 * @throws Exception The benchmark could not be run.
 */
public static void main(final String[] args) throws RunnerException, MalformedQueryException, CommandLineOptionException {
    final OptionsBuilder opts = new OptionsBuilder();
    opts.parent( new CommandLineOptions(args) );
    opts.include(PCJOptimizerBenchmark.class.getSimpleName());

    new Runner(opts.build()).run();
}