Search in sources :

Example 1 with GraknSystemProperty

use of ai.grakn.GraknSystemProperty in project grakn by graknlabs.

the class BenchmarkTest method newOptionsBuilder.

private ChainedOptionsBuilder newOptionsBuilder() throws Exception {
    String className = getClass().getSimpleName();
    ChainedOptionsBuilder runnerOptions = new OptionsBuilder().include(".*" + className + ".*").detectJvmArgs();
    // We have to pass system properties into the child JVM
    // TODO: This should probably not be necessary
    List<String> jvmArgs = new ArrayList<>();
    for (GraknSystemProperty property : GraknSystemProperty.values()) {
        String value = property.value();
        if (value != null) {
            jvmArgs.add("-D" + property.key() + "=" + value);
        }
    }
    runnerOptions.jvmArgsAppend(jvmArgs.toArray(new String[jvmArgs.size()]));
    if (getWarmupIterations() > 0) {
        runnerOptions.warmupIterations(getWarmupIterations());
    }
    if (getMeasureIterations() > 0) {
        runnerOptions.measurementIterations(getMeasureIterations());
    }
    if (getReportDir() != null) {
        String filePath = getReportDir() + className + ".json";
        File file = new File(filePath);
        if (file.exists()) {
            file.delete();
        } else {
            file.getParentFile().mkdirs();
            file.createNewFile();
        }
        runnerOptions.resultFormat(ResultFormatType.JSON);
        runnerOptions.result(filePath);
    }
    return runnerOptions;
}
Also used : ChainedOptionsBuilder(org.openjdk.jmh.runner.options.ChainedOptionsBuilder) GraknSystemProperty(ai.grakn.GraknSystemProperty) ArrayList(java.util.ArrayList) File(java.io.File) OptionsBuilder(org.openjdk.jmh.runner.options.OptionsBuilder) ChainedOptionsBuilder(org.openjdk.jmh.runner.options.ChainedOptionsBuilder)

Aggregations

GraknSystemProperty (ai.grakn.GraknSystemProperty)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 ChainedOptionsBuilder (org.openjdk.jmh.runner.options.ChainedOptionsBuilder)1 OptionsBuilder (org.openjdk.jmh.runner.options.OptionsBuilder)1