Skip to content

Instantly share code, notes, and snippets.

@yusureabc
Created July 31, 2018 02:25
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 yusureabc/da8c6384e6b87ad14a05c5cb165a3a97 to your computer and use it in GitHub Desktop.
Save yusureabc/da8c6384e6b87ad14a05c5cb165a3a97 to your computer and use it in GitHub Desktop.
测试java代码运行时间
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