perf(分组): 决策47 _group_v2 性能重写,语义零变化提速约7倍

This commit is contained in:
lianjianwei2024
2026-10-13 15:40:59 +08:00
parent 78ffabae84
commit 0c9f9f7185
7 changed files with 111 additions and 63 deletions

View File

@@ -1,24 +0,0 @@
# 一次性 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())