Files
TransPyC/PROF/_worker_analyze.py
T
2026-08-22 02:35:30 +08:00

24 lines
888 B
Python

# -*- coding: utf-8 -*-
"""临时:分析 worker prof,看翻译计算时间分布"""
import pstats
import glob
files = sorted(glob.glob(r"D:\Users\TermiNexus\Desktop\TransPyC\PROF\worker_prof_*.prof"))
print(f"worker prof 数量: {len(files)}")
rows = []
for f in files:
st = pstats.Stats(f)
# 总时间 = 文件头打印的 in X seconds
total = st.total_tt # tottime 总和
# 找 _translate_file 的 cumtime
tt_file = st.stats.get(('D:\\Users\\TermiNexus\\Desktop\\TransPyC\\lib\\Projectrans\\Phase2Translator.py',
1286, '_translate_file'))
tf_cum = tt_file[3] if tt_file else 0.0
rows.append((tf_cum, total, f))
rows.sort(reverse=True)
print(f"{'worker文件':<45}{'translate_file(s)':>18}{'total_tt(s)':>12}")
for tf_cum, total, f in rows[:20]:
print(f"{f.split('worker_prof_')[-1]:<45}{tf_cum:>18.2f}{total:>12.2f}")