title: Using timeit module in Python with function
body: <p>I have created a script in Python to calculate X specified numbers of the prime number sequence, and this works just fine on its own.</p>
  
  <p>However, I am looking to find how long it takes this script to run in the terminal, and I learned from the Internet that the timeit module was the best way to do this.</p>
  
  <p>However, the description on Python's website and other questions concerning this are quite irrelevant to my case.  Here is the code.</p>
  
  <pre><code>P = 2
  Y = 1
  
  def Main(P, Y):
      X = int(raw_input('choose number: '))
      while Y &lt;= X:
          isprime = True
          for x in range(2, P - 1):
              if P % x == 0:
                  isprime = False
          if isprime:
              print P
              Y += 1
          P += 1
  
  Main(P, Y)
  </code></pre>
  
  <p>Basically, how would I use the timeit module in this situation, so that it will print out the numbers in the sequence (as the above code allows it to) and then prints out the time it takes to calculate the specified amount of numbers?</p>
  
  <p>Would it be possible to do this without making large edits to the current code?</p>