import pstats for f in ["PROF/main_prof_23800.prof", "PROF/combined_all.raw.prof"]: print("=" * 70) print("FILE:", f) print("=" * 70) try: p = pstats.Stats(f) print("--- cumulative top 35 ---") p.sort_stats("cumulative").print_stats(35) print("--- tottime top 35 ---") p.sort_stats("tottime").print_stats(35) except Exception as e: print("ERROR:", e)