Я новичок в JMH и пытаюсь понять, как @ Params применяются во время теста. Вот код, который я использую:
public class BenchmarkMapper
{
@State (Scope.Benchmark)
public static class ExecutionPlan
{
public Source source;
public Mapper mapper;
@Param (
{ "100", "1000", "10000", "100000", "1000000" })
public int iterations;
@Setup (Level.Invocation)
public void setUp()
{
this.source = BenchmarkUtils.createSource();
this.mapper = new Mapper();
}
}
@Benchmark
public Map<Integer, Object> testMap(ExecutionPlan plan)
{
Map<Integer, Object> resultMap = new HashMap<>();
for (int index = plan.iterations; index > 0; index--)
{
resultMap.put(index, plan.mapper.map(plan.source));
}
return resultMap;
}
}
После его запуска я увидел применяемые итерации параметров:
![Parameter Iterations = 100,000](https://i.stack.imgur.com/jgWvy.png)
![Parameter Iterations = 1,000,000](https://i.stack.imgur.com/qm68p.png)
Итак, что влияет на тест, когда я использую эти @ Params ? Какая разница в использовании @ Params или @ Measurements аннотаций?
Заранее спасибо
Джеймс