Skip to content

Commit 725076b

Browse files
committed
performance tests tune up
1 parent 5dd6d52 commit 725076b

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

‎core-java-collections/src/main/java/com/baeldung/performance/ArrayListBenchmark.java‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.concurrent.TimeUnit;
1010

1111
@BenchmarkMode(Mode.AverageTime)
12-
@OutputTimeUnit(TimeUnit.MICROSECONDS)
12+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
1313
@Warmup(iterations = 10)
1414
public class ArrayListBenchmark {
1515

@@ -63,6 +63,7 @@ public int testIndexOf(ArrayListBenchmark.MyState state) {
6363
public Employee testGet(ArrayListBenchmark.MyState state) {
6464
return state.employeeList.get(state.employeeIndex);
6565
}
66+
6667
@Benchmark
6768
public Employee testVectorGet(ArrayListBenchmark.MyState state) {
6869
return state.employeeVector.get(state.employeeIndex);
@@ -78,14 +79,9 @@ public void testAdd(ArrayListBenchmark.MyState state) {
7879
state.employeeList.add(new Employee(state.iterations + 1, "John"));
7980
}
8081

81-
@Benchmark
82-
public void testAddVector(ArrayListBenchmark.MyState state) {
83-
state.employeeVector.add(new Employee(state.iterations + 1, "John"));
84-
}
85-
8682
public static void main(String[] args) throws Exception {
8783
Options options = new OptionsBuilder()
88-
.include(ArrayListBenchmark.class.getSimpleName()).threads(1)
84+
.include(ArrayListBenchmark.class.getSimpleName()).threads(3)
8985
.forks(1).shouldFailOnError(true)
9086
.shouldDoGC(true)
9187
.jvmArgs("-server").build();

0 commit comments

Comments
 (0)