Last active
March 10, 2016 21:37
-
-
Save joaovicente/fcb4b4f9b0832bc8bdc4 to your computer and use it in GitHub Desktop.
Sample Tracy benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.sample; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.*; | |
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.annotations.Benchmark; | |
import org.openjdk.jmh.infra.Blackhole; | |
import java.util.concurrent.TimeUnit; | |
import com.apm4all.tracy.Tracy; | |
public class TracyBenchmark { | |
static final String TASK_ID = "T-1234567890123456"; | |
static final String OPT_ID = "O-123456"; | |
static final String COMPONENT = "myAwsomeService"; | |
static final String OUTER = "outer"; | |
static final String STATUS_NAME = "status"; | |
static final int STATUS_VALUE = 200; | |
@Benchmark | |
//@BenchmarkMode(Mode.All) | |
@BenchmarkMode(Mode.SampleTime) | |
@OutputTimeUnit(TimeUnit.MICROSECONDS) | |
@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) | |
@Measurement(iterations = 10, time = 4, timeUnit = TimeUnit.SECONDS) | |
@Threads(5) | |
@Fork(2) | |
public void testInlineTracy(Blackhole bh) { | |
Tracy.setContext(TASK_ID, OPT_ID, COMPONENT); | |
Tracy.before(OUTER); | |
Tracy.annotate(STATUS_NAME, STATUS_VALUE); | |
Tracy.after(OUTER); | |
for (String event : Tracy.getEventsAsJson()) { | |
bh.consume(event); | |
} | |
Tracy.clearContext(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment