All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.csp.sentinel.benchmark.RollingNumberBenchmark Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package com.alibaba.csp.sentinel.benchmark;

import java.util.concurrent.TimeUnit;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

/**
 * @author Eric Zhao
 */
@Warmup(iterations = 10)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
public class RollingNumberBenchmark {

    private final HystrixRollingNumber rollingNumber = new HystrixRollingNumber(1000, 10);

    @Benchmark
    @Threads(8)
    public void testMultiThreadUpdate(Blackhole blackhole) {
        blackhole.consume(rollingNumber.getCurrentBucket());
    }

    public static void main(String[] args) throws Exception {
        Options opt = new OptionsBuilder()
            .include(RollingNumberBenchmark.class.getSimpleName())
            .forks(1)
            .build();
        new Runner(opt).run();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy