Question
1. Devise a small Python program that executes a repetitive task, such as calling the same function multiple times in a loop. Execute this program
1. Devise a small Python program that executes a repetitive task, such as calling the same function multiple times in a loop. Execute this program and record how long it takes to complete. The specifics of the task do not matter. You can try to complete something practical (you can write a function of your choice for example a function to calculate the sum of numbers (this is just an example, do not use it.)) with the sleep() function. 2. Now update the program to execute each task using a separate thread. Record how long it takes to execute. 3. Compare the execution time between the serial and concurrent versions of the program. Calculate the difference in seconds (e.g. it is faster by 5 seconds). Calculate the ratio that the second program is faster than the first program (e.g. it is 2.5x faster). Your program should calculate and display the result, do not count it manually. These calculations may help: difference = serial time - concurrent time ratio = serial time / concurrent time If it turns out that the concurrent version of the program is not faster, perhaps change or manipulate the task so that the serial version is slower than the faster version.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started