title: How to time execution time of a batch of code in Python?
body: <p>I found this question and answer here on StackOverflow.</p>
  
  <p><a href="https://stackoverflow.com/questions/85451/python-time-clock-vs-time-time-accuracy">Python - time.clock() vs. time.time() - accuracy?</a></p>
  
  <p>Here is some code I'm trying to run:</p>
  
  <pre><code>import sys
  import time
  import timeit
  
  if (len(sys.argv) &gt; 1):
    folder_path = sys.argv[1]
    if not os.path.isdir(folder_path):
      print "The folder you provided doesn't exist"    
    else:
      print_console_headers()    
      rename_files_to_title_case(folder_path)
      #start the timer.
      #do some freaky magic here.
      #end the timer.
  
  else:
    print "You must provide a path to a folder."
  
  def print_console_headers():
    print "Renaming files..."
    print "--------------------"
    return
  
  def rename_files_to_title_case():  
    """this is just for testing purposes"""  
    L = []
    for i in range(100):
        L.append(i)
  
  if __name__ == '__main__':
      from timeit import Timer
      t = Timer("test()", "from __main__ import test")
      print t.timeit()
  </code></pre>
  
  <p>How would I give timeit a function with a parameter that's been saved elsewhere?</p>
  
  <p>This is something I've written in Ruby that gave me results in clean code, maybe this helps for suggestions.</p>
  
  <pre><code>start_time = Time.now
  
  folder_path = ARGV[0]
  i = 0
  Dir.glob(folder_path + "/*").sort.each do |f|
      filename = File.basename(f, File.extname(f))
      File.rename(f, folder_path + "/" + filename.gsub(/\b\w/){$&amp;.upcase} + File.extname(f))
      i += 1
  end
  
  puts "Renaming complete."
  puts "The script renamed #{i} file(s) correctly."
  puts "----------"
  puts "Running time is #{Time.now - start_time} seconds"
  </code></pre>