python - Importing a local variable in a function into timeit -


i need time execution of function across variable amounts of data.

def foo(raw_data):    preprocessed_data = preprocess_data(raw_data)    time = timeit.timer('module.expensive_func(preprocessed_data)', 'import module').timeit() 

however, preprocessed_data not global variable. cannot imported from __main__. local subroutine.

how can import data timeit.timer environment?

pass callable time, rather string. (unfortunately, introduces function call overhead, it's viable when thing time swamps overhead.)

time = timeit.timeit(lambda: module.expensive_func(data)) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -