# 一次性 profile 脚本(只读分析,决策 46 后方案 B 评估;测完即删,不进生产) # 目标:南屏批次 30 的 _group_v2_output 6.6 秒热点分布 import sys, time, cProfile, pstats, io sys.path.insert(0, r'D:\PricingReview\CostReview\app\server') import api_server as A c = A.conn() t0 = time.time() rows = A._cmp_bills(c, A.TBL['batch'], 30) c.close() print('可比集行数:', len(rows), ' 取数耗时', round(time.time() - t0, 2), 's', flush=True) t0 = time.time() out = A._group_v2_output(rows) print('_group_v2_output 总耗时:', round(time.time() - t0, 2), 's 组数:', out['total'], flush=True) pr = cProfile.Profile() pr.enable() A._group_v2_output(rows) pr.disable() s = io.StringIO() ps = pstats.Stats(pr, stream=s).sort_stats('tottime') ps.print_stats(16) print(s.getvalue())