Question: Measure the time cost (efficiency) of an algorithm to use the computers clock to obtain an actual runtime. Via benchmarking/profiling implement an algorithm that counts
Measure the time cost (efficiency) of an algorithm to use the computers clock to obtain an actual runtime. Via benchmarking/profiling implement an algorithm that counts from 1 to a million, time the algorithm and output the running time to the terminal window. Triple the problem size of this number and repeat this process. After four such increases, output the results of your program. For simplicity, measure the efficiency of the algorithm below.
#Start the algorithm work = 1 for x in range(problemSize): work += 5 work -= 5 #end of algorithm
Console
Problem Size Seconds 1,000,000 0.1028 3,000,000 0.3800 9,000,000 0.9046 27,000,000 2.7337
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
