How can I count the time it takes a function to complete in Java? April 3, 2023 by Tarik long start = System.nanoTime(); methodToBeTimed(); long elapsedTime = System.nanoTime() - start;