Master of Project Academy: https://bit.ly/3CFqqRl -
Join the DZone community and get the full member experience. Join For Free If you want to benchmark your code, the Java Microbenchmark Harness is the tool of choice. In our example, we will use the refill-rate-limiter project.
Since refill-rate-limiter uses Gradle, we will use the following plugin for Gradle: plugins
... id "me.champeau.gradle.jmh" version "0.5.3"
...
We will place the benchmark in the jmh/java/io/github/resilience4j/ratelimiter folder.
Our benchmark should look like this: package io.github.resilience4j.ratelimiter; import io.github.resilience4j.ratelimiter.internal.RefillRateLimiter;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.profile.GCProfiler;
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.time.Duration;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier; @State(Scope.Benchmark)
@OutputTimeUnit(TimeUnit.MICROSECONDS)...
Master of Project Academy: https://bit.ly/3CFqqRl -