def test5(): import profile profile.run("test4()", "prof.txt") import pstats p = pstats.Stats("prof.txt") p.sort_stats("time").print_stats()