Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions jmh-core-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ questions.
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
Expand All @@ -49,7 +48,7 @@
* Tests if harness favors the iteration count annotations.
*/
@State(Scope.Thread)
public class IterationCountAnnTest {
public class IterationCountAnnTest implements RunnerFactory {

private final AtomicInteger count = new AtomicInteger();

Expand Down Expand Up @@ -78,7 +77,7 @@ public void invokeAPI() throws RunnerException {
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opts).run();
createRunner(opts).run();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
Expand All @@ -47,7 +46,7 @@
* Tests if harness favors the iteration count cmdline parameters.
*/
@State(Scope.Thread)
public class IterationCountCmdTest {
public class IterationCountCmdTest implements RunnerFactory {

private final AtomicInteger count = new AtomicInteger();

Expand Down Expand Up @@ -77,7 +76,7 @@ public void invokeAPI() throws RunnerException {
.measurementTime(TimeValue.milliseconds(100))
.warmupIterations(0)
.build();
new Runner(opt).run();
createRunner(opt).run();
}

}
34 changes: 34 additions & 0 deletions jmh-core-it/src/test/java/org/openjdk/jmh/it/RunnerFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.jmh.it;

import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;

public interface RunnerFactory {
default Runner createRunner(Options opts) {
return new Runner(opts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
Expand All @@ -41,7 +40,7 @@
* Tests if harness had indeed executed different tests in different JVMs.
*/
@BenchmarkMode(Mode.SingleShotTime)
public class SingleShotTest {
public class SingleShotTest implements RunnerFactory {

private static final AtomicInteger test1executed = new AtomicInteger();
private static final AtomicInteger test2executed = new AtomicInteger();
Expand Down Expand Up @@ -69,7 +68,7 @@ public void invokeAPI() throws RunnerException {
.shouldFailOnError(true)
.forks(1)
.build();
new Runner(opt).run();
createRunner(opt).run();
}

@Test
Expand All @@ -79,7 +78,7 @@ public void invokeAPI_1() throws RunnerException {
.shouldFailOnError(true)
.forks(2)
.build();
new Runner(opt).run();
createRunner(opt).run();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
Expand All @@ -42,7 +41,7 @@


@State(Scope.Thread)
public class StackTraceInThrowableTest {
public class StackTraceInThrowableTest implements RunnerFactory {

@Benchmark
@BenchmarkMode(Mode.All)
Expand All @@ -60,7 +59,7 @@ public void invokeAPI() throws RunnerException {
.shouldFailOnError(true)
.jvmArgs("-XX:-StackTraceInThrowable")
.build();
new Runner(opts).run();
createRunner(opts).run();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
Expand All @@ -49,7 +48,7 @@
* Tests if harness honors warmup annotation settings.
*/
@State(Scope.Thread)
public class WarmupIterationCountAnnTest {
public class WarmupIterationCountAnnTest implements RunnerFactory {

private final AtomicInteger count = new AtomicInteger();

Expand Down Expand Up @@ -78,7 +77,7 @@ public void invokeAPI() throws RunnerException {
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
createRunner(opt).run();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
Expand All @@ -47,7 +46,7 @@
* Tests if harness honors warmup command line settings.
*/
@State(Scope.Thread)
public class WarmupIterationCountCmdTest {
public class WarmupIterationCountCmdTest implements RunnerFactory {

private final AtomicInteger count = new AtomicInteger();

Expand Down Expand Up @@ -78,7 +77,7 @@ public void invokeAPI() throws RunnerException {
.measurementIterations(1)
.warmupIterations(3)
.build();
new Runner(opt).run();
createRunner(opt).run();
}


Expand Down