I would recommend using getThreadCpuTime
from ThreadMXBean
(see also https://stackoverflow.com/a/7467299/185031). If you want to measure the execution time of a method, you are most of the time not so much interested in the wall clock, but more on the CPU execution time.