title: How can I use the cProfile module to time each funtion in python?
body: <p>I have a program in Python that takes in several command line arguments and uses them in several functions. How can I use cProfile (within my code)to obtain the running time of each function? (I still want the program to run normally when it's done). Yet I can't figure out how, for example I cannot use</p>
  <p><code>cProfile.run('loadBMPImage(sys.argv[1])')</code></p>
  <p>to test the run time of the function loadBMPImage. I cannot use <code>sys.argv[1]</code> as an argument. Any idea how I can use cProfile to test the running time of each function and print to stdout, if each function depends on command line arguments? Also the cProfile must be integrated into the code itself. Thanks</p>