import time import sys import os if "r" in sys.argv: a=time.time() os.system("python Projectrans.py --project TransPyV/project.json --clean --rebuild-includes --clear-cache") b=time.time() print(b-a) import pstats # 读取cprofile二进制文件 stats = pstats.Stats("tpc_tpv.prof") # 按累计时间排序 stats.sort_stats(pstats.SortKey.CUMULATIVE) # 将全部统计信息写入文本文件 with open("./cprofile.txt", "w", encoding="utf-8") as f: stats.stream = f stats.print_stats() # python -m pstats tpc_tpv.prof --sort cumulative --dump cprofile.txt