In JAVA I need help with the coding portion of the following. Command line execution: java cs280a1.hw2.Memory
Fantastic news! We've Found the answer you've been seeking!
Question:
In JAVA I need help with the coding portion of the following.
Command line execution: java cs280a1.hw2.Memory
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 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. 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 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. Page 2 of 5 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. 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 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. Page 2 of 5
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Data set Theory Assume an informational record with one association parent including matches (a, b) where a can't try not to be a parent of b. (a) Write a Datalog demand which gives the graph of...
-
(a) Explain how a limit worth may be tended to at run-time, both in a syntaxtree middle person and in collected code. What is the importance word "settled" already? [3 marks] (b) Give a model program...
-
In Problems 23 34, graph each system of linear inequalities. x - 2y 6 2x - 4y 0
-
Findit Gold Inc. (FGI) was created in 2008 and is 25% owned by Findit Mining Corporation (FMC). FGI's shares trade on the local exchange and its objective is to become a substantial low-cost mineral...
-
Copper-rich copper???beryllium alloys are precipitation hardenable. After consulting the portion of the phase diagram (Figure), do the following: (a) Specify the range of compositions over which...
-
In four-stroke petrol engine: (a) Intake valve closes after top dead center (b) Intake valve closed after bottom dead center (c) Exhaust valve closes after top dead center (d) Exhaust valve closes...
-
Think back to your first hour after awakening this morning. List 15 decision-making opportunities that existed during that hour. After you have done that, mark the decision-making opportunities that...
-
What is the difference between a stack and a queue data structure?
-
You are a student from a very small undergraduate institution, accepted for graduate study in a prestigious university. Your first year is covered by a scholarship. When you arrive, your advisors...
-
You are considering an investment that is going to pay $1,500 a month starting 20 years from today for 15 years. If you can earn an 8 percent return on any investment, compounded monthly, how much at...
-
Discuss in a short paragraph (3-5+ sentences) how the theory of the diffusion of innovation does or does not apply to your communication campaign.
-
Use Strategy D13 from Unit D3 to determine whether each of the following series converges. Name any results or rules that you use. You may use the basic series listed in Theorem D33 from Unit D3. (a)...
-
For the second half of the semester, you will be working in the role of student intern at the Conestoga Consulting Company, does a lot of consulting for Conestoga College and companies near the...
-
Draw the Lewis structures of two possible arrangements of atoms of hypofluorous acid-HOF and HFO.
-
7). Refer to the data below: Great Gun's, Inc. Adjusted Trial Balance December 31 Debit Credit Cash S 16 Accounts Receivable Equipment Accounts Payable Capital Stock Retained Eamings 34 170 S 25 112...
-
The May 2014 revenue and cost information for Houston Outfitters, Inc. follow: Sales Revenue (at standard).............. $ 540,000 Cost of Goods Sold (at standard) ..........341,000 Direct Materials...
-
Jim is fired from his job as a waiter and decides to take an extended trip to Europe. After touring Europe for 3 months, Jim returns to look for a new job as a waiter. Are his job-hunting expenses...
-
Russell (age 50) and Linda (age 45) Long have brought you the following information regarding their income and expenses for the current year. Russell owns and operates a landscaping business called...
-
Leslie and Leon Lazo are married and file a joint return for 2012. Leslie's Social Security number is 466-47-3311 and Leon's is 467-74-4451. They live at 143 Snapdragon Drive, Reno, NV 82102. For...
-
An amorphous material is: (a) Mica (b) Lead (c) Rubber (d) Glass
-
Discuss the application vernier caliper and its method of measurement.
-
In center lathe, cutting tool is fed in ____ directions with reference to the lathe axis.
Study smarter with the SolutionInn App