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);
}
Aggregations