快速排序是线性的?

出于某种原因,测了一下Sun的JDK的qsort,也即Arrays.sort,虽然源码注释中说道:
//The sorting algorithm is a tuned quicksort

但结果出乎意料,对int数组进行排序,性能几乎是线性的,到底是为啥么捏?难道是Java
代码如下:
import java.util.Arrays;

public class SortTest {

    public static void main(String[] args) {
        for (int i = 10000000; i < 1000000000; i += 10000000) {
            sort(i);
        }
    }

    private static void sort(int i) {
        int n[] = new int[i];
        for (int j = 0; j < n.length; j++) {
            n[j] = (int) (Math.random() * Integer.MAX_VALUE);
        }

        long s = System.currentTimeMillis();
        Arrays.sort(n);
        long e = System.currentTimeMillis();
        System.out.print(i + "\t\t");
        System.out.println(e - s);
    }

}

结果如下:可以看出,基本上是线性的。环境:WinXP SP3,JDK1.6.0_13,E8400,4G内存,javac SortTest.java,java -Xmx1024m SortTest
10000000 1610
20000000 3328
30000000 5187
40000000 7031
50000000 8766
60000000 10625
70000000 12578
80000000 14500
90000000 16359
100000000 18250

你可能感兴趣的:(java,jdk,J#,sun)