Created
February 4, 2017 02:01
-
-
Save Yuiki/b779fe62c54cbd5e540eec543ce84d7d to your computer and use it in GitHub Desktop.
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
class Timer { | |
private long startNanoTime, endNanoTime = 0L; | |
void start() { | |
this.startNanoTime = System.nanoTime(); | |
} | |
void stop() { | |
if (startNanoTime != 0L) { | |
this.endNanoTime = System.nanoTime(); | |
} else { | |
throw new IllegalStateException(); | |
} | |
} | |
String getResultTimeInMilliseconds() { | |
long resultTime = (endNanoTime - startNanoTime) / 1000000; | |
startNanoTime = 0L; | |
endNanoTime = 0L; | |
return "計測時間:" + resultTime + "ms"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment