File tree Expand file tree Collapse file tree
core-java-collections/src/main/java/com/baeldung/performance Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import java .util .concurrent .TimeUnit ;
1010
1111@ BenchmarkMode (Mode .AverageTime )
12- @ OutputTimeUnit (TimeUnit .MICROSECONDS )
12+ @ OutputTimeUnit (TimeUnit .NANOSECONDS )
1313@ Warmup (iterations = 10 )
1414public 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 ();
You can’t perform that action at this time.
0 commit comments