2

I'm trying to use Stats() from the pstats module as such:

    p = Profile()
    p.runcall(wrangle_file,input_filename="test.csv",output_file="solution.csv",metrics=True)
    stats = Stats(p)
    stats.strip_dirs()
    stats.sort_stats('cumulative')
    stats.print_stats()

However, when I do print_stats, I'm getting the calls to library functions as well. Is there a way I can filter these to just print the calls to my functions?

lorenzocastillo
  • 985
  • 3
  • 13
  • 24

1 Answers1

4

You can filter modules by passing a module name in the print_stats() function.

Assuming the name of your Python file is my_python.py, you'd do print_stats("my_python").

You can also pass in function names.

DannyDannyDanny
  • 838
  • 9
  • 26
lorenzocastillo
  • 985
  • 3
  • 13
  • 24