Calendar calendar = new GregorianCalendar();
long start = calendar.getTimeInMillis();
System.out.println("MILLISECOND Start: " + start);
try{
Thread.sleep(5000);
}catch(InterruptedException e){
System.err.println(e.toString());
}
for (int i=0;i<10000000;i++){ }
Calendar calendar1 = new GregorianCalendar();
long end = calendar1.getTimeInMillis();
long b = end - start;
System.out.println("MILLISECOND: " + end);
System.out.println("运行时间: " + b);
如何计算一段程序的运行时间
最新推荐文章于 2022-10-05 11:18:22 发布