import cProfile import pstats import a_wordcloud import bvid import to_allexcel import to_danmu import to_excel def run_all(): a_wordcloud.main() bvid.main() to_allexcel.main() to_danmu.main() to_excel.main() if __name__ == '__main__': profiler = cProfile.Profile() profiler.enable() run_all() profiler.disable() profiler.dump_stats('performance_profile.prof') # 分析结果 with open('performance_report.txt', 'w') as f: ps = pstats.Stats(profiler, stream=f) ps.sort_stats('cumulative') ps.print_stats()