我正在尝试使用cprofile对一个相当大的Python项目进行性能分析。 通常我会像这样调用我的Python应用程序作为模块: python -m cabon.apps.detector -i input_image.png 如何在命令行中使用 cProfile?我发现 cProfile 本身是通过 -m 作为模块调用的,那么如何将其与我的 Python 应用程序结合起来,因为我的应用程序也是作为模块调用的?
文件cProfile和profile也可以被调用作为脚本来对另一个脚本进行分析。例如: python -m cProfile [-o 输出文件] [-s 排序顺序] (-m 模块 | myscript.py) 如在文档中所述,我们可以使用额外的-m指定正在分析的模块。首先是cProfile,然后是实际的模块: python -m cProfile -m cabon.apps.detector -i input_image.png