I have: Methods like this:
@GenerateMicroBenchmark
public static void calculateArraySummary(String[] args) {
// create a random data set
/* PROBLEM HERE:
* now I measure not only pool.invoke(finder) time,
* but also generateRandomArray method time
*/
final int[] array = generateRandomArray(1000000);
// submit the task to the pool
final ForkJoinPool pool = new ForkJoinPool(4);
final ArraySummator finder = new ArraySummator(array);
System.out.println(pool.invoke(finder));
}
private static int[] generateRandomArray(int length) {
final int[] array = new int[1000000];
final Random random = new Random();
for (int i = 0; i < array.length; i++) {
array[i] = random.nextInt(100);
}
return array;
}
Problem: I don't want my program take into account time spent by generateRandomArray
method.
Questuin: How can I exclude generateRandomArray
from jmh measurements?