Python cprofile文件名:lineno get full path

标签 python cprofile

我用 cprofile得到重犯,但是 filename:lineno仅列出文件名,但列出文件路径对于快速打开该路径会更有用。特别是如果不同层次结构中可能存在相同的模块名称。

ncalls    tottime    percall    cumtime    percall    filename:lineno(function)
1         0.000       0.000       3.922    display.py:599 (show)

有没有办法把它变成全路径?

最佳答案

我猜你用“pstats.Stats”类格式化输出,你有:

stats = Stats(profiler)
stats.strip_dirs()  # remove this

关于Python cprofile文件名:lineno get full path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50731065/

相关文章:

python - 如何从 Python 中的 csv 文件生成 JSON?

pythonic 交换 x,y = y,x 不起作用?

python - cProfile 在调用 numba jit 函数时会增加大量开销

python - 我可以使用 -m 标志运行多个模块吗?

python - 我可以通过 pytest 测试运行 line_profiler 吗?

python - Tensorflow - 值错误 : Shape must be rank 1 but is rank 0 for 'ParseExample/ParseExample'

python - Python 中的元组匹配与变量赋值

python - Snakeviz 只显示一个功能

python - 类型错误 : __init__() takes at least 2 arguments (1 given) error

python - 使用 cProfile 在 Python 中分析类的方法?