Files
pricing_review/CostReview/app/tools/_tmp_profile_grp.py
lianjianwei2024 78ffabae84 perf(分组): 类似清单分组结果服务端 LRU 缓存,支持强制重载与后台列收编优化
- 服务端按「数据指纹+规则指纹」缓存 _group_v2_output 结果(LRU 上限 12 批次),大幅缩短大工程重复分组耗时;工作台新增「⟳ 重载」入口可跳过缓存按当前数据与规则重算
- 后台弹框显隐收编为 detLayout 单一写入点,修复组树与价格工具行残留
- 列定义引入 wb 声明式标记,「取消采纳」「备注」列后台剔除,工作台布局为唯一来源
- 目录树新增展开/折叠把手与宽度拖动条;会话页加载挂进度条
- 更新决策台账(决策 44-46),附一次性 profile 脚本
2026-10-13 12:53:31 +08:00

25 lines
821 B
Python

# 一次性 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())