Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need Help with Conducting the performance measurements to get the running times. R un test and record running times for SIZE = 10, 100, 1000,

Need Help with Conducting the performance measurements to get the running times. Run test and record running times for SIZE = 10, 100, 1000, 10000
 public class TestPerformance { 1 // TODO run test and record running times for SIZE = 10, 100, 1000, 10000, ... // (choose in conjunction with REPS below up to an upper limit where the clock // running time is in the tens of seconds) 2 // TODO which of the two lists performs better as the size increases? private final int SIZE = 10; 3 // TODO choose this value in such a way that you can observe an actual effect // for increasing problem sizes private final int REPS = 1000000; private List arrayList; private List linkedList; @Before public void setUp() throws Exception { arrayList = new ArrayList(SIZE); linkedList = new LinkedList(); for (var i = 0; i < SIZE; i++) { arrayList.add(i); linkedList.add(i); } } @After public void tearDown() throws Exception { arrayList = null; linkedList = null; } @Test public void testLinkedListAddRemove() { for (var r = 0; r < REPS; r++) { linkedList.add(0, 77); linkedList.remove(0); } } @Test public void testArrayListAddRemove() { for (var r = 0; r < REPS; r++) { arrayList.add(0, 77); arrayList.remove(0); } } @Test public void testLinkedListAccess() { var sum = 0L; for (var r = 0; r < REPS; r++) { sum += linkedList.get(r % SIZE); } } @Test public void testArrayListAccess() { var sum = 0L; for (var r = 0; r < REPS; r++) { sum += arrayList.get(r % SIZE); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

how would you have done things differently?

Answered: 1 week ago

Question

What were the reasons for your conversion or resistance?

Answered: 1 week ago

Question

How was their resistance overcome?

Answered: 1 week ago