Created
September 17, 2018 08:21
-
-
Save sleepless-se/9a775b657e6c2b8cfdbb8fb5d65fac34 to your computer and use it in GitHub Desktop.
This class for test java process speed.
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
public class SpeedTest { | |
private long start = System.currentTimeMillis(); | |
public static void main(String[] args) { | |
SpeedTest speedTest = new SpeedTest(); | |
// some process | |
speedTest.stopTimer(); | |
} | |
public void resetTimer() { | |
this.start = System.currentTimeMillis(); | |
} | |
public void stopTimer() { | |
long end = System.currentTimeMillis(); | |
long ms = end - this.start; | |
long sec = ms / 1000; | |
long min = sec / 60; | |
System.out.println(ms + " ms"); | |
System.out.println(sec + " sec"); | |
System.out.println(min + " min"); | |
} | |
public void stopAndStart() { | |
stopTimer(); | |
resetTimer(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment