Skip to content

Instantly share code, notes, and snippets.

@sleepless-se
Created September 17, 2018 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sleepless-se/9a775b657e6c2b8cfdbb8fb5d65fac34 to your computer and use it in GitHub Desktop.
Save sleepless-se/9a775b657e6c2b8cfdbb8fb5d65fac34 to your computer and use it in GitHub Desktop.
This class for test java process speed.
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