Skip to content

Instantly share code, notes, and snippets.

@alexandrnikitin
Created November 15, 2017 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandrnikitin/3dbcfa48762c02c6db32655679563644 to your computer and use it in GitHub Desktop.
Save alexandrnikitin/3dbcfa48762c02c6db32655679563644 to your computer and use it in GitHub Desktop.
JMH
package com;
import org.junit.Ignore;
import org.junit.Test;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.profile.GCProfiler;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
@State(Scope.Benchmark)
@Ignore("Benchmark")
public class Benchmark {
private AeroRecordToCookieProfileRecord sut;
@Test
public void run() throws Exception {
Options opt = new OptionsBuilder()
.include(this.getClass().getName() + ".*")
.warmupIterations(3)
.measurementIterations(10)
.threads(1)
.forks(1)
.shouldFailOnError(true)
.shouldDoGC(true)
//.jvmArgs("-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining")
.addProfiler(GCProfiler.class)
.build();
new Runner(opt).run();
}
@Setup
public void setup() throws Exception {
this.sut = ;
}
@Benchmark
public void test(Blackhole bh) {
bh.consume(sut.apply());
}
}
jmh:run -i 20 -wi 20 -f1 -t1 -prof xperfasm .*AlgoBenchmark.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment