In order to gain greater fidelity in benchmark outputs, we can designate a specific unit of time, listed here from shortest to longest:
- NANOSECONDS
- MICROSECONDS
- MILLISECONDS
- SECONDS
- MINUTES
- HOURS
- DAYS
In order to make this designation, we simply add the following code to our @Benchmark line:
@Benchmark @BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
In the preceding example, we have designated the average mode and nanoseconds as the time unit.