debuggingtestingand profiling vary considerably depending on the input data--we might have to test each function with multiple sets of input data to cover representative set of cases and then compare the total or average execution times it isn' always convenient to instrument our code to get timingsand so the timeit module provides way of timing code from the command line for exampleto time function_a(from the mymodule py modulewe would enter the following in the consolepython - timeit - - "from mymodule import function_axy"function_a(xy)(as usualfor windowswe must replace python with something like :\python \python exe the - option is for the python interpreter and tells it to load the specified module (in this case timeitand the other options are handled by the timeit module the - option specifies the repetition countthe - option specifies the setupand the last argument is the code to execute and time after the command has finished it prints its results on the consolefor example loopsbest of msec per loop we can easily then repeat the timing for the other two functions so that we can compare them all the cprofile module (or the profile module--we will refer to them both as the cprofile modulecan also be used to compare the performance of functions and methods and unlike the timeit module that just provides raw timingsthe cprofile module shows precisely what is being called and how long each call takes here' the code we would use to compare the same three functions as beforeif __name__ ="__main__"for function in ("function_a""function_b""function_c")cprofile run("for in range( ){ }(xy)format(function)we must put the number of repeats inside the code we pass to the cprofile run(functionbut we don' need to do any setup since the module function uses introspection to find the functions and variables we want to use there is no explicit print(statement since by default the cprofile run(function prints its output on the console here are the results for all the functions (with some irrelevant lines omitted and slightly reformatted to fit the page) function calls in cpu seconds ncalls tottime percall cumtime percall filename:lineno(function : ( mymodule py: (function_a {built-in method exec function calls in cpu seconds