根据需求采用纳秒或微秒为单位 纳秒: long start=System.nanoTime(); for (int i = 0; i < 1000; i++) { } long end=System.nanoTime(); System.out.println("The Run Time Is:"+(end-start)+"ns"); 微秒: long start=System.currentTimeMillis(); for (int i = 0; i < 100000; i++) { } long end=System.currentTimeMillis(); System.out.println("The Run Time Is:"+(end-start)+"ms"); 微秒的另一种方式: Date mydate1 = new Date(); long start = mydate1.getTime(); for (int i = 0; i < 100000; i++) { } Date mydate2 = new Date(); long end = mydate2.getTime(); System.out.println("The Run Time Is:" + (end - start) + "ms");