2

I know cProfile can be used like this

python -m cProfile script.py

But suppose I have a packaged application (pip-installable) with an entry_point defined in setup.py, such that I can call the application from the terminal, without explicitly using any .py file. How can I use cProfile in that case?

foxpal
  • 586
  • 4
  • 14

2 Answers2

1

I found the answer in this thread:

python -m cProfile $(which application)
foxpal
  • 586
  • 4
  • 14
0

What if someone is using click for CLI ? It seems not to be working for me.

Update: Actually cProfile requires main, and adding standard

if __name__=="__main__":
    cli()

to mymodule/cli.py program, solved the issue.

Mateusz
  • 1
  • 1