Search in sources :

Example 1 with SemaphoreBasedRateLimiter

use of io.github.resilience4j.ratelimiter.internal.SemaphoreBasedRateLimiter in project resilience4j by resilience4j.

the class RateLimiterBenchmark method setUp.

@Setup
public void setUp() {
    RateLimiterConfig rateLimiterConfig = RateLimiterConfig.custom().limitForPeriod(Integer.MAX_VALUE).limitRefreshPeriod(Duration.ofNanos(10)).timeoutDuration(Duration.ofSeconds(5)).build();
    semaphoreBasedRateLimiter = new SemaphoreBasedRateLimiter("semaphoreBased", rateLimiterConfig);
    atomicRateLimiter = new AtomicRateLimiter("atomicBased", rateLimiterConfig);
    Supplier<String> stringSupplier = () -> {
        Blackhole.consumeCPU(1);
        return "Hello Benchmark";
    };
    semaphoreGuardedSupplier = RateLimiter.decorateSupplier(semaphoreBasedRateLimiter, stringSupplier);
    atomicGuardedSupplier = RateLimiter.decorateSupplier(atomicRateLimiter, stringSupplier);
}
Also used : SemaphoreBasedRateLimiter(io.github.resilience4j.ratelimiter.internal.SemaphoreBasedRateLimiter) AtomicRateLimiter(io.github.resilience4j.ratelimiter.internal.AtomicRateLimiter) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

AtomicRateLimiter (io.github.resilience4j.ratelimiter.internal.AtomicRateLimiter)1 SemaphoreBasedRateLimiter (io.github.resilience4j.ratelimiter.internal.SemaphoreBasedRateLimiter)1 Setup (org.openjdk.jmh.annotations.Setup)1