Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MherBaghinyan committed Feb 8, 2019
1 parent 627a493 commit 3704450
Showing 1 changed file with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,48 @@ public static class Initialize {

int iterations = 1000;

int[] array = new int[iterations];
List<Integer> list = new ArrayList<>();
String[] array = new String[iterations];
List<String> list = new ArrayList<>();

int[] intArray = new int[iterations];
List<Integer> integerList = new ArrayList<>();

@Setup(Level.Trial)
public void setUp() {
for (int i = 0; i < iterations; i++) {
array[i] = i;
list.add(i);
array[i] = i + "";
list.add(i + "");

intArray[i] = i;
integerList.add(i);
}
}
}

@Benchmark
public int[] benchmarkArraysSort(ArraySortBenchmark.Initialize state) {
public String[] benchmarkArraysSort(ArraySortBenchmark.Initialize state) {
Arrays.sort(state.array);
return state.array;
}

@Benchmark
public List<Integer> benchmarkCollectionsSort(ArraySortBenchmark.Initialize state) {
public List<String> benchmarkCollectionsSort(ArraySortBenchmark.Initialize state) {
Collections.sort(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 {
Options options = new OptionsBuilder()
.include(ArraySortBenchmark.class.getSimpleName()).threads(1)
Expand Down

0 comments on commit 3704450

Please sign in to comment.