Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In JAVA Command line execution: java cs280a1.hw2.Memory 1.1 Iask 1 The first task involves contrasting the performance of programs with and without caching. In particular,

In JAVA

Command line execution: java cs280a1.hw2.Memory

image text in transcribed

1.1 Iask 1 The first task involves contrasting the performance of programs with and without caching. In particular, you will be working with the volatile keyword in Java. The volatile keyword informs the compiler that the variable should not be cached and accesses should always go to main memory. To profile the impact of caching, you will be contrasting the performance of loops when the loop variable is marked volatile and when the volatile keyword is not used for the loop variable. Your loop will maintain a running total of the addition and subtraction operations using the loop variable. The choice of whether you perform an addition or subtraction to the runningTotal is based on whether the loop variable is odd or even for the given iteration. If the loop variable is even (e.g., 10) then you should add the loop variable to the runningTotal; if the loop variable is odd (e.g., 37) then you should subtract the loop variable from the runningtotal. To cope with potential overflows/underflows runningtotal should be a long variable type. For times calculate the average time taken to perform runningtotal when the loop variable ranges from [0,size>). Produce a short report (450-500 words) with graphs and/or tables describing the observed behavior when using the volatile keyword versus without. 1.2 Task 2: Allocate an array with size size and fill it with random numbers using the seed> to seed the random number generator. To get the most noticeable effect use the Integer type rather than the primitive int type. For times do the following: Calculate the time to access each element in the first 10% of the array and a single random element in the last 10% of the array. Next, calculate the sum of each of the elements accessed and report the following averages: 1. Time to access a single element in the first 10% of the array. 2. Time to access a single random element in the last 10% of the array. 3. Average sum of the elements. Produce a short report (450-500 words) with graphs and/or tables describing the observed behavior when accessing elements at the prescribed portions of the array. 1.3 Task 3: Allocate a TreeSet and LinkedList both with size size and fill both structures with the range of numbers [0, size ). For times do the following: - Calculate a random number in the range [0, size) and time how long the .contains () method takes to find if the element exists in the structure. Report the average time for each of the structures to find if the element exists. Produce a short report (450-500 words) with graphs and/or tables describing the observed behavior when using TreeSet versus a LinkedList

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions