Time units

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset