Finding Memory Usage, CPU utilization, Execution time for running a python script

For time profiling

  1. cd into the dir that contains example.py (lets call this exampledir).
  2. run python -m cProfile -o example.profile example.py
  3. download RunSnake and unpack it anywhere
  4. cd into the dir where you unpacked RunSnake
  5. run python runsnake.py exampledir/example.profile

For CPU Profiling

  1. Use psutil
    1. create a new psutil.Process with myProcess = psutil.Process(os.getpid())
    2. call myProcess.get_memory_info() or myProcess.get_ext_memory_info() or myProcess.get_memory_percent() as required

For memory profiling

  1. install meliae with easy_install or pip
  2. Add the following lines of code to the top of example.py:

from meliae import scanner # [[source](http://www.vrplumber.com/programming/runsnakerun/)]
scanner.dump_all_objects( filename ) # you can pass a file-handle if you prefer

  1. run runsnakemem fpath, where fpath is the path to the file that you used in the code above.

This should get you a visual memory profiler similar to What you got with RunSnakeRun.

Hope this helps