I want to calculate how much CPU time my function takes to execute in Java. Currently I am doing as below.
long startTime = System.currentTimeMillis();
There are a number of profilers (Jprofile, Jprobe, Yourkit) available to analyze such data. And not only this, but much more...(such as memory utilization, thread details, etc.)