Created
October 30, 2014 21:08
-
-
Save cmlewis/ab120fbab166257816b1 to your computer and use it in GitHub Desktop.
Create a 'timer' in Java to measure the duration of some code in milliseconds and minutes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the current system time to calculate duration | |
long startTime = System.currentTimeMillis(); | |
// Do logic here | |
// Get the end time and calculate duration | |
long endTime = System.currentTimeMillis(); | |
long durationInMs = endTime - startTime; | |
long durationInMins = durationInMs/60000; | |
logger.debug("This script took " + durationInMs + " ms or " + durationInMins + " minutes to run."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment