1.1 Task 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, ). 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 and fill it with random numbers using the 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. Time to access a single random element in the last 10% of the array. 2. 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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question
100%

In JAVA

Command line execution: java cs280a1.hw2.Memory <size> <experiments> <seed>

 

 
1.1 Task 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 <experiments> 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 <experiments> 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 <experiments> 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.
Page 2 of 5
Transcribed Image Text:1.1 Task 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 <experiments> 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 <experiments> 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 <experiments> 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. Page 2 of 5
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education