import java.util.Random;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;

@Warmup(iterations = 10)
@Measurement(iterations = 5)
@Fork(value = 1)
@State(Scope.Thread)
public class Square {
    public static Random rnd = new Random();

    public double x;

    @Setup
    public void init() {
        x = (double)rnd.nextInt(256);
    }

    @Benchmark
    public void square(Blackhole sink) {
        sink.consume(Math.pow(x, 2.0));
    }
}
