The @Param annotation

Report a typo

With how many different values of the letter variable will testMethod() run?

@State(Scope.Benchmark)
public class MyBenchmark {
    @Param({"A", "B", "C", "D"})
    private String letter;
    Map<Intger, String> map;

    @Setup
    public void doSetup() {
        map = new HashMap<>();
        map.put(1, letter);
    }

    @Benchmark
    @BenchmarkMode(Mode.SingleShotTime)
    @Fork(1)
    @Warmup(iterations = 2)
    @Measurement(iterations = 2)
    public int testMethod() {
        System.out.println(map);

        return map.size();
    }
}
Enter a number
___

Create a free account to access the full topic