Created
July 31, 2018 02:25
-
-
Save yusureabc/da8c6384e6b87ad14a05c5cb165a3a97 to your computer and use it in GitHub Desktop.
测试java代码运行时间
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
import java.util.*; | |
public class DiffDemo | |
{ | |
public static void main(String[] args) | |
{ | |
try | |
{ | |
long start = System.currentTimeMillis(); | |
System.out.println( new Date() + "\n" ); | |
Thread.sleep( 5 * 60 * 10 ); | |
System.out.println( new Date() + "\n" ); | |
long end = System.currentTimeMillis(); | |
long diff = end - start; | |
System.out.println( "Difference is :" + diff ); | |
} | |
catch ( Exception e ) | |
{ | |
System.out.println( "Got an exception!" ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment