0

Here i'm trying to profile four functions from numstring module

from numstring import * #loading functions to profile
import timeit

def profile_timeit():
     funcs_list = [numbers_string1, numbers_string2, numbers_string3, num_strings4]
     for i in funcs_list:
         for count in [10, 100, 1000, 10000]:
             actuals = timeit.timeit(stmt='i(count)', number=4, 
                      setup='from __main__ import *')
             print "{0} count = {1} \t min = {2} \t actuals = {3}".format(i,count,min(actuals), actuals)
             print "\n"
if __name__ == "__main__":
     profile_timeit()

In the code

  setup =  'from __main__ import *'

I'm trying to load the stament variables to get my job done but some how it fails. Can anybody help...Thanks in advance

coderusher
  • 36
  • 4

1 Answers1

0

If I understood you correctly you want to pass the local names to timeit. Have you tried setup=locals()?

Or alternatively with Python 2.6 and later you should be able to omit setup parameter and have stmt parameter without the quotes (so passing the actual Python objects you want to measure).

Heikki Toivonen
  • 30,964
  • 11
  • 42
  • 44