Extend ArrayList fastpath to Collections.sort(List<T>, Comparator<T>).
My original reasons for not extending it were bogus. We can safely cast Object[] to T[] in this case. Also tidy up the benchmark by changing buildList(.. boolean isArrayList) to buildList(.. Class<T extends List<Integer> list. AFTER SortWithComparator_arrayList, arrayListLength=4} 10881.97 ns; σ=64.97 ns @ 3 trials SortWithComparator_arrayList, arrayListLength=16} 33235.73 ns; σ=127.45 ns @ 3 trials SortWithComparator_arrayList, arrayListLength=64} 130317.52 ns; σ=135.31 ns @ 3 trials SortWithComparator_arrayList, arrayListLength=256} 495200.19 ns; σ=1120.86 ns @ 3 trials SortWithComparator_arrayList, arrayListLength=1024} 1990796.02 ns; σ=19151.58 ns @ 6 trials BEFORE SortWithComparator_arrayList, arrayListLength=4} 40030.32 ns; σ=509.60 ns @ 10 trials SortWithComparator_arrayList, arrayListLength=16} 122122.08 ns; σ=182.58 ns @ 3 trials SortWithComparator_arrayList, arrayListLength=64} 457833.87 ns; σ=1311.54 ns @ 3 trials SortWithComparator_arrayList, arrayListLength=256} 1764647.22 ns; σ=35150.74 ns @ 10 trials SortWithComparator_arrayList, arrayListLength=1024} 7127679.90 ns; σ=122546.75 ns @ 10 trials bug: 18821961 Change-Id: I22a18d99598dfacbdc54cf75e38dbc32ab027754
Loading
Please sign in to comment