我试图将pstats模块中的Stats()作为这样的方式使用:
p = Profile()
p.runcall(wrangle_file,input_filename="test.csv",output_file="solution.csv",metrics=True)
stats = Stats(p)
stats.strip_dirs()
stats.sort_stats('cumulative')
stats.print_stats()但是,当我执行print_stats时,也会收到对库函数的调用。有什么方法可以过滤这些函数来打印对我函数的调用吗?
发布于 2016-04-14 22:33:28
您可以通过在print_stats()函数中传递模块名称来过滤模块。
假设您的Python文件名为my_python.py,则可以执行print_stats("my_python")。
您还可以传递函数名。
https://stackoverflow.com/questions/36635179
复制相似问题