“Performance” or “response time.” defines how fast an application presents an output once given an input.  Assume you are building an app, and one of the engineers on the team thinks the Sieve of Eratosthenes algorithm will be the bottleneck in satisfying performance requirements.  They have executed the algorithm and set it under test to create a performance baseline. (Please, find below A4.py and primeSieve.py) Run A4.py and report the result from the part 1 section: “X function calls in Y seconds.” After the remainder of the application and main algorithms are written, the engineers set the full application under performance testing, in part 2 of A4.py. Record the result from the part 2 section: “X function calls in Y seconds.”  The method described in this section is to examine performance by making an educated guess on where performance bottlenecks occur before finishing and testing the entire application (or at least a complete portion of a significant function) Was it a good idea? Why or why not? Compose a short performance requirement for the (full) application, Describe why it is essential to write “good” performance requirements and what establishes “good.” *************************************************** A4.Py from primeSieve import * print 'Welcome to Assignment 4\n'print 'Example of print primeSieve(100)\n'print primeSieve(100) print '\nPart 1 - lets do a timing of primeSieve:\n' def full_calculation(x):if isPrime(x):x=x+1return math.sqrt(x)+ math.sin(x)/(x+1) #Part 1 -- Believed to be the critical algorithm#review the cProfile manual page numberOfPrimes = 1000000import cProfile, pstats, StringIOpr = cProfile.Profile()pr.enable() primeSieve(numberOfPrimes) pr.disable()s = StringIO.StringIO()sortby = 'cumulative'ps = pstats.Stats(pr, stream=s).sort_stats(sortby)ps.print_stats()print s.getvalue() print '\nPart 2 - lets do a timing of the (dummy) full calculation:\n'#Part 2 -- The full applicationpr2 = cProfile.Profile()pr2.enable() primes=primeSieve(numberOfPrimes)map(full_calculation, primes) pr2.disable()s2 = StringIO.StringIO()sortby = 'cumulative'ps2 = pstats.Stats(pr2, stream=s2).sort_stats(sortby)ps2.print_stats()print s2.getvalue() *************************************************** primeSieve.py # Prime Number Sieve# http://inventwithpython.com/hacking (BSD Licensed) import syssys.dont_write_bytecode = True import math def isPrime(num):# Returns True if num is a prime number, otherwise False. # Note: Generally, isPrime() is slower than primeSieve(). # all numbers less than 2 are not primeif num < 2:return False # see if num is divisible by any number up to the square root of numfor i in range(2, int(math.sqrt(num)) + 1):if num % i == 0:return Falsereturn True def primeSieve(sieveSize):# Returns a list of prime numbers calculated using# the Sieve of Eratosthenes algorithm. sieve = [True] * sieveSizesieve[0] = False # zero and one are not prime numberssieve[1] = False # create the sievefor i in range(2, int(math.sqrt(sieveSize)) + 1):pointer = i * 2while pointer < sieveSize:sieve[pointer] = Falsepointer += i # compile the list of primesprimes = []for i in range(sieveSize):if sieve[i] == True:primes.append(i) return primes ***************************************************

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

“Performance” or “response time.” defines how fast an application presents an output once given an input.  Assume you are building an app, and one of the engineers on the team thinks the Sieve of Eratosthenes algorithm will be the bottleneck in satisfying performance requirements.  They have executed the algorithm and set it under test to create a performance baseline.

(Please, find below A4.py and primeSieve.py)

  1. Run A4.py and report the result from the part 1 section: “X function calls in Y seconds.” After the remainder of the application and main algorithms are written, the engineers set the full application under performance testing, in part 2 of A4.py.
  2. Record the result from the part 2 section: “X function calls in Y seconds.” 
  3. The method described in this section is to examine performance by making an educated guess on where performance bottlenecks occur
    • before finishing and testing the entire application (or at least a complete portion of a significant function)
    • Was it a good idea? Why or why not?
  4. Compose a short performance requirement for the (full) application, Describe why it is essential to write “good” performance requirements and what establishes “good.”

***************************************************

A4.Py

from primeSieve import *

print 'Welcome to Assignment 4\n'
print 'Example of print primeSieve(100)\n'
print primeSieve(100)

print '\nPart 1 - lets do a timing of primeSieve:\n'

def full_calculation(x):
if isPrime(x):
x=x+1

return math.sqrt(x)+ math.sin(x)/(x+1)

#Part 1 -- Believed to be the critical algorithm
#review the cProfile manual page

numberOfPrimes = 1000000
import cProfile, pstats, StringIO
pr = cProfile.Profile()
pr.enable()

primeSieve(numberOfPrimes)

pr.disable()
s = StringIO.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print s.getvalue()

print '\nPart 2 - lets do a timing of the (dummy) full calculation:\n'
#Part 2 -- The full application
pr2 = cProfile.Profile()
pr2.enable()

primes=primeSieve(numberOfPrimes)
map(full_calculation, primes)

pr2.disable()
s2 = StringIO.StringIO()
sortby = 'cumulative'
ps2 = pstats.Stats(pr2, stream=s2).sort_stats(sortby)
ps2.print_stats()
print s2.getvalue()

***************************************************

primeSieve.py

# Prime Number Sieve
# http://inventwithpython.com/hacking (BSD Licensed)

import sys
sys.dont_write_bytecode = True

import math

def isPrime(num):
# Returns True if num is a prime number, otherwise False.

# Note: Generally, isPrime() is slower than primeSieve().

# all numbers less than 2 are not prime
if num < 2:
return False

# see if num is divisible by any number up to the square root of num
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True


def primeSieve(sieveSize):
# Returns a list of prime numbers calculated using
# the Sieve of Eratosthenes algorithm.

sieve = [True] * sieveSize
sieve[0] = False # zero and one are not prime numbers
sieve[1] = False

# create the sieve
for i in range(2, int(math.sqrt(sieveSize)) + 1):
pointer = i * 2
while pointer < sieveSize:
sieve[pointer] = False
pointer += i

# compile the list of primes
primes = []
for i in range(sieveSize):
if sieve[i] == True:
primes.append(i)

return primes

***************************************************

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY