I am having some trouble using the time or timeit functions to determine the runtime of two algorithms within python. So far I have this
def normal(sound):
for s in getSamples(sound):
largest=max(0,getSampleValue(s))
amplification = 32767.0/largest
for s in getSamples(sound):
louder = amplification*getSampleValue(s)
setSampleValue(s,louder)
def onlyMax(sound):
for s in getSamples(sound):
value=getSampleValue(s)
if value>0:
setSampleValue(s,32767)
if value<=0:
setSampleValue(s,-32768)
import time
def timetwoalgorithms(sound):
print time.time("normal(sound)","onlyMax(sound)")
The program should measure the time it takes to run each of the functions then output/print what the runtime of each program was.