java how to time algorithm code example
Example 1: java execution time
long start = System.currentTimeMillis();
class.method();
long time = System.currentTimeMillis() - start;
Example 2: java get excectuon time
long startTime = System.nanoTime();
methodToTime();
long endTime = System.nanoTime();
long duration = (endTime - startTime); //divide by 1000000 to get milliseconds.