Files
Toolbox/dev_test_scripts/debug/debug_cloud_timing_probe.js
T
yangxiangyuan e4f84caa23 feat: 重构定投评估工具并优化Cloud工具体验
- 重构市场定投评估逻辑:优先读取本地估值快照,必要时通过探针补抓海外数据,后端接口新增force参数支持强制刷新,更新前后端注释与交互文案
- 优化Cloud工具全链路:
  - 新增运营商登录页地址字段,支持一键复制账号密码并打开对应登录页
  - 缓存密钥派生结果,避免重复阻塞事件循环,提升列表加载性能
  - 完善接口错误处理,新增面板级加载失败提示与自动重试功能
  - 修复云资源代理转发时的Cookie缺失问题
  - 并行加载所有面板数据,优化首屏渲染速度
  - 新增登录按钮样式与错误提示样式
- 新增4个Cloud工具调试脚本,用于性能测试、解密审计、回归验证与加载耗时统计
- 启动定投评估工具的定时调度任务
2026-08-17 16:33:41 +08:00

30 lines
1.5 KiB
JavaScript

// 调试脚本:对指定 BASE 做 cloud 接口顺序+并发耗时复测
// 用法:node dev_test_scripts/debug/debug_cloud_timing_probe.js [base_url]
const BASE = process.argv[2] || 'http://localhost:8976'
const main = async () => {
const r1 = await fetch(BASE + '/go?systemId=Tools-cloud', { redirect: 'manual' })
const loc = r1.headers.get('location')
if (!loc) throw new Error('no location, status=' + r1.status)
await fetch(new URL(loc, BASE), { redirect: 'manual' })
const H = { Cookie: 'cloud_gate=1' }
const t = async n => {
const t0 = Date.now()
const r = await fetch(BASE + n, { headers: H })
await r.text()
return `${String(Date.now() - t0).padStart(5)}ms ${r.status} ${n}`
}
console.log('-- sequential --')
for (const u of ['/api/cloud/operators', '/api/cloud/ecs', '/api/cloud/vas', '/api/cloud/renew', '/api/cloud/notes', '/api/cloud/balance_alerts/status']) {
console.log(await t(u))
}
console.log('-- burst --')
const t0 = Date.now()
const urls = ['/api/cloud/operators', '/api/cloud/ecs', '/api/cloud/vas', '/api/cloud/renew', '/api/cloud/notes', '/api/cloud/balance_alerts/status', '/api/flags']
const rs = await Promise.all(urls.map(u => fetch(BASE + u, { headers: H }).then(async r => { await r.text(); return `${String(Date.now() - t0).padStart(5)}ms ${r.status} ${u}` })))
rs.forEach(x => console.log(x))
console.log('burst total', Date.now() - t0, 'ms')
}
main().catch(e => { console.error('ERR', e.message); process.exit(1) })