Jump to content

Calculating runtime in Python

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
king_koder

king_koder

    Newbie

  • Members
  • Pip
  • 7 posts
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!!

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
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.
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.

#3
king_koder

king_koder

    Newbie

  • Members
  • Pip
  • 7 posts
Thanks, that sounds logical to me. I'll try it out :)