more tests
This commit is contained in:
parent
627a493f8f
commit
3704450509
@ -22,30 +22,48 @@ public class ArraySortBenchmark {
|
|||||||
|
|
||||||
int iterations = 1000;
|
int iterations = 1000;
|
||||||
|
|
||||||
int[] array = new int[iterations];
|
String[] array = new String[iterations];
|
||||||
List<Integer> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
|
|
||||||
|
int[] intArray = new int[iterations];
|
||||||
|
List<Integer> integerList = new ArrayList<>();
|
||||||
|
|
||||||
@Setup(Level.Trial)
|
@Setup(Level.Trial)
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
array[i] = i;
|
array[i] = i + "";
|
||||||
list.add(i);
|
list.add(i + "");
|
||||||
|
|
||||||
|
intArray[i] = i;
|
||||||
|
integerList.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public int[] benchmarkArraysSort(ArraySortBenchmark.Initialize state) {
|
public String[] benchmarkArraysSort(ArraySortBenchmark.Initialize state) {
|
||||||
Arrays.sort(state.array);
|
Arrays.sort(state.array);
|
||||||
return state.array;
|
return state.array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public List<Integer> benchmarkCollectionsSort(ArraySortBenchmark.Initialize state) {
|
public List<String> benchmarkCollectionsSort(ArraySortBenchmark.Initialize state) {
|
||||||
Collections.sort(state.list);
|
Collections.sort(state.list);
|
||||||
return state.list;
|
return state.list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
public int[] benchmarkArraysSortInt(ArraySortBenchmark.Initialize state) {
|
||||||
|
Arrays.sort(state.intArray);
|
||||||
|
return state.intArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
public List<Integer> benchmarkCollectionsSortInteger(ArraySortBenchmark.Initialize state) {
|
||||||
|
Collections.sort(state.integerList);
|
||||||
|
return state.integerList;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Options options = new OptionsBuilder()
|
Options options = new OptionsBuilder()
|
||||||
.include(ArraySortBenchmark.class.getSimpleName()).threads(1)
|
.include(ArraySortBenchmark.class.getSimpleName()).threads(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user