public class SortingTimeTest { public static void main(String[] args) { // TODO 自动生成的方法存根 Stopwatch time = new Stopwatch(); int[] arrays = new int[100000]; long time1; long time2; for (int i = 0;i < arrays.length;i++){ arrays[i] = (int)(Math.random() * 100000); } time1 = time.start(); System.out.println(time1); java.util.Arrays.parallelSort(arrays); time2 = time.stop(); System.out.println( time2); } class Stopwatch { private long startTime ; private long endTime ; java.util.Date date = new java.util.Date(); public Stopwatch(){ startTime = 0; } public long start(){ startTime = date.getTime(); return startTime; } public long stop(){ endTime = date.getTime(); return endTime; } public long getElapsedTime(){ return endTime - startTime; } } }
相关分类