Hey guys,
I was just solving some problems at Project Euler and some programs just took too long(those using brute force). So, I want to write a program which estimates the time it will take for the program to display its result. How do I do this? Thanks!!
Calculating runtime in Python
Started by king_koder, Oct 23 2010 10:43 PM
2 replies to this topic
#1
Posted 23 October 2010 - 10:43 PM
|
|
|
#2
Posted 23 October 2010 - 11:14 PM
You can find the algorithmic complexity of the script and calculate the average case scenario it will take to complete the workload.
A simpler and more accurate method would be to calculate the maximum number of searches require for the brute force. Take the example 2^20 maximum searches, every 10,000th loop you can measure the time it took to get there, and if you're half done the max possible searches then you can assume it will take (elapsed time * 2) to finish.
A simpler and more accurate method would be to calculate the maximum number of searches require for the brute force. Take the example 2^20 maximum searches, every 10,000th loop you can measure the time it took to get there, and if you're half done the max possible searches then you can assume it will take (elapsed time * 2) to finish.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#3
Posted 24 October 2010 - 11:03 PM
Thanks, that sounds logical to me. I'll try it out :)
#samrat- http://hashsamrat.blogspot.com


Sign In
Create Account

Back to top









