Calculate Execution time in Java
Following is the easiest way to find the execution time of a code block:
1. Get the start time before the code block:
long startTime = System.currentTimeMillis();
2. Get the end time after the code block:
long endTime = System.currentTimeMillis();
3. Calculate the time difference:
long secsTaken = (endTime - startTime); // unit is millisecond
4. Convert to required unit (Eg: Second):
long secsTaken =secsTaken / 1000;











