通过代码计算一段程序运行的时间

 1 public class T1 {
 2     public static void main(String[] args) {
 3         long start=System.currentTimeMillis();
 4         long n=0;
 5         while(n<1000000000){
 6             n++;
 7         }
 8         System.out.print("运行时间为:");
 9         long end=System.currentTimeMillis();
10         System.out.println(end-start);
11     }
12 }

结果为:

猜你喜欢

转载自www.cnblogs.com/yushaolin/p/9426042.html
今日推荐