jenkins.benchmark.jmh.JmhBenchmark Java Examples

The following examples show how to use jenkins.benchmark.jmh.JmhBenchmark. 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: CascJmhBenchmarkState.java    From configuration-as-code-plugin with MIT License 6 votes vote down vote up
/**
 * Setups the Jenkins instance using configuration as code
 * available through the {@link CascJmhBenchmarkState#getResourcePath()}.
 *
 * @throws ConfiguratorException when unable to configure
 */
@Override
public void setup() throws Exception {
    Class<?> enclosingClass = getEnclosingClass();

    if (!enclosingClass.isAnnotationPresent(JmhBenchmark.class)) {
        throw new IllegalStateException("The enclosing class must be annotated with @JmhBenchmark");
    }

    String config = Objects.requireNonNull(getEnclosingClass().getResource(getResourcePath()),
            "Unable to find YAML config file").toExternalForm();
    try {
        ConfigurationAsCode.get().configure(config);
    } catch (ConfiguratorException e) {
        LOGGER.log(Level.SEVERE, "Unable to configure using configuration as code. Aborting.");
        terminateJenkins();
        throw e; // causes JMH to abort benchmark
    }
}