I have the following code that I am benchmarking using JMH
package org.example;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class BenchmarkRunner {
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public void bench_Rand() {
List<Integer> pages = IntStream.range(0, 256).boxed().collect(Collectors.toList());
Collections.shuffle(pages);
}
public static void main(String[] args) throws Exception {
org.openjdk.jmh.Main.main(args);
}
}
While the benchmark works, I am wondering about the latency values incurred for importing the libraries in the benchmark code. Is there a way to benchmark the library import together with the code?