Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ttldtor;
- import org.openjdk.jmh.annotations.Benchmark;
- import org.openjdk.jmh.annotations.BenchmarkMode;
- import org.openjdk.jmh.annotations.Fork;
- import org.openjdk.jmh.annotations.Measurement;
- import org.openjdk.jmh.annotations.Mode;
- import org.openjdk.jmh.annotations.Warmup;
- import java.util.concurrent.TimeUnit;
- /**
- * @author kalin
- * @since 09.02.2018
- */
- public class Runner {
- @Benchmark
- @Fork(value = 1, warmups = 2)
- @Measurement(iterations = 1)
- @BenchmarkMode(Mode.Throughput)
- @Warmup(iterations = 1, timeUnit = TimeUnit.MILLISECONDS)
- public void boxed() {
- Long sum = 0L;
- for (long i = 0; i < Integer.MAX_VALUE; i++) {
- sum += i;
- }
- }
- @Benchmark
- @Fork(value = 1, warmups = 2)
- @Measurement(iterations = 1)
- @BenchmarkMode(Mode.Throughput)
- @Warmup(iterations = 1, timeUnit = TimeUnit.MILLISECONDS)
- public void notBoxed() {
- long sum = 0L;
- for (long i = 0; i < Integer.MAX_VALUE; i++) {
- sum += i;
- }
- }
- public static void main(String[] args) throws Exception {
- org.openjdk.jmh.Main.main(args);
- }
- }
- /*
- # Run complete. Total time: 00:00:52
- Benchmark Mode Cnt Score Error Units
- Runner.boxed thrpt 0,152 ops/s
- Runner.notBoxed thrpt 1,659 ops/s
- Process finished with exit code 0
- */
Add Comment
Please, Sign In to add comment