how to randomize test in JMH
J Kinable
j.kinable at gmail.com
Sun Apr 10 15:53:28 UTC 2016
I've got 2 algorithms which I would like to compare. An algorithm takes a
data instance as input and produces a certain result. To do a fair but
thorough comparison, I would like to run my algorithms on several different
data instances. Obviously, to make it a fair comparison, both algorithms
should use the same pool of data instances. How would you create such a
test. I could do the following:
@Benchmark
public void testAlgorithm1(){
for(Instance instance : instances) algorithm1.run(instance);
}
@Benchmark
public void testAlgorithm2(){
for(Instance instance : instances) algorithm2.run(instance);
}
Does this make sense, or would you use a different approach, e.g. use some
of the Setup parameters/annotations?
thanks,
Joris
More information about the jmh-dev
mailing list