如何从脚本输出 .cprofile 文件

How to output a .cprofile file from script

我在我的脚本中使用了 cProfiler。我想输出带有结果的 .cprofile 文件。 我想获得人类不可读的输出文件,然后在 snakeviz 中打开它。这可能吗?

我无法使用

python -m cProfile -o program.prof my_program.py

命令,因为我在 gui 模式下使用嵌入在 Autodesk Maya 软件中的 Python 解释器运行脚本。

好的,我问得太早了。我发现:

cProfile.run('function', 'path')

可以做到