Skip to content

Instantly share code, notes, and snippets.

@joaovicente
Last active March 10, 2016 21:37
Show Gist options
  • Select an option

  • Save joaovicente/fcb4b4f9b0832bc8bdc4 to your computer and use it in GitHub Desktop.

Select an option

Save joaovicente/fcb4b4f9b0832bc8bdc4 to your computer and use it in GitHub Desktop.

Revisions

  1. joaovicente revised this gist Mar 10, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion TracyBenchmark.java
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ public class TracyBenchmark {
    @Measurement(iterations = 10, time = 4, timeUnit = TimeUnit.SECONDS)
    @Threads(5)
    @Fork(2)
    public void testMethodA(Blackhole bh) {
    public void testInlineTracy(Blackhole bh) {
    Tracy.setContext(TASK_ID, OPT_ID, COMPONENT);
    Tracy.before(OUTER);
    Tracy.annotate(STATUS_NAME, STATUS_VALUE);
  2. joaovicente created this gist Mar 10, 2016.
    39 changes: 39 additions & 0 deletions TracyBenchmark.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    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 testMethodA(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();
    }
    }