/****************************************************************************** * Compilation: javac SystemSort.java * Execution: java SystemSort n < mobydick.txt * ******************************************************************************/ import java.util.Arrays; public class SystemSort { public static double timeit(int n) { double[] a = new double[n]; for (int i = 0; i < n; i++) a[i] = StdRandom.uniformDouble(0.0, 1.0); Stopwatch timer = new Stopwatch(); Arrays.sort(a); return timer.elapsedTime(); } public static void main(String[] args) { int n = Integer.parseInt(args[0]); for (int i = 0; i < 100; i++) StdOut.println(timeit(n)); } }