Python标准库调试和分析cProfile、profile、pstatsOn this pagecProfile、profile、pstats复制为 MarkdowncProfile 是 Python 内置的确定性性能分析器(C 扩展实现,开销小),用来回答「我的代码慢在哪」。如果 cProfile 在您的系统上不可用,请使用纯 Python 版的 profile。 这些统计数据可以通过 pstats 模块格式化为报表。 命令行直接分析脚本