repo stringlengths 1 191 ⌀ | file stringlengths 23 351 | code stringlengths 0 5.32M | file_length int64 0 5.32M | avg_line_length float64 0 2.9k | max_line_length int64 0 288k | extension_type stringclasses 1 value |
|---|---|---|---|---|---|---|
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/IterationParamsTest.java | /*
* 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.infraparams;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.IterationParams;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.CommandLineOptionException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;
@State(Scope.Benchmark)
public class IterationParamsTest {
Set<IterationParams> set;
@Setup(Level.Iteration)
public void setup() {
set = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<>()));
}
@TearDown(Level.Iteration)
public void verify() {
Assert.assertEquals(1, set.size());
}
@Benchmark
@Threads(4)
public void test(IterationParams params) {
set.add(params);
Fixtures.work();
}
@Test
public void test() throws RunnerException, CommandLineOptionException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.warmupIterations(5)
.warmupTime(TimeValue.seconds(1))
.measurementIterations(5)
.measurementTime(TimeValue.seconds(1))
.forks(1)
.shouldFailOnError(true)
.build();
new Runner(opts).run();
}
}
| 2,815 | 33.765432 | 94 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/infraparams/ThreadParamsTest.java | /*
* 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.infraparams;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.ThreadParams;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.*;
import java.util.Collection;
import java.util.Collections;
import java.util.IdentityHashMap;
@State(Scope.Benchmark)
public class ThreadParamsTest {
Collection<ThreadParams> set;
@Setup(Level.Iteration)
public void setup() {
set = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<>()));
}
@TearDown(Level.Iteration)
public void verify() {
Assert.assertEquals(4, set.size());
}
@Benchmark
@Threads(4)
public void test(ThreadParams params) {
set.add(params);
Fixtures.work();
}
@Test
public void test() throws RunnerException, CommandLineOptionException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.warmupIterations(5)
.warmupTime(TimeValue.seconds(1))
.measurementIterations(5)
.measurementTime(TimeValue.seconds(1))
.forks(1)
.shouldFailOnError(true)
.build();
new Runner(opts).run();
}
}
| 2,642 | 32.884615 | 94 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkBenchOrderTest.java | /*
* Copyright (c) 2005, 2020, 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.interorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@State(Scope.Benchmark)
public class BenchmarkBenchOrderTest {
public static final AtomicInteger TICKER = new AtomicInteger();
private volatile int tickSetInstance;
private volatile int tickSetIteration;
private volatile int tickSetInvocation;
private volatile int tickTearInstance;
private volatile int tickTearIteration;
private volatile int tickTearInvocation;
private volatile int tickRun;
@Setup(Level.Trial)
public void setupInstance() {
tickSetInstance = TICKER.incrementAndGet();
}
@Setup(Level.Iteration)
public void setupIteration() {
tickSetIteration = TICKER.incrementAndGet();
}
@Setup(Level.Invocation)
public void setupInvocation() {
tickSetInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Invocation)
public void tearDownInvocation() {
tickTearInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Iteration)
public void tearDownIteration() {
tickTearIteration = TICKER.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDownInstance() {
tickTearInstance = TICKER.incrementAndGet();
Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration);
Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation);
Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun);
Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation);
Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration);
Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance);
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Threads(1)
public void test() {
tickRun = TICKER.incrementAndGet();
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.syncIterations(false)
.build();
new Runner(opt).run();
}
}
}
| 4,656 | 36.556452 | 114 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/BenchmarkStateOrderTest.java | /*
* Copyright (c) 2005, 2020, 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.interorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class BenchmarkStateOrderTest {
public static final AtomicInteger TICKER = new AtomicInteger();
@State(Scope.Benchmark)
public static class MyState {
private volatile int tickSetInstance;
private volatile int tickSetIteration;
private volatile int tickSetInvocation;
private volatile int tickTearInstance;
private volatile int tickTearIteration;
private volatile int tickTearInvocation;
private volatile int tickRun;
@Setup(Level.Trial)
public void setupInstance() {
tickSetInstance = TICKER.incrementAndGet();
}
@Setup(Level.Iteration)
public void setupIteration() {
tickSetIteration = TICKER.incrementAndGet();
}
@Setup(Level.Invocation)
public void setupInvocation() {
tickSetInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Invocation)
public void tearDownInvocation() {
tickTearInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Iteration)
public void tearDownIteration() {
tickTearIteration = TICKER.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDownInstance() {
tickTearInstance = TICKER.incrementAndGet();
Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration);
Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation);
Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun);
Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation);
Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration);
Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance);
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Threads(1)
public void test(MyState state) {
state.tickRun = TICKER.incrementAndGet();
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.syncIterations(false)
.build();
new Runner(opt).run();
}
}
}
| 4,866 | 37.936 | 118 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupBenchOrderTest.java | /*
* Copyright (c) 2005, 2020, 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.interorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@State(Scope.Group)
public class GroupBenchOrderTest {
public static final AtomicInteger TICKER = new AtomicInteger();
private volatile int tickSetInstance;
private volatile int tickSetIteration;
private volatile int tickSetInvocation;
private volatile int tickTearInstance;
private volatile int tickTearIteration;
private volatile int tickTearInvocation;
private volatile int tickRun;
@Setup(Level.Trial)
public void setupInstance() {
tickSetInstance = TICKER.incrementAndGet();
}
@Setup(Level.Iteration)
public void setupIteration() {
tickSetIteration = TICKER.incrementAndGet();
}
@Setup(Level.Invocation)
public void setupInvocation() {
tickSetInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Invocation)
public void tearDownInvocation() {
tickTearInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Iteration)
public void tearDownIteration() {
tickTearIteration = TICKER.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDownInstance() {
tickTearInstance = TICKER.incrementAndGet();
Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration);
Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation);
Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun);
Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation);
Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration);
Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance);
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Group("T")
public void test() {
tickRun = TICKER.incrementAndGet();
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.syncIterations(false)
.build();
new Runner(opt).run();
}
}
}
| 4,646 | 36.475806 | 114 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/GroupStateOrderTest.java | /*
* Copyright (c) 2005, 2020, 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.interorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class GroupStateOrderTest {
public static final AtomicInteger TICKER = new AtomicInteger();
@State(Scope.Group)
public static class MyState {
private volatile int tickSetInstance;
private volatile int tickSetIteration;
private volatile int tickSetInvocation;
private volatile int tickTearInstance;
private volatile int tickTearIteration;
private volatile int tickTearInvocation;
private volatile int tickRun;
@Setup(Level.Trial)
public void setupInstance() {
tickSetInstance = TICKER.incrementAndGet();
}
@Setup(Level.Iteration)
public void setupIteration() {
tickSetIteration = TICKER.incrementAndGet();
}
@Setup(Level.Invocation)
public void setupInvocation() {
tickSetInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Invocation)
public void tearDownInvocation() {
tickTearInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Iteration)
public void tearDownIteration() {
tickTearIteration = TICKER.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDownInstance() {
tickTearInstance = TICKER.incrementAndGet();
Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration);
Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation);
Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun);
Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation);
Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration);
Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance);
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Group("T")
public void test(MyState state) {
state.tickRun = TICKER.incrementAndGet();
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.syncIterations(false)
.build();
new Runner(opt).run();
}
}
}
| 4,857 | 37.555556 | 118 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadBenchOrderTest.java | /*
* Copyright (c) 2005, 2020, 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.interorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@State(Scope.Thread)
public class ThreadBenchOrderTest {
public static final AtomicInteger TICKER = new AtomicInteger();
private volatile int tickSetInstance;
private volatile int tickSetIteration;
private volatile int tickSetInvocation;
private volatile int tickTearInstance;
private volatile int tickTearIteration;
private volatile int tickTearInvocation;
private volatile int tickRun;
@Setup(Level.Trial)
public void setupInstance() {
tickSetInstance = TICKER.incrementAndGet();
}
@Setup(Level.Iteration)
public void setupIteration() {
tickSetIteration = TICKER.incrementAndGet();
}
@Setup(Level.Invocation)
public void setupInvocation() {
tickSetInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Invocation)
public void tearDownInvocation() {
tickTearInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Iteration)
public void tearDownIteration() {
tickTearIteration = TICKER.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDownInstance() {
tickTearInstance = TICKER.incrementAndGet();
Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration);
Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation);
Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun);
Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation);
Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration);
Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance);
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Threads(1)
public void test() {
tickRun = TICKER.incrementAndGet();
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.syncIterations(false)
.build();
new Runner(opt).run();
}
}
}
| 4,650 | 36.508065 | 114 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/interorder/ThreadStateOrderTest.java | /*
* Copyright (c) 2005, 2020, 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.interorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class ThreadStateOrderTest {
public static final AtomicInteger TICKER = new AtomicInteger();
@State(Scope.Thread)
public static class MyState {
private volatile int tickSetInstance;
private volatile int tickSetIteration;
private volatile int tickSetInvocation;
private volatile int tickTearInstance;
private volatile int tickTearIteration;
private volatile int tickTearInvocation;
private volatile int tickRun;
@Setup(Level.Trial)
public void setupInstance() {
tickSetInstance = TICKER.incrementAndGet();
}
@Setup(Level.Iteration)
public void setupIteration() {
tickSetIteration = TICKER.incrementAndGet();
}
@Setup(Level.Invocation)
public void setupInvocation() {
tickSetInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Invocation)
public void tearDownInvocation() {
tickTearInvocation = TICKER.incrementAndGet();
}
@TearDown(Level.Iteration)
public void tearDownIteration() {
tickTearIteration = TICKER.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDownInstance() {
tickTearInstance = TICKER.incrementAndGet();
Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration);
Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation);
Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun);
Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation);
Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration);
Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance);
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Threads(1)
public void test(MyState state) {
state.tickRun = TICKER.incrementAndGet();
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.syncIterations(false)
.build();
new Runner(opt).run();
}
}
}
| 4,860 | 37.888 | 118 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/InterruptibleInterruptTest.java | /*
* Copyright (c) 2021, Red Hat, Inc. 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.interrupts;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.it.Fixtures;
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;
import org.openjdk.jmh.runner.options.TimeValue;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public class InterruptibleInterruptTest {
@Benchmark
public void test() {
try {
Thread.sleep(5_000);
} catch (InterruptedException e) {
// Harness delivered, just exit.
}
}
@Test
public void invokeAPI() throws RunnerException {
for (Mode m : Mode.values()) {
if (m != Mode.All) continue;
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.mode(m)
.timeout(TimeValue.seconds(1))
.build();
new Runner(opt).run();
}
}
}
| 2,500 | 35.246377 | 76 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/interrupts/NonInterruptibleInterruptTest.java | /*
* Copyright (c) 2021, Red Hat, Inc. 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.interrupts;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.it.Fixtures;
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;
import org.openjdk.jmh.runner.options.TimeValue;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public class NonInterruptibleInterruptTest {
@Benchmark
public void test() {
// This method deliberately does not check interrupt status.
long start = System.currentTimeMillis();
long end = start + 5_000;
while (System.currentTimeMillis() < end) {
Blackhole.consumeCPU(10_000);
}
}
@Test
public void invokeAPI() throws RunnerException {
for (Mode m : Mode.values()) {
if (m != Mode.All) continue;
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.mode(m)
.timeout(TimeValue.seconds(1))
.build();
new Runner(opt).run();
}
}
}
| 2,613 | 36.342857 | 76 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/BenchmarkBenchSetupOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
@State(Scope.Benchmark)
public class BenchmarkBenchSetupOrderTest {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@Setup(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Threads(2)
public void test() {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 4,963 | 30.617834 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/BenchmarkBenchTearDownOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
@State(Scope.Benchmark)
public class BenchmarkBenchTearDownOrderTest {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@TearDown(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Threads(2)
public void test() {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 4,960 | 30.801282 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/BenchmarkStateSetupOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
public class BenchmarkStateSetupOrderTest {
@State(Scope.Benchmark)
public static class MyState {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@Setup(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void test(MyState state) {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 5,218 | 31.823899 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/BenchmarkStateTearDownOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
public class BenchmarkStateTearDownOrderTest {
@State(Scope.Benchmark)
public static class MyState {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@TearDown(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void test(MyState state) {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 5,216 | 31.811321 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchSetupOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.GroupThreads;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
@State(Scope.Group)
public class GroupBenchSetupOrderTest {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@Setup(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Group("T")
@GroupThreads(2)
public void test() {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 5,024 | 30.40625 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupBenchTearDownOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.GroupThreads;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
@State(Scope.Group)
public class GroupBenchTearDownOrderTest {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@TearDown(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Group("T")
@GroupThreads(2)
public void test() {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 5,021 | 30.584906 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateSetupOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
public class GroupStateSetupOrderTest {
@State(Scope.Group)
public static class MyState {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@Setup(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Group("T")
public void test(MyState state) {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 5,269 | 31.530864 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/GroupStateTearDownOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
public class GroupStateTearDownOrderTest {
@State(Scope.Group)
public static class MyState {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@TearDown(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Group("T")
public void test(MyState state) {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 5,266 | 31.714286 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/ThreadBenchSetupOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
@State(Scope.Thread)
public class ThreadBenchSetupOrderTest {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@Setup(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Threads(2)
public void test() {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 4,958 | 30.386076 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/ThreadBenchTearDownOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
@State(Scope.Thread)
public class ThreadBenchTearDownOrderTest {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@TearDown(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@Threads(2)
public void test() {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 4,955 | 30.566879 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/ThreadStateSetupOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
public class ThreadStateSetupOrderTest {
@State(Scope.Thread)
public static class MyState {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@Setup(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@Setup(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@Setup(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@Setup(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void test(MyState state) {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 5,213 | 31.5875 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/intraorder/ThreadStateTearDownOrderTest.java | /*
* Copyright (c) 2005, 2013, 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.intraorder;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Tests if harness executes setup (instance) methods in lexicographical order.
*/
public class ThreadStateTearDownOrderTest {
@State(Scope.Thread)
public static class MyState {
private final AtomicInteger seq = new AtomicInteger();
private int run1, run2, run3, runD;
private int iter1, iter2, iter3, iterD;
private int invoc1, invoc2, invoc3, invocD;
@TearDown(Level.Trial)
public void run1() {
run1 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run3() {
run3 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run2() {
run2 = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void run() {
runD = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration1() {
iter1 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration3() {
iter3 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration2() {
iter2 = seq.incrementAndGet();
}
@TearDown(Level.Iteration)
public void iteration() {
iterD = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation1() {
invoc1 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation3() {
invoc3 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation2() {
invoc2 = seq.incrementAndGet();
}
@TearDown(Level.Invocation)
public void invocation() {
invocD = seq.incrementAndGet();
}
@TearDown(Level.Trial)
public void tearDown() {
Assert.assertTrue("Trial(D) < Trial(1)", runD < run1);
Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2);
Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3);
Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1);
Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2);
Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3);
Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1);
Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2);
Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3);
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void test(MyState state) {
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
}
}
| 5,210 | 31.773585 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/jvmoption/JvmOptionTest.java | /*
* Copyright (c) 2021, 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.jvmoption;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
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;
import org.openjdk.jmh.util.Utils;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class JvmOptionTest {
@Param("")
public String x;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void test_api() throws RunnerException {
Path currentJvm = Paths.get(Utils.getCurrentJvm());
// Construct an alternative path to the JVM to exercise PrintPropertiesMain
Path alternativePathToJvm = currentJvm.getParent().resolve(".").resolve(currentJvm.getFileName());
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.jvm(alternativePathToJvm.toString())
.build();
new Runner(opts).run();
}
}
| 2,556 | 36.602941 | 106 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/Parameters.java | /*
* Copyright (c) 2005, 2014, 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.parameters;
import org.junit.Assert;
import org.openjdk.jmh.runner.BenchmarkList;
import org.openjdk.jmh.runner.BenchmarkListEntry;
import org.openjdk.jmh.runner.format.OutputFormatFactory;
import org.openjdk.jmh.runner.options.VerboseMode;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
public class Parameters {
public static BenchmarkListEntry get(Class<?> klass) {
BenchmarkList list = BenchmarkList.fromFile("target/test-classes" + BenchmarkList.BENCHMARK_LIST);
Set<BenchmarkListEntry> set = list.find(OutputFormatFactory.createFormatInstance(System.out, VerboseMode.EXTRA),
Collections.singletonList(klass.getName().replaceAll("\\$", ".")),
Collections.<String>emptyList());
Assert.assertEquals("The single benchmark exists", 1, set.size());
return set.iterator().next();
}
}
| 2,129 | 43.375 | 120 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/fork/BenchForkTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.fork;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.it.parameters.Parameters;
@Fork(10)
public class BenchForkTest {
@Benchmark
public void bench() {
// do nothing
}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getForks().get());
}
}
| 1,697 | 35.12766 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/fork/BenchMethodForkTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.fork;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.it.parameters.Parameters;
@Fork(20)
public class BenchMethodForkTest {
@Fork(10)
@Benchmark
public void bench() {
// do nothing
}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getForks().get());
}
}
| 1,717 | 34.791667 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/fork/MethodForkTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.fork;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.it.parameters.Parameters;
public class MethodForkTest {
@Fork(10)
@Benchmark
public void bench() {
// do nothing
}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getForks().get());
}
}
| 1,702 | 35.234043 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/BenchmarkGroupThreadsTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.threads;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.it.parameters.Parameters;
@Threads(10)
public class BenchmarkGroupThreadsTest {
@Group("a")
@Benchmark
public void bench1() {
// do nothing
}
@Group("a")
@Benchmark
public void bench2() {
// do nothing
}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getThreads().get());
}
}
| 1,866 | 32.945455 | 101 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/BenchmarkMethodThreadsTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.threads;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.it.parameters.Parameters;
@Threads(20)
public class BenchmarkMethodThreadsTest {
@Threads(10)
@Benchmark
public void bench() {
// do nothing
}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getThreads().get());
}
}
| 1,738 | 35.229167 | 101 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/BenchmarkThreadsTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.threads;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.it.parameters.Parameters;
@Threads(10)
public class BenchmarkThreadsTest {
@Benchmark
public void bench() {
// do nothing
}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getThreads().get());
}
}
| 1,715 | 35.510638 | 101 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/InheritedBenchMethodThreadsTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.threads;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.it.parameters.Parameters;
public class InheritedBenchMethodThreadsTest {
@Threads(20)
public static abstract class AbstractBenchmark {
@Threads(10)
@Benchmark
public void bench() {
// do nothing
}
}
public static class ConcreteBenchmark extends AbstractBenchmark {}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(ConcreteBenchmark.class).getThreads().get());
}
}
| 1,906 | 35.673077 | 109 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/InheritedBenchSubclassThreadsTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.threads;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.it.parameters.Parameters;
public class InheritedBenchSubclassThreadsTest {
public static abstract class AbstractBenchmark {
@Benchmark
public void bench() {
// do nothing
}
}
@Threads(10)
public static class ConcreteBenchmark extends AbstractBenchmark {}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(ConcreteBenchmark.class).getThreads().get());
}
}
| 1,887 | 36.019608 | 109 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/InheritedBenchThreadsTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.threads;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.it.parameters.Parameters;
public class InheritedBenchThreadsTest {
@Threads(10)
public static abstract class AbstractBenchmark {
@Benchmark
public void bench() {
// do nothing
}
}
public static class ConcreteBenchmark extends AbstractBenchmark {}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(ConcreteBenchmark.class).getThreads().get());
}
}
| 1,879 | 35.862745 | 109 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/InheritedMethodThreadsTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.threads;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.it.parameters.Parameters;
public class InheritedMethodThreadsTest {
public static abstract class AbstractBenchmark {
@Threads(10)
@Benchmark
public void bench() {
// do nothing
}
}
public static class ConcreteBenchmark extends AbstractBenchmark {}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(ConcreteBenchmark.class).getThreads().get());
}
}
| 1,884 | 35.960784 | 109 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/parameters/threads/MethodThreadsTest.java | /*
* Copyright (c) 2005, 2014, 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.parameters.threads;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.it.parameters.Parameters;
public class MethodThreadsTest {
@Threads(10)
@Benchmark
public void bench() {
// do nothing
}
@Test
public void test() {
Assert.assertEquals(Integer.valueOf(10), Parameters.get(this.getClass()).getThreads().get());
}
}
| 1,716 | 35.531915 | 101 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/BenchmarkBenchParamSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
@State(Scope.Benchmark)
public class BenchmarkBenchParamSequenceTest {
@Param({"1", "2", "3"})
public int x;
@Param({"a", "b", "c"})
public String y;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,342 | 34.946237 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/BenchmarkStateParamSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
public class BenchmarkStateParamSequenceTest {
@State(Scope.Benchmark)
public static class MyState {
@Param({"1", "2", "3"})
public int x;
@Param({"a", "b", "c"})
public String y;
}
@Benchmark
public void test(MyState s) {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,411 | 34.915789 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/CollidingParamsTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.it.Fixtures;
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;
import org.openjdk.jmh.runner.options.TimeValue;
public class CollidingParamsTest {
@State(Scope.Benchmark)
public static class Benchmark1 {
@Param("1")
private int x;
@Benchmark
public void test() {
}
}
@State(Scope.Benchmark)
public static class Benchmark2 {
@Param("2")
private int x;
@Benchmark
public void test() {
}
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.warmupIterations(1)
.warmupTime(TimeValue.milliseconds(100))
.measurementIterations(1)
.measurementTime(TimeValue.milliseconds(100))
.forks(1)
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Assert.assertEquals(4, new Runner(opts).run().size());
}
}
| 2,703 | 32.382716 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyLeadingStringParamTest.java | /*
* Copyright (c) 2005, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class EmptyLeadingStringParamTest {
@Param({"", "val"})
public String x;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void test_ann() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Collection<RunResult> res = new Runner(opts).run();
Set<String> actualP = new HashSet<>();
for (RunResult r : res) {
actualP.add(r.getParams().getParam("x"));
}
Assert.assertEquals(2, actualP.size());
Assert.assertTrue(actualP.contains("val"));
Assert.assertTrue(actualP.contains(""));
}
@Test
public void test_api() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "", "val")
.build();
Collection<RunResult> res = new Runner(opts).run();
Set<String> actualP = new HashSet<>();
for (RunResult r : res) {
actualP.add(r.getParams().getParam("x"));
}
Assert.assertEquals(2, actualP.size());
Assert.assertTrue(actualP.contains("val"));
Assert.assertTrue(actualP.contains(""));
}
}
| 3,297 | 33 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyMiddleStringParamTest.java | /*
* Copyright (c) 2005, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class EmptyMiddleStringParamTest {
@Param({"val1", "", "val2"})
public String x;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void test_ann() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Collection<RunResult> res = new Runner(opts).run();
Set<String> actualP = new HashSet<>();
for (RunResult r : res) {
actualP.add(r.getParams().getParam("x"));
}
Assert.assertEquals(3, actualP.size());
Assert.assertTrue(actualP.contains("val1"));
Assert.assertTrue(actualP.contains("val2"));
Assert.assertTrue(actualP.contains(""));
}
@Test
public void test_api() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "val1", "", "val2")
.build();
Collection<RunResult> res = new Runner(opts).run();
Set<String> actualP = new HashSet<>();
for (RunResult r : res) {
actualP.add(r.getParams().getParam("x"));
}
Assert.assertEquals(3, actualP.size());
Assert.assertTrue(actualP.contains("val1"));
Assert.assertTrue(actualP.contains("val2"));
Assert.assertTrue(actualP.contains(""));
}
}
| 3,422 | 33.575758 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyStringParamTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class EmptyStringParamTest {
@Param("")
public String x;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void test_ann() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opts).run();
}
@Test
public void test_api() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "")
.build();
new Runner(opts).run();
}
}
| 2,481 | 33 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EmptyTrailingStringParamTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class EmptyTrailingStringParamTest {
@Param({"val", ""})
public String x;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void test_ann() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Collection<RunResult> res = new Runner(opts).run();
Set<String> actualP = new HashSet<>();
for (RunResult r : res) {
actualP.add(r.getParams().getParam("x"));
}
Assert.assertEquals(2, actualP.size());
Assert.assertTrue(actualP.contains("val"));
Assert.assertTrue(actualP.contains(""));
}
@Test
public void test_api() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "val", "")
.build();
Collection<RunResult> res = new Runner(opts).run();
Set<String> actualP = new HashSet<>();
for (RunResult r : res) {
actualP.add(r.getParams().getParam("x"));
}
Assert.assertEquals(2, actualP.size());
Assert.assertTrue(actualP.contains("val"));
Assert.assertTrue(actualP.contains(""));
}
}
| 3,298 | 33.010309 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumBenchParamImplicitSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class EnumBenchParamImplicitSequenceTest {
@Param({"VALUE_A", "VALUE_B", "VALUE_C"})
public SampleEnumA a;
@Param
public SampleEnumB b;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Assert.assertEquals(3 * 3, new Runner(opts).run().size());
}
@Test
public void constrainedA() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("a", SampleEnumA.VALUE_A.name())
.build();
Assert.assertEquals(1 * 3, new Runner(opts).run().size());
}
@Test
public void constrainedB() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("b", SampleEnumB.VALUE_A.name())
.build();
Assert.assertEquals(1*3, new Runner(opts).run().size());
}
public enum SampleEnumA {
VALUE_A, VALUE_B, VALUE_C
}
public enum SampleEnumB {
VALUE_A, VALUE_B, VALUE_C
}
}
| 3,465 | 33.316832 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
@State(Scope.Thread)
public class EnumParamSequenceTest {
@Param({"VALUE_A", "VALUE_B", "VALUE_C"})
public SampleEnumA a;
@Param({"VALUE_A", "VALUE_B", "VALUE_C"})
public SampleEnumB b;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Assert.assertEquals(3 * 3, new Runner(opts).run().size());
}
@Test
public void constrainedA() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("a", SampleEnumA.VALUE_A.name())
.build();
Assert.assertEquals(1 * 3, new Runner(opts).run().size());
}
@Test
public void constrainedB() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("b", SampleEnumB.VALUE_A.name())
.build();
Assert.assertEquals(1*3, new Runner(opts).run().size());
}
public enum SampleEnumA {
VALUE_A, VALUE_B, VALUE_C
}
public enum SampleEnumB {
VALUE_A, VALUE_B, VALUE_C
}
}
| 3,487 | 33.534653 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumParamToStringOverridingTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
@State(Scope.Thread)
public class EnumParamToStringOverridingTest {
@Param({"VALUE_A", "VALUE_B", "VALUE_C"})
public SampleEnumA a;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void normal() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Assert.assertEquals(3, new Runner(opts).run().size());
}
public enum SampleEnumA {
VALUE_A, VALUE_B, VALUE_C;
@Override
public String toString() {
return name().toLowerCase();
}
}
}
| 2,715 | 34.272727 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EnumStateParamImplicitSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
public class EnumStateParamImplicitSequenceTest {
@State(Scope.Benchmark)
public static class MyState {
@Param({ "VALUE_A", "VALUE_B", "VALUE_C" })
public SampleEnumA a;
@Param
public SampleEnumB b;
}
@Benchmark
public void test(MyState state) {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Assert.assertEquals(3 * 3, new Runner(opts).run().size());
}
@Test
public void constrainedA() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("a", SampleEnumA.VALUE_A.name())
.build();
Assert.assertEquals(1 * 3, new Runner(opts).run().size());
}
@Test
public void constrainedB() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("b", SampleEnumB.VALUE_A.name())
.build();
Assert.assertEquals(1*3, new Runner(opts).run().size());
}
public enum SampleEnumA {
VALUE_A, VALUE_B, VALUE_C
}
public enum SampleEnumB {
VALUE_A, VALUE_B, VALUE_C
}
}
| 3,543 | 33.407767 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/EscapedParamsTest.java | /*
* Copyright (c) 2019, Red Hat, Inc. 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
public class EscapedParamsTest {
@Param("value")
public String param_plain;
@Param("value\n")
public String param_n;
@Param("value\r")
public String param_r;
@Param("value\r\n")
public String param_rn;
@Param("value\n\r")
public String param_nr;
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void test() {
Fixtures.work();
Assert.assertEquals("value", param_plain);
Assert.assertEquals("value\n", param_n);
Assert.assertEquals("value\r", param_r);
Assert.assertEquals("value\r\n", param_rn);
Assert.assertEquals("value\n\r", param_nr);
}
@Test
public void vals() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opts).run();
}
}
| 2,611 | 31.65 | 78 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/GroupBenchParamSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
@State(Scope.Group)
public class GroupBenchParamSequenceTest {
@Param({"1", "2", "3"})
public int x;
@Param({"a", "b", "c"})
public String y;
@Benchmark
@Group("s")
public void test1() {
Fixtures.work();
}
@Benchmark
@Group("s")
public void test2() {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c" });
}
}
| 3,483 | 33.49505 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/GroupStateParamSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
public class GroupStateParamSequenceTest {
@State(Scope.Group)
public static class MyState {
@Param({"1", "2", "3"})
public int x;
@Param({"a", "b", "c"})
public String y;
}
@Benchmark
@Group("s")
public void test1(MyState s) {
Fixtures.work();
}
@Benchmark
@Group("s")
public void test2(MyState s) {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,560 | 33.572816 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/IsolatedParamSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
public class IsolatedParamSequenceTest {
@State(Scope.Benchmark)
public static class MyState {
@Param({"1", "2", "3"})
public int x;
}
@Benchmark
public void test1(MyState s) {
Fixtures.work();
}
@Benchmark
public void test2() {
Fixtures.work();
}
@Test
public void onlyTest1() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()) + ".*test1")
.shouldFailOnError(true)
.build();
Collection<RunResult> run = new Runner(opts).run();
Assert.assertEquals(3, run.size());
}
@Test
public void onlyTest2() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()) + ".*test2")
.shouldFailOnError(true)
.build();
Collection<RunResult> run = new Runner(opts).run();
Assert.assertEquals(1, run.size());
}
}
| 3,134 | 33.833333 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/MultipleParamTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
@State(Scope.Thread)
public class MultipleParamTest {
@Param({"1", "2", "3"})
public int x;
@Param({"4", "5", "6"})
public int y;
@Param({"7", "8", "9"})
public int z;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Assert.assertEquals(3*3*3, new Runner(opts).run().size());
}
}
| 2,595 | 33.613333 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/OverridingParamsTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.it.Fixtures;
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;
import org.openjdk.jmh.runner.options.TimeValue;
public class OverridingParamsTest {
@State(Scope.Benchmark)
public static class Benchmark1 {
@Param("1")
private int x;
@Benchmark
public void test() {
}
}
@State(Scope.Benchmark)
public static class Benchmark2 extends Benchmark1 {
@Param("2")
private int x;
@Benchmark
public void overtest() {
// check that all x parameters set to the same value
Assert.assertEquals("this.x != super.x", this.x, super.x);
}
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.warmupIterations(1)
.warmupTime(TimeValue.milliseconds(100))
.measurementIterations(1)
.measurementTime(TimeValue.milliseconds(100))
.forks(1)
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Assert.assertEquals(6, new Runner(opts).run().size());
}
}
| 2,862 | 33.914634 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/ParamDeclaredOrderTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(0)
@State(Scope.Thread)
public class ParamDeclaredOrderTest {
static int prevV;
@Param({"1", "2", "4", "8", "16", "32", "64"})
public int v;
@Setup(Level.Trial)
public void setup() {
Assert.assertTrue("Running in different VM", prevV != 0);
}
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
public void test() {
Fixtures.work();
Assert.assertTrue(v + " > " + prevV, v > prevV);
}
@TearDown(Level.Trial)
public void tearDown() {
prevV = v;
}
@Test
public void invoke() throws RunnerException {
prevV = -1;
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opt).run();
}
@Test
public void invokeOverride() throws RunnerException {
prevV = -1;
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("128", "1024", "2048")
.build();
new Runner(opt).run();
}
}
| 3,368 | 32.69 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/QuotedParamsTest.java | /*
* Copyright (c) 2019, Red Hat, Inc. 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
public class QuotedParamsTest {
@Param("value")
public String param_plain;
@Param("[value]")
public String param_square;
@Param("{value}")
public String param_curly;
@Param("'value'")
public String param_squote;
@Param("\"value\"")
public String param_dquote;
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void test() {
Fixtures.work();
Assert.assertEquals("value", param_plain);
Assert.assertEquals("[value]", param_square);
Assert.assertEquals("{value}", param_curly);
Assert.assertEquals("'value'", param_squote);
Assert.assertEquals("\"value\"", param_dquote);
}
@Test
public void vals() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opts).run();
}
}
| 2,640 | 32.0125 | 78 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/Shared.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.results.RunResult;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class Shared {
public static void compare(Collection<RunResult> res, int[] xs, String[] ys) {
Set<String> actualPairs = new HashSet<>();
for (RunResult r : res) {
BenchmarkParams params = r.getParams();
actualPairs.add(params.getParam("x") + params.getParam("y"));
}
for (int x : xs) {
for (String y : ys) {
Assert.assertTrue(x + y + " is not found", actualPairs.contains(x + y));
}
}
}
}
| 1,952 | 36.557692 | 88 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/StaticParamSanityTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class StaticParamSanityTest {
@Param({"1", "2", "3"})
public static int x;
@Param({"a", "b", "c"})
public static String y;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,343 | 34.956989 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/ThreadBenchParamSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
@State(Scope.Thread)
public class ThreadBenchParamSequenceTest {
@Param({"1", "2", "3"})
public int x;
@Param({"a", "b", "c"})
public String y;
@Benchmark
public void test() {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,336 | 34.88172 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/ThreadStateParamSequenceTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
public class ThreadStateParamSequenceTest {
@State(Scope.Thread)
public static class MyState {
@Param({"1", "2", "3"})
public int x;
@Param({"a", "b", "c"})
public String y;
}
@Benchmark
public void test(MyState s) {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Collection<RunResult> params = new Runner(opts).run();
Shared.compare(params, new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[] {2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,523 | 34.959184 | 96 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/UTF8ParamsTest.java | /*
* Copyright (c) 2005, 2014, 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.params;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
public class UTF8ParamsTest {
@Param("\uff11000")
String value;
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void test() {
Fixtures.work();
Assert.assertEquals("\uff11000", value);
}
@Test
public void vals() throws RunnerException {
Locale prev = Locale.getDefault();
Locale.setDefault(Locale.ROOT);
try {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
new Runner(opts).run();
} finally {
Locale.setDefault(prev);
}
}
}
| 2,421 | 32.638889 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedSetupDependencyTest.java | /*
* Copyright (c) 2005, 2014, 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.params.nested;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.it.params.Shared;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
@State(Scope.Benchmark)
public class NestedSetupDependencyTest {
@State(Scope.Benchmark)
public static class S1 {
@Param({"1", "2", "3"})
public int x;
}
@State(Scope.Thread)
public static class S2 {
@Param({"a", "b", "c"})
public String y;
@Setup
public void setup(S1 s) {
}
}
@Benchmark
public void bench(S2 s) {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[]{2, 3}, new String[]{"a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,629 | 32.925234 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedSubclassDependencyTest.java | /*
* Copyright (c) 2005, 2014, 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.params.nested;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.it.params.Shared;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
@State(Scope.Benchmark)
public class NestedSubclassDependencyTest {
@State(Scope.Benchmark)
public static class S1 {
@Param({"1", "2", "3"})
public int x;
}
@State(Scope.Thread)
public static class S2 extends S1 {
@Param({"a", "b", "c"})
public String y;
}
@Benchmark
public void bench(S2 s) {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[]{2, 3}, new String[]{"a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,540 | 34.059406 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedSubclassImplicitDependencyTest.java | /*
* Copyright (c) 2005, 2014, 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.params.nested;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.it.params.Shared;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
@State(Scope.Benchmark)
public class NestedSubclassImplicitDependencyTest {
@Param({"1", "2", "3"})
public int x;
@State(Scope.Thread)
public static class S2 extends NestedSubclassImplicitDependencyTest {
@Param({"a", "b", "c"})
public String y;
}
@Benchmark
public void bench(S2 s) {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[]{2, 3}, new String[]{"a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,511 | 34.836735 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/params/nested/NestedTearDownDependencyTest.java | /*
* Copyright (c) 2005, 2014, 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.params.nested;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.it.params.Shared;
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;
import java.util.concurrent.TimeUnit;
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MICROSECONDS)
@Fork(1)
@State(Scope.Benchmark)
public class NestedTearDownDependencyTest {
@State(Scope.Benchmark)
public static class S1 {
@Param({"1", "2", "3"})
public int x;
}
@State(Scope.Thread)
public static class S2 {
@Param({"a", "b", "c"})
public String y;
@TearDown
public void tearDown(S1 s) {
}
}
@Benchmark
public void bench(S2 s) {
Fixtures.work();
}
@Test
public void full() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "a", "b", "c"});
}
@Test
public void constrainedX() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("x", "2", "3")
.build();
Shared.compare(new Runner(opts).run(), new int[]{2, 3}, new String[]{"a", "b", "c"});
}
@Test
public void constrainedY() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.param("y", "b", "c")
.build();
Shared.compare(new Runner(opts).run(), new int[] {1, 2, 3}, new String[] { "b", "c"});
}
}
| 3,641 | 33.037383 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractAsmProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.util.JDKVersion;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
@State(Scope.Thread)
public abstract class AbstractAsmProfilerTest {
private static final int SIZE = 10_000;
private byte[] src, dst;
@Setup
public void setup() {
src = new byte[SIZE];
dst = new byte[SIZE];
}
@Benchmark
public void work() {
// Call something that definitely results in calling a native stub.
// This should work on environments where hsdis is not available.
System.arraycopy(src, 0, dst, 0, SIZE);
}
public static boolean checkDisassembly(String out) {
if (JDKVersion.parseMajor(System.getProperty("java.version")) >= 17) {
// Should always print, since abstract assembler is available
return out.contains("StubRoutines::");
} else {
if (out.contains("StubRoutines::")) {
// hsdis is enabled, good
return true;
} else {
// hsdis is not enabled, okay
return out.contains("<no assembly is recorded, native region>");
}
}
}
}
| 2,573 | 35.253521 | 80 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractHotspotProfilerTest.java | /*
* 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.profilers;
import org.openjdk.jmh.annotations.*;
import java.util.concurrent.TimeUnit;
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(1) // 0 to enable debugging
@Warmup(iterations = 5)
@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.AverageTime)
public class AbstractHotspotProfilerTest {
@Benchmark
public Object alloc() {
return new Object();
}
boolean isHotspotVM() {
String name = System.getProperty("java.vm.name");
return (name.contains("OpenJDK") || name.contains("HotSpot"));
}
}
| 1,823 | 36.22449 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsExternalProfiler.java | /*
* Copyright (c) 2014, 2014, 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.profilers;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.profile.ExternalProfiler;
import org.openjdk.jmh.results.BenchmarkResult;
import org.openjdk.jmh.results.Result;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
public class ChangeJVMOptsExternalProfiler implements ExternalProfiler {
@Override
public Collection<String> addJVMInvokeOptions(BenchmarkParams params) {
return Collections.emptyList();
}
@Override
public Collection<String> addJVMOptions(BenchmarkParams params) {
return Collections.singletonList("-Dkey=" + Math.random());
}
@Override
public void beforeTrial(BenchmarkParams benchmarkParams) {
// intentionally left blank
}
@Override
public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) {
return Collections.emptyList();
}
@Override
public boolean allowPrintOut() {
return true;
}
@Override
public boolean allowPrintErr() {
return true;
}
@Override
public String getDescription() {
return "Changing JVM Opts Integration Test External Profiler";
}
}
| 2,464 | 32.767123 | 108 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ChangeJVMOptsTest.java | /*
* Copyright (c) 2014, 2014, 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.*;
import org.openjdk.jmh.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
public class ChangeJVMOptsTest {
public static final File TMP_FILE = new File(System.getProperty("java.io.tmpdir") + File.separator + "ChangingJVMOpts-list");
@Setup(Level.Trial)
public void setup() {
try {
FileUtils.appendLines(TMP_FILE,
Collections.singleton(ManagementFactory.getRuntimeMXBean().getInputArguments().toString()));
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS)
@Fork(value = 5, warmups = 5)
public void bench() {
// intentionally left blank
}
@Test
public void testExternal_API() throws RunnerException, IOException {
prepare();
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.warmupForks(5)
.forks(5)
.addProfiler(ChangeJVMOptsExternalProfiler.class)
.build();
new Runner(opts).run();
check();
}
@Test
public void testExternal_CLI() throws RunnerException, CommandLineOptionException, IOException {
prepare();
Options opts = new CommandLineOptions("-prof", ChangeJVMOptsExternalProfiler.class.getCanonicalName(), Fixtures.getTestMask(this.getClass()));
new Runner(opts).run();
check();
}
private void prepare() {
TMP_FILE.delete();
}
private void check() throws IOException {
Set<String> lines = new HashSet<>();
for (String line : FileUtils.readAllLines(TMP_FILE)) {
if (!lines.add(line)) {
Assert.fail("Duplicate line: " + line);
}
}
}
}
| 3,582 | 32.801887 | 150 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ClassloadProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.ClassloaderProfiler;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class ClassloadProfilerTest {
// Simplest Dummy class
static final byte[] CLASS = new byte[] {
(byte) 0xca, (byte) 0xfe, (byte) 0xba, (byte) 0xbe,
0x00, 0x00, 0x00, 0x34,
0x00, 0x0a, 0x0a, 0x00, 0x02, 0x00, 0x03, 0x07,
0x00, 0x04, 0x0c, 0x00, 0x05, 0x00, 0x06, 0x01,
0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c,
0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65,
0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e,
0x69, 0x74, 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29,
0x56, 0x07, 0x00, 0x08, 0x01, 0x00, 0x05, 0x44,
0x75, 0x6d, 0x6d, 0x79, 0x01, 0x00, 0x04, 0x43,
0x6f, 0x64, 0x65, 0x00, 0x21, 0x00, 0x07, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x01, 0x00, 0x05, 0x00, 0x06, 0x00, 0x01, 0x00,
0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00,
0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, (byte) 0xb7, 0x00,
0x01, (byte) 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static class MyClassLoader extends ClassLoader {
public Class<?> loadClass(String name) throws ClassNotFoundException {
if (name.equals("Dummy")) {
return defineClass(name, CLASS, 0, CLASS.length, null);
} else {
return super.loadClass(name);
}
}
}
@Benchmark
public Class<?> work() throws Exception {
Fixtures.work();
ClassLoader loader = new MyClassLoader();
return Class.forName("Dummy", true, loader);
}
@Test
public void test() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(ClassloaderProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
double classLoad = ProfilerTestUtils.checkedGet(sr, "·class.load.norm").getScore();
// Allow 5% slack
if (Math.abs(1 - classLoad) > 0.05) {
Assert.fail("Class loading rate is incorrect. Reported by profiler: " + classLoad);
}
}
}
| 4,136 | 39.165049 | 95 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CompilerProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.CompilerProfiler;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class CompilerProfilerTest {
@Benchmark
public void work() {
Fixtures.work();
}
@Test
public void test() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(CompilerProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
double timeTotal = ProfilerTestUtils.checkedGet(sr, "·compiler.time.total").getScore();
double timeProfiled = ProfilerTestUtils.checkedGet(sr, "·compiler.time.profiled").getScore();
if (timeProfiled > timeTotal) {
throw new IllegalStateException("Profiled time is larger than total time. " +
"Total: " + timeTotal + ", Profiled: " + timeProfiled);
}
if (timeProfiled <= 0) {
throw new IllegalStateException("Should have profiled time: " + timeProfiled);
}
if (timeTotal <= 0) {
throw new IllegalStateException("Should have total time: " + timeTotal);
}
}
}
| 3,009 | 37.101266 | 101 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfiler.java | /*
* Copyright (c) 2017, Red Hat Inc. 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.profilers;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.profile.ExternalProfiler;
import org.openjdk.jmh.results.BenchmarkResult;
import org.openjdk.jmh.results.Result;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicInteger;
public class CountingExternalProfiler implements ExternalProfiler {
static final AtomicInteger jvmOpts = new AtomicInteger();
static final AtomicInteger jvmInvokeOpts = new AtomicInteger();
static final AtomicInteger beforeTrial = new AtomicInteger();
static final AtomicInteger afterTrial = new AtomicInteger();
public static void reset() {
jvmOpts.set(0);
jvmInvokeOpts.set(0);
beforeTrial.set(0);
afterTrial.set(0);
}
@Override
public boolean allowPrintErr() {
return true;
}
@Override
public boolean allowPrintOut() {
return true;
}
@Override
public Collection<String> addJVMOptions(BenchmarkParams params) {
jvmOpts.incrementAndGet();
return Collections.emptyList();
}
@Override
public Collection<String> addJVMInvokeOptions(BenchmarkParams params) {
jvmInvokeOpts.incrementAndGet();
return Collections.emptyList();
}
@Override
public void beforeTrial(BenchmarkParams benchmarkParams) {
beforeTrial.incrementAndGet();
}
@Override
public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) {
afterTrial.incrementAndGet();
return Collections.emptyList();
}
@Override
public String getDescription() {
return "Integration Test External Profiler with Stage Counting";
}
}
| 2,989 | 32.222222 | 108 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/CountingExternalProfilerTest.java | /*
* Copyright (c) 2017, Red Hat Inc. 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
public class CountingExternalProfilerTest {
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void bench() {
// intentionally left blank
}
@Test
public void test() throws RunnerException {
for (int warmupForks : new int[]{0, 1, 5}) {
for (int forks : new int[]{1, 5}) {
CountingExternalProfiler.reset();
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(CountingExternalProfiler.class)
.forks(forks)
.warmupForks(warmupForks)
.build();
new Runner(opts).run();
Assert.assertEquals("jvmOpts count is correct for warmupForks = " + warmupForks + ", and forks = " + forks,
warmupForks + forks, CountingExternalProfiler.jvmOpts.get());
Assert.assertEquals("jvmInvokeOpts count is correct for warmupForks = " + warmupForks + ", and forks = " + forks,
warmupForks + forks, CountingExternalProfiler.jvmInvokeOpts.get());
Assert.assertEquals("afterTrial count is correct for warmupForks = " + warmupForks + ", and forks = " + forks,
warmupForks + forks, CountingExternalProfiler.afterTrial.get());
Assert.assertEquals("beforeTrial count is correct for warmupForks = " + warmupForks + ", and forks = " + forks,
warmupForks + forks, CountingExternalProfiler.beforeTrial.get());
}
}
}
}
| 3,427 | 42.948718 | 129 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DTraceAsmProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Test;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.DTraceAsmProfiler;
import org.openjdk.jmh.profile.ProfilerException;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
public class DTraceAsmProfilerTest extends AbstractAsmProfilerTest {
@Test
public void test() throws RunnerException {
try {
new DTraceAsmProfiler("");
} catch (ProfilerException e) {
System.out.println("Profiler is not supported or cannot be enabled, skipping test");
return;
}
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(DTraceAsmProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
String out = ProfilerTestUtils.checkedGet(sr, "·asm").extendedInfo();
if (!checkDisassembly(out)) {
throw new IllegalStateException("Profile does not contain the required frame: " + out);
}
}
}
| 2,577 | 38.060606 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/DuplicateProfilerTest.java | /*
* Copyright (c) 2017, Red Hat Inc. 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.CommandLineOptionException;
import org.openjdk.jmh.runner.options.CommandLineOptions;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.concurrent.TimeUnit;
public class DuplicateProfilerTest {
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void bench() {
// intentionally left blank
}
@Test
public void testInternal_API() {
try {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(ItInternalProfiler.class)
.addProfiler(ItInternalProfiler.class)
.build();
new Runner(opts).run();
Assert.fail("Expected to fail");
} catch (RunnerException e) {
String msg = e.getMessage();
Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler"));
}
}
@Test
public void testExternal_API() {
try {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(ItExternalProfiler.class)
.addProfiler(ItExternalProfiler.class)
.build();
new Runner(opts).run();
Assert.fail("Expected to fail");
} catch (RunnerException e) {
String msg = e.getMessage();
Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler"));
}
}
@Test
public void testInternal_CLI() throws CommandLineOptionException {
try {
Options opts = new CommandLineOptions(
"-prof", ItInternalProfiler.class.getCanonicalName(),
"-prof", ItInternalProfiler.class.getCanonicalName(),
Fixtures.getTestMask(this.getClass()));
new Runner(opts).run();
Assert.fail("Expected to fail");
} catch (RunnerException e) {
String msg = e.getMessage();
Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler"));
}
}
@Test
public void testExternal_CLI() throws CommandLineOptionException {
try {
Options opts = new CommandLineOptions(
"-prof", ItExternalProfiler.class.getCanonicalName(),
"-prof", ItExternalProfiler.class.getCanonicalName(),
Fixtures.getTestMask(this.getClass()));
new Runner(opts).run();
Assert.fail("Expected to fail");
} catch (RunnerException e) {
String msg = e.getMessage();
Assert.assertTrue(msg, msg.contains("Cannot instantiate the same profiler"));
}
}
}
| 4,508 | 37.87069 | 89 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java | /*
* Copyright (c) 2022, Red Hat, Inc. 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.GCProfiler;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
public class GCProfilerAllocRateTest {
@Benchmark
public Object allocate() {
return new byte[1000];
}
@Test
public void testDefault() throws RunnerException {
testWith("");
}
@Test
public void testAlloc() throws RunnerException {
testWith("alloc=true");
}
@Test
public void testAll() throws RunnerException {
testWith("alloc=true;churn=true");
}
private void testWith(String initLine) throws RunnerException {
if (!Fixtures.expectStableThreads()) {
// This test assumes threads survive until the end of run to get their
// allocation data.
return;
}
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(GCProfiler.class, initLine)
.build();
RunResult rr = new Runner(opts).runSingle();
double opsPerSec = rr.getPrimaryResult().getScore();
Map<String, Result> sr = rr.getSecondaryResults();
double allocRateMB = ProfilerTestUtils.checkedGet(sr, "·gc.alloc.rate").getScore();
double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "·gc.alloc.rate.norm").getScore();
double allocRatePrimaryMB = opsPerSec * allocRateNormB / 1024 / 1024;
// Allow 20% slack
if (Math.abs(1 - allocRatePrimaryMB / allocRateMB) > 0.2) {
Assert.fail("Allocation rates disagree. " +
"Reported by profiler: " + allocRateMB +
", computed from primary score: " + allocRatePrimaryMB);
}
}
}
| 3,596 | 35.333333 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerSeparateThreadTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.GCProfiler;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import org.openjdk.jmh.util.JDKVersion;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(value = 1, jvmArgs = {"-Xms1g", "-Xmx1g", "-XX:+UseParallelGC"})
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
public class GCProfilerSeparateThreadTest {
static final int SIZE = 1_000_000;
@Benchmark
public void separateAlloc(Blackhole bh) throws InterruptedException {
Thread t = new Thread(() -> bh.consume(new byte[SIZE]));
t.start();
t.join();
}
@Test
public void testDefault() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(GCProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
double allocRateNormB = ProfilerTestUtils.checkedGet(sr, "·gc.alloc.rate.norm").getScore();
String msg = "Reported by profiler: " + allocRateNormB + ", target: " + SIZE;
// Allow 1% slack
if (accurateProfiler() && (Math.abs(1 - allocRateNormB / SIZE) > 0.01)) {
Assert.fail("Allocation rate failure. Reported by profiler: " + allocRateNormB + ", target: " + SIZE);
}
System.out.println(msg);
}
private boolean accurateProfiler() {
// Change to this version-sensing code after JDK 21 releases:
// return JDKVersion.parseMajor(System.getProperty("java.version")) >= 21;
// Try to sense the existence of the accurate method:
try {
Class.forName("com.sun.management.ThreadMXBean").getMethod("getTotalThreadAllocatedBytes");
return true;
} catch (Exception e) {
// Fall through
}
return false;
}
}
| 3,689 | 37.041237 | 114 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerTest.java | /*
* 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.profilers;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.GCProfiler;
import org.openjdk.jmh.profile.ProfilerException;
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;
import java.util.concurrent.TimeUnit;
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(1) // 0 to enable debugging
public class GCProfilerTest {
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.AverageTime)
public Object allocateObjectNoWarmup() {
return new Object();
}
@Benchmark
@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 2, time = 2, timeUnit = TimeUnit.SECONDS)
@BenchmarkMode(Mode.AverageTime)
public Object allocateObject() {
return new Object();
}
@Benchmark
@Warmup(iterations = 2)
@Measurement(iterations = 5)
@BenchmarkMode(Mode.SingleShotTime)
public Object allocateObjectSingleShot() {
return new Object();
}
@Benchmark
@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 1, time = 2, timeUnit = TimeUnit.SECONDS)
@BenchmarkMode(Mode.SampleTime)
public Object allocateObjectSampleTime() {
return new Object();
}
@Test
public void testDefault() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(GCProfiler.class)
.build();
new Runner(opts).run();
}
@Test
public void testAlloc() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(GCProfiler.class, "alloc=true")
.build();
new Runner(opts).run();
}
@Test
public void testChurn() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(GCProfiler.class, "churn=true;churnWait=1")
.build();
new Runner(opts).run();
}
@Test
public void testAll() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(GCProfiler.class, "alloc=true;churn=true;churnWait=1")
.build();
new Runner(opts).run();
}
}
| 3,957 | 34.657658 | 83 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ItExternalProfiler.java | /*
* Copyright (c) 2014, 2014, 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.profilers;
import org.junit.Assert;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.profile.ExternalProfiler;
import org.openjdk.jmh.results.BenchmarkResult;
import org.openjdk.jmh.results.Result;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
public class ItExternalProfiler implements ExternalProfiler {
@Override
public Collection<String> addJVMInvokeOptions(BenchmarkParams params) {
return Collections.emptyList();
}
@Override
public Collection<String> addJVMOptions(BenchmarkParams params) {
return Collections.emptyList();
}
@Override
public void beforeTrial(BenchmarkParams benchmarkParams) {
// intentionally left blank
}
@Override
public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) {
Assert.assertFalse("Forked VM PID is not 0", pid == 0);
return Collections.emptyList();
}
@Override
public boolean allowPrintOut() {
return true;
}
@Override
public boolean allowPrintErr() {
return true;
}
@Override
public String getDescription() {
return "Integration Test External Profiler";
}
}
| 2,496 | 32.293333 | 108 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ItInternalProfiler.java | /*
* Copyright (c) 2014, 2014, 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.profilers;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.infra.IterationParams;
import org.openjdk.jmh.profile.InternalProfiler;
import org.openjdk.jmh.results.IterationResult;
import org.openjdk.jmh.results.Result;
import java.util.Collection;
import java.util.Collections;
public class ItInternalProfiler implements InternalProfiler {
@Override
public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) {
// intentionally blank
}
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) {
return Collections.emptyList();
}
@Override
public String getDescription() {
return "Integration Test Internal Profiler";
}
}
| 2,076 | 38.188679 | 146 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/JavaFlightRecorderProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.CompilerProfiler;
import org.openjdk.jmh.profile.JavaFlightRecorderProfiler;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class JavaFlightRecorderProfilerTest {
@Benchmark
public void work() {
Fixtures.work();
}
@Test
public void test() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(JavaFlightRecorderProfiler.class)
.build();
new Runner(opts).runSingle();
}
}
| 2,337 | 36.111111 | 76 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfAsmProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Test;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.LinuxPerfAsmProfiler;
import org.openjdk.jmh.profile.ProfilerException;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
public class LinuxPerfAsmProfilerTest extends AbstractAsmProfilerTest {
@Test
public void test() throws RunnerException {
try {
new LinuxPerfAsmProfiler("");
} catch (ProfilerException e) {
System.out.println("Profiler is not supported or cannot be enabled, skipping test");
return;
}
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(LinuxPerfAsmProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
String out = ProfilerTestUtils.checkedGet(sr, "·asm").extendedInfo();
if (!checkDisassembly(out)) {
throw new IllegalStateException("Profile does not contain the required frame: " + out);
}
}
}
| 2,589 | 38.242424 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfC2CProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.LinuxPerfC2CProfiler;
import org.openjdk.jmh.profile.ProfilerException;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class LinuxPerfC2CProfilerTest {
@Benchmark
public void work() {
somethingInTheMiddle();
}
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
public void somethingInTheMiddle() {
Fixtures.work();
}
@Test
public void test() throws RunnerException {
try {
new LinuxPerfC2CProfiler();
} catch (ProfilerException e) {
System.out.println("Profiler is not supported or cannot be enabled, skipping test");
return;
}
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(LinuxPerfC2CProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
String text = ProfilerTestUtils.checkedGet(sr, "·perfc2c").extendedInfo();
Assert.assertNotNull(text);
}
}
| 2,897 | 34.777778 | 96 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.LinuxPerfNormProfiler;
import org.openjdk.jmh.profile.ProfilerException;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class LinuxPerfNormProfilerTest {
@Benchmark
public void work() {
somethingInTheMiddle();
}
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
public void somethingInTheMiddle() {
Blackhole.consumeCPU(1);
}
@Test
public void test() throws RunnerException {
try {
new LinuxPerfNormProfiler("");
} catch (ProfilerException e) {
System.out.println("Profiler is not supported or cannot be enabled, skipping test");
return;
}
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(LinuxPerfNormProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
double instructions = ProfilerTestUtils.checkedGet(sr, "instructions", "instructions:u").getScore();
double cycles = ProfilerTestUtils.checkedGet(sr, "cycles", "cycles:u").getScore();
double branches = ProfilerTestUtils.checkedGet(sr, "branches", "branches:u").getScore();
Assert.assertNotEquals(0D, instructions, 0D);
Assert.assertNotEquals(0D, cycles, 0D);
Assert.assertNotEquals(0D, branches, 0D);
if (branches > instructions) {
throw new IllegalStateException(String.format("Branches (%.2f) larger than instructions (%.3f)", branches, instructions));
}
double ipc = ProfilerTestUtils.checkedGet(sr, "IPC").getScore();
double cpi = ProfilerTestUtils.checkedGet(sr, "CPI").getScore();
Assert.assertNotEquals(0D, ipc, 0D);
Assert.assertNotEquals(0D, cpi, 0D);
}
}
| 3,704 | 37.59375 | 134 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.LinuxPerfAsmProfiler;
import org.openjdk.jmh.profile.LinuxPerfProfiler;
import org.openjdk.jmh.profile.ProfilerException;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class LinuxPerfProfilerTest {
@Benchmark
public void work() {
somethingInTheMiddle();
}
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
public void somethingInTheMiddle() {
Blackhole.consumeCPU(1);
}
@Test
public void test() throws RunnerException {
try {
new LinuxPerfProfiler("");
} catch (ProfilerException e) {
System.out.println("Profiler is not supported or cannot be enabled, skipping test");
return;
}
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(LinuxPerfProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
String msg = ProfilerTestUtils.checkedGet(sr, "·perf").extendedInfo();
if (sr.containsKey("·ipc")) {
double ipc = ProfilerTestUtils.checkedGet(sr, "·ipc").getScore();
double cpi = ProfilerTestUtils.checkedGet(sr, "·cpi").getScore();
Assert.assertNotEquals(0D, ipc, 0D);
Assert.assertNotEquals(0D, cpi, 0D);
}
Assert.assertTrue(msg.contains("cycles"));
Assert.assertTrue(msg.contains("instructions"));
Assert.assertTrue(msg.contains("branches"));
}
}
| 3,412 | 36.097826 | 96 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/MemPoolProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.CompilerProfiler;
import org.openjdk.jmh.profile.MemPoolProfiler;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class MemPoolProfilerTest {
@Benchmark
public void work() {
Fixtures.work();
}
@Test
public void test() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(MemPoolProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
double usedMetaspace = ProfilerTestUtils.checkedGet(sr, "·mempool.Metaspace.used").getScore();
double usedTotal = ProfilerTestUtils.checkedGet(sr, "·mempool.total.used").getScore();
double usedTotalCodeheap = ProfilerTestUtils.checkedGet(sr, "·mempool.total.codeheap.used").getScore();
if (usedMetaspace == 0) {
throw new IllegalStateException("Metaspace used is zero");
}
if (usedTotal == 0) {
throw new IllegalStateException("Total used is zero");
}
if (usedTotalCodeheap == 0) {
throw new IllegalStateException("Total codeheap used is zero");
}
if (usedMetaspace > usedTotal) {
throw new IllegalStateException("Metaspace size is larger than total size. " +
"Total: " + usedTotal + ", Metaspace: " + usedMetaspace);
}
if (usedTotalCodeheap > usedTotal) {
throw new IllegalStateException("Codeheap size is larger than total size. " +
"Total: " + usedTotal + ", Codeheap: " + usedTotalCodeheap);
}
}
}
| 3,487 | 37.32967 | 111 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ProfilerTest.java | /*
* Copyright (c) 2014, 2014, 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.profilers;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.CommandLineOptionException;
import org.openjdk.jmh.runner.options.CommandLineOptions;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.concurrent.TimeUnit;
public class ProfilerTest {
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void bench() {
// intentionally left blank
}
@Test
public void testInternal_API() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(ItInternalProfiler.class)
.build();
new Runner(opts).run();
}
@Test
public void testExternal_API() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(ItExternalProfiler.class)
.build();
new Runner(opts).run();
}
@Test
public void testInternal_CLI() throws RunnerException, CommandLineOptionException {
Options opts = new CommandLineOptions("-prof", ItInternalProfiler.class.getCanonicalName(), Fixtures.getTestMask(this.getClass()));
new Runner(opts).run();
}
@Test
public void testExternal_CLI() throws RunnerException, CommandLineOptionException {
Options opts = new CommandLineOptions("-prof", ItExternalProfiler.class.getCanonicalName(), Fixtures.getTestMask(this.getClass()));
new Runner(opts).run();
}
}
| 3,220 | 37.807229 | 139 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/ProfilerTestUtils.java | /*
* 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.profilers;
import org.openjdk.jmh.results.Result;
import java.util.Arrays;
import java.util.Map;
public class ProfilerTestUtils {
public static Result checkedGet(Map<String, Result> sr, String... names) {
for (String name : names) {
Result r = sr.get(name);
if (r != null) {
return r;
}
}
StringBuilder sb = new StringBuilder();
for (String k : sr.keySet()) {
sb.append(k);
sb.append(" = ");
sb.append(sr.get(k));
sb.append(System.lineSeparator());
}
throw new IllegalStateException("Cannot find the result for " + Arrays.toString(names) + "\". Available entries: " + sb);
}
}
| 1,980 | 35.685185 | 129 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.MemPoolProfiler;
import org.openjdk.jmh.profile.SafepointsProfiler;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(value = 1, jvmArgsAppend = {"-Xms1g", "-Xmx1g"})
public class SafepointsProfilerTest {
@Benchmark
public int[] allocate() {
return new int[1_000_000];
}
@Test
public void test() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(SafepointsProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
double interval = ProfilerTestUtils.checkedGet(sr, "·safepoints.interval").getScore();
double pauseTotal = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause").getScore();
double ttspTotal = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp").getScore();
double pauseCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.count").getScore();
double ttspCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.count").getScore();
Assert.assertNotEquals(0D, pauseTotal, 0D);
Assert.assertNotEquals(0D, ttspTotal, 0D);
Assert.assertNotEquals(0D, pauseCount, 0D);
Assert.assertNotEquals(0D, ttspCount, 0D);
Assert.assertEquals(ttspCount, pauseCount, 0D);
if (interval < 3000) {
throw new IllegalStateException("Interval time is too low. " +
" Interval: " + interval);
}
if (ttspTotal > interval) {
throw new IllegalStateException("TTSP time is larger than interval time. " +
"TTSP: " + ttspTotal + ", Interval: " + interval);
}
if (pauseTotal > interval) {
throw new IllegalStateException("Pause time is larger than interval time. " +
"Pause: " + pauseTotal + ", Interval: " + interval);
}
if (ttspTotal > pauseTotal) {
throw new IllegalStateException("TTSP time is larger than pause time. " +
"TTSP: " + ttspTotal + ", Pause: " + pauseTotal);
}
double lastPause = 0;
double lastTTSP = 0;
for (String suff : new String[] {"0.00", "0.50", "0.90", "0.95", "0.99", "0.999", "0.9999", "1.00"}) {
double curPause = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.p" + suff).getScore();
double curTTSP = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.p" + suff).getScore();
if (curPause < lastPause) {
throw new IllegalStateException("pause.p" + suff + " is not monotonic");
}
if (curTTSP < lastTTSP) {
throw new IllegalStateException("ttsp.p" + suff + " is not monotonic");
}
lastPause = curPause;
lastTTSP = curTTSP;
}
}
}
| 4,744 | 39.905172 | 110 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/StackProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.JavaFlightRecorderProfiler;
import org.openjdk.jmh.profile.StackProfiler;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class StackProfilerTest {
@Benchmark
public void work() {
somethingInTheMiddle();
}
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
public void somethingInTheMiddle() {
Fixtures.work();
}
@Test
public void test() throws RunnerException {
if (Fixtures.isVirtualExecutor()) {
System.out.println("Stack profiler is not reliable with virtual threads");
return;
}
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(StackProfiler.class, "lines=10")
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
String out = ProfilerTestUtils.checkedGet(sr, "·stack").extendedInfo();
if (!out.contains(StackProfilerTest.class.getCanonicalName() + ".somethingInTheMiddle")) {
throw new IllegalStateException("Profile does not contain the required frame: " + out);
}
}
}
| 2,981 | 36.746835 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/WinPerfAsmProfilerTest.java | /*
* Copyright Amazon.com Inc. 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.profilers;
import org.junit.Test;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.profile.ProfilerException;
import org.openjdk.jmh.profile.WinPerfAsmProfiler;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
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;
import java.util.Map;
public class WinPerfAsmProfilerTest extends AbstractAsmProfilerTest {
@Test
public void test() throws RunnerException {
try {
new WinPerfAsmProfiler("");
} catch (ProfilerException e) {
System.out.println("Profiler is not supported or cannot be enabled, skipping test");
return;
}
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(WinPerfAsmProfiler.class)
.build();
RunResult rr = new Runner(opts).runSingle();
Map<String, Result> sr = rr.getSecondaryResults();
String out = ProfilerTestUtils.checkedGet(sr, "·asm").extendedInfo();
if (!checkDisassembly(out)) {
throw new IllegalStateException("Profile does not contain the required frame: " + out);
}
}
}
| 2,581 | 38.121212 | 99 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/AbstractExternalProfiler.java | /*
* 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.profilers.order;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.profile.ExternalProfiler;
import org.openjdk.jmh.results.BenchmarkResult;
import org.openjdk.jmh.results.Result;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
public abstract class AbstractExternalProfiler implements ExternalProfiler {
private final String pfx;
protected long start, stop;
protected AbstractExternalProfiler(String pfx) {
this.pfx = pfx;
}
@Override
public boolean allowPrintErr() {
return true;
}
@Override
public boolean allowPrintOut() {
return true;
}
@Override
public Collection<String> addJVMOptions(BenchmarkParams params) {
return Collections.emptyList();
}
@Override
public Collection<String> addJVMInvokeOptions(BenchmarkParams params) {
return Collections.emptyList();
}
@Override
public void beforeTrial(BenchmarkParams benchmarkParams) {
start = System.nanoTime();
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) {
stop = System.nanoTime();
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
return Arrays.asList(
new ProfilerTimestamp(pfx + "start", start),
new ProfilerTimestamp(pfx + "stop", stop)
);
}
@Override
public String getDescription() {
return "Integration Test External Profiler";
}
}
| 3,084 | 30.804124 | 108 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/AbstractInternalProfiler.java | /*
* 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.profilers.order;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.infra.IterationParams;
import org.openjdk.jmh.profile.InternalProfiler;
import org.openjdk.jmh.results.IterationResult;
import org.openjdk.jmh.results.Result;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
public abstract class AbstractInternalProfiler implements InternalProfiler {
private final String pfx;
protected long start, stop;
protected AbstractInternalProfiler(String pfx) {
this.pfx = pfx;
}
@Override
public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) {
start = System.nanoTime();
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) {
stop = System.nanoTime();
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
return Arrays.asList(
new ProfilerTimestamp(pfx + "start", start),
new ProfilerTimestamp(pfx + "stop", stop)
);
}
@Override
public String getDescription() {
return "Integration Test Internal Profiler";
}
}
| 2,728 | 34.907895 | 146 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ExternalProfiler1.java | /*
* Copyright (c) 2014, 2014, 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.profilers.order;
public class ExternalProfiler1 extends AbstractExternalProfiler {
public ExternalProfiler1() {
super("prof1");
}
}
| 1,389 | 42.4375 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ExternalProfiler2.java | /*
* Copyright (c) 2014, 2014, 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.profilers.order;
public class ExternalProfiler2 extends AbstractExternalProfiler {
public ExternalProfiler2() {
super("prof2");
}
}
| 1,389 | 42.4375 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ExternalProfiler3.java | /*
* Copyright (c) 2014, 2014, 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.profilers.order;
public class ExternalProfiler3 extends AbstractExternalProfiler {
public ExternalProfiler3() {
super("prof3");
}
}
| 1,389 | 42.4375 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/InternalProfiler1.java | /*
* Copyright (c) 2014, 2014, 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.profilers.order;
public class InternalProfiler1 extends AbstractInternalProfiler {
public InternalProfiler1() {
super("prof1");
}
}
| 1,389 | 42.4375 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/InternalProfiler2.java | /*
* Copyright (c) 2014, 2014, 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.profilers.order;
public class InternalProfiler2 extends AbstractInternalProfiler {
public InternalProfiler2() {
super("prof2");
}
}
| 1,389 | 42.4375 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/InternalProfiler3.java | /*
* Copyright (c) 2014, 2014, 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.profilers.order;
public class InternalProfiler3 extends AbstractInternalProfiler {
public InternalProfiler3() {
super("prof3");
}
}
| 1,389 | 42.4375 | 79 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ProfilerOrderTest.java | /*
* Copyright (c) 2014, 2014, 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.profilers.order;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.RunResult;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.CommandLineOptionException;
import org.openjdk.jmh.runner.options.CommandLineOptions;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class ProfilerOrderTest {
@Benchmark
@Warmup(iterations = 0)
@Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public void bench() {
// intentionally left blank
}
@Test
public void testInternal_API() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(InternalProfiler1.class)
.addProfiler(InternalProfiler2.class)
.addProfiler(InternalProfiler3.class)
.build();
runWith(opts);
}
@Test
public void testInternal_CLI() throws RunnerException, CommandLineOptionException {
CommandLineOptions opts = new CommandLineOptions(
Fixtures.getTestMask(this.getClass()),
"-prof", InternalProfiler1.class.getCanonicalName(),
"-prof", InternalProfiler2.class.getCanonicalName(),
"-prof", InternalProfiler3.class.getCanonicalName()
);
runWith(opts);
}
@Test
public void testExternal_API() throws RunnerException {
Options opts = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.addProfiler(ExternalProfiler1.class)
.addProfiler(ExternalProfiler2.class)
.addProfiler(ExternalProfiler3.class)
.build();
runWith(opts);
}
@Test
public void testExternal_CLI() throws RunnerException, CommandLineOptionException {
CommandLineOptions opts = new CommandLineOptions(
Fixtures.getTestMask(this.getClass()),
"-prof", ExternalProfiler1.class.getCanonicalName(),
"-prof", ExternalProfiler2.class.getCanonicalName(),
"-prof", ExternalProfiler3.class.getCanonicalName()
);
runWith(opts);
}
private void runWith(Options opts) throws RunnerException {Collection<RunResult> results = new Runner(opts).run();
for (RunResult r : results) {
Map<String, Result> sec = r.getSecondaryResults();
double prof1start = sec.get("prof1start").getScore();
double prof2start = sec.get("prof2start").getScore();
double prof3start = sec.get("prof3start").getScore();
double prof1stop = sec.get("prof1stop").getScore();
double prof2stop = sec.get("prof2stop").getScore();
double prof3stop = sec.get("prof3stop").getScore();
Assert.assertTrue("start(1) < start(2)", prof1start < prof2start);
Assert.assertTrue("start(2) < start(3)", prof2start < prof3start);
Assert.assertTrue("stop(3) < stop(2)", prof3stop < prof2stop);
Assert.assertTrue("stop(2) < stop(1)", prof2stop < prof1stop);
}
}
}
| 4,894 | 38.796748 | 118 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/order/ProfilerTimestamp.java | /*
* 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.profilers.order;
import org.openjdk.jmh.results.AggregationPolicy;
import org.openjdk.jmh.results.Aggregator;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.ResultRole;
import java.util.Collection;
public class ProfilerTimestamp extends Result<ProfilerTimestamp> {
public ProfilerTimestamp(String label, double ts) {
super(ResultRole.SECONDARY, label, of(ts), "N/A", AggregationPolicy.MAX);
}
@Override
protected Aggregator<ProfilerTimestamp> getThreadAggregator() {
return new LogAggregator();
}
@Override
protected Aggregator<ProfilerTimestamp> getIterationAggregator() {
return new LogAggregator();
}
public static class LogAggregator implements Aggregator<ProfilerTimestamp> {
@Override
public ProfilerTimestamp aggregate(Collection<ProfilerTimestamp> results) {
String label = null;
double d = Double.MIN_VALUE;
for (ProfilerTimestamp r : results) {
label = r.label;
d = Math.max(d, r.getScore());
}
return new ProfilerTimestamp(label, d);
}
}
}
| 2,402 | 36.546875 | 83 | java |
jmh | jmh-master/jmh-core-it/src/test/java/org/openjdk/jmh/it/races/RaceBenchmarkStateInvocationTest.java | /*
* Copyright (c) 2005, 2013, 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.races;
import org.junit.Assert;
import org.junit.Test;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.it.Fixtures;
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;
import java.util.concurrent.TimeUnit;
/**
* Baseline test:
* Checks if assertions are propagated back to integration tests.
*/
public class RaceBenchmarkStateInvocationTest {
@State(Scope.Benchmark)
public static class MyState {
public int value = 2;
@Setup(Level.Invocation)
public void setup() {
Assert.assertEquals("Setup", 2, value);
value = 1;
}
@TearDown(Level.Invocation)
public void tearDown() {
Assert.assertEquals("TearDown", 1, value);
value = 2;
}
}
@Benchmark
@BenchmarkMode(Mode.All)
@Warmup(iterations = 0)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Threads(4)
public void test(MyState state) {
// Useless to test this condition here, intrinsic races.
// Assert.assertEquals("Run", 1, state.value);
Fixtures.work();
}
@Test
public void invokeAPI() throws RunnerException {
for (int c = 0; c < Fixtures.repetitionCount(); c++) {
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.forks(0)
.build();
new Runner(opt).run();
}
}
}
| 3,339 | 34.157895 | 79 | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.