Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need ASistance with the TODO in test below. Conduct the performance measurements will find the running times in the test report. package cs271.lab.list; import java.util.ArrayList;

Need ASistance with the TODO in test below. 

Conduct the performance measurements will find the running times in the test report.

 package cs271.lab.list; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; public class TestPerformance { // 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) // TODO (optional) refactor to DRY // which of the two lists performs better as the size increases? private final int SIZE = 10; // 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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

Innovative financing

Answered: 1 week ago

Question

What is Centrifugation?

Answered: 1 week ago

Question

To find integral of ?a 2 - x 2

Answered: 1 week ago

Question

To find integral of e 3x sin4x

Answered: 1 week ago

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago