[{"data":1,"prerenderedAt":4004},["ShallowReactive",2],{"content-/blog/code-generation-speed":3,"related-blog":3979},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"keywords":10,"author":11,"date":12,"category":13,"image":14,"body":15,"_type":3973,"_id":3974,"_source":3975,"_file":3976,"_stem":3977,"_extension":3978},"/blog/code-generation-speed","blog",false,"","代码生成速度优化","优化算法，代码生成速度提升 3 倍，导出更快更流畅","代码生成速度优化, Blog, HTMLPAGE","HTMLPAGE","2025-11-26","待分类","/content-images/blog/blog.jpg",{"type":16,"children":17,"toc":3949},"root",[18,26,32,58,64,107,112,173,179,186,219,225,248,254,270,276,284,290,298,304,312,318,323,328,563,568,758,763,771,776,789,794,827,832,840,845,850,855,886,890,895,901,906,919,2653,2658,2741,2746,2759,2765,2778,3081,3086,3128,3133,3139,3160,3848,3853,3882,3887,3925,3930,3943],{"type":19,"tag":20,"props":21,"children":22},"element","p",{},[23],{"type":24,"value":25},"text","本文详细讨论在模板、页面或代码自动生成系统中提升生成速度的原则、测量方法、架构与工程实践，帮助团队在保证正确性与可维护性的前提下显著提升吞吐与响应时间。\n本文详细讨论在模板、页面或代码自动生成系统中提升生成速度的原则、衡量方法、架构与工程实践，帮助团队在保证正确性与可维护性的前提下显著提升吞吐与响应时间。",{"type":19,"tag":27,"props":28,"children":30},"h2",{"id":29},"为什么要关注生成速度",[31],{"type":24,"value":29},{"type":19,"tag":33,"props":34,"children":35},"ul",{},[36,48],{"type":19,"tag":37,"props":38,"children":39},"li",{},[40,46],{"type":19,"tag":41,"props":42,"children":43},"strong",{},[44],{"type":24,"value":45},"用户体验",{"type":24,"value":47},"：编辑器与实时预览场景下，生成延迟直接影响交互流畅性与用户满意度。",{"type":19,"tag":37,"props":49,"children":50},{},[51,56],{"type":19,"tag":41,"props":52,"children":53},{},[54],{"type":24,"value":55},"成本与吞吐",{"type":24,"value":57},"：批量生成（例如活动页批量创建、导出任务）时，生成速度决定单位时间内可完成的任务量，影响资源成本与 SLA。",{"type":19,"tag":27,"props":59,"children":61},{"id":60},"衡量指标kpi",[62],{"type":24,"value":63},"衡量指标（KPI）",{"type":19,"tag":33,"props":65,"children":66},{},[67,77,87,97],{"type":19,"tag":37,"props":68,"children":69},{},[70,75],{"type":19,"tag":41,"props":71,"children":72},{},[73],{"type":24,"value":74},"单次延迟（latency）",{"type":24,"value":76},"：一次生成请求从入队到完成的时长（关注 P50/P95/P99）。",{"type":19,"tag":37,"props":78,"children":79},{},[80,85],{"type":19,"tag":41,"props":81,"children":82},{},[83],{"type":24,"value":84},"吞吐（throughput）",{"type":24,"value":86},"：单位时间内完成的生成任务数（tasks/sec）。",{"type":19,"tag":37,"props":88,"children":89},{},[90,95],{"type":19,"tag":41,"props":91,"children":92},{},[93],{"type":24,"value":94},"并发容量",{"type":24,"value":96},"：在目标延迟内系统可支持的并发任务数。",{"type":19,"tag":37,"props":98,"children":99},{},[100,105],{"type":19,"tag":41,"props":101,"children":102},{},[103],{"type":24,"value":104},"资源效率",{"type":24,"value":106},"：每个任务平均消耗的 CPU、内存与网络带宽。",{"type":19,"tag":27,"props":108,"children":110},{"id":109},"常见瓶颈与诊断方法",[111],{"type":24,"value":109},{"type":19,"tag":113,"props":114,"children":115},"ol",{},[116,143,153,163],{"type":19,"tag":37,"props":117,"children":118},{},[119,124,126,133,135,141],{"type":19,"tag":41,"props":120,"children":121},{},[122],{"type":24,"value":123},"CPU/内存",{"type":24,"value":125},"：生成过程包含模板渲染、语法转换或图片处理等 CPU 密集型工作。使用 profiler（Node.js 的 ",{"type":19,"tag":127,"props":128,"children":130},"code",{"className":129},[],[131],{"type":24,"value":132},"clinic",{"type":24,"value":134},"、",{"type":19,"tag":127,"props":136,"children":138},{"className":137},[],[139],{"type":24,"value":140},"--inspect",{"type":24,"value":142}," 或 V8 profiling）定位热函数。",{"type":19,"tag":37,"props":144,"children":145},{},[146,151],{"type":19,"tag":41,"props":147,"children":148},{},[149],{"type":24,"value":150},"I/O 阻塞",{"type":24,"value":152},"：磁盘读写、数据库或远程资源下载导致阻塞。观察 I/O 延迟、队列长度和系统调用时间。",{"type":19,"tag":37,"props":154,"children":155},{},[156,161],{"type":19,"tag":41,"props":157,"children":158},{},[159],{"type":24,"value":160},"串行依赖",{"type":24,"value":162},"：流水线式任务中存在不必要串行步骤，限制并发能力。绘制依赖 DAG 找出可并行化的节点。",{"type":19,"tag":37,"props":164,"children":165},{},[166,171],{"type":19,"tag":41,"props":167,"children":168},{},[169],{"type":24,"value":170},"频繁进程启动",{"type":24,"value":172},"：大量短生命周期子进程或容器带来高启动/销毁开销。",{"type":19,"tag":27,"props":174,"children":176},{"id":175},"优化策略按投入与收益排序",[177],{"type":24,"value":178},"优化策略（按投入与收益排序）",{"type":19,"tag":180,"props":181,"children":183},"h3",{"id":182},"_1-快速可行的工程改进",[184],{"type":24,"value":185},"1) 快速可行的工程改进",{"type":19,"tag":33,"props":187,"children":188},{},[189,199,209],{"type":19,"tag":37,"props":190,"children":191},{},[192,197],{"type":19,"tag":41,"props":193,"children":194},{},[195],{"type":24,"value":196},"缓存可复用结果",{"type":24,"value":198},"：对不常变的模板片段、静态资源或第三方调用结果使用内存或 Redis 缓存。",{"type":19,"tag":37,"props":200,"children":201},{},[202,207],{"type":19,"tag":41,"props":203,"children":204},{},[205],{"type":24,"value":206},"合并小 I/O 请求",{"type":24,"value":208},"：批量读取文件、合并多次小网络请求以减少系统调用与网络 RTT。",{"type":19,"tag":37,"props":210,"children":211},{},[212,217],{"type":19,"tag":41,"props":213,"children":214},{},[215],{"type":24,"value":216},"减少不必要的序列化",{"type":24,"value":218},"：在内存中传递对象，降低 JSON stringify/parse 的开销。",{"type":19,"tag":180,"props":220,"children":222},{"id":221},"_2-并行化与批处理",[223],{"type":24,"value":224},"2) 并行化与批处理",{"type":19,"tag":33,"props":226,"children":227},{},[228,238],{"type":19,"tag":37,"props":229,"children":230},{},[231,236],{"type":19,"tag":41,"props":232,"children":233},{},[234],{"type":24,"value":235},"并行执行独立子任务",{"type":24,"value":237},"：例如同时做图片压缩与模板填充，使用 Promise.all 或 worker 并行。",{"type":19,"tag":37,"props":239,"children":240},{},[241,246],{"type":19,"tag":41,"props":242,"children":243},{},[244],{"type":24,"value":245},"批处理外部请求",{"type":24,"value":247},"：对第三方 API 或 DB 的多次小请求合并为一次批请求，减少总请求数与延迟。",{"type":19,"tag":180,"props":249,"children":251},{"id":250},"_3-长生命周期-worker-池",[252],{"type":24,"value":253},"3) 长生命周期 Worker 池",{"type":19,"tag":33,"props":255,"children":256},{},[257],{"type":19,"tag":37,"props":258,"children":259},{},[260,262,268],{"type":24,"value":261},"使用长期运行的 worker（线程/进程池）代替频繁 spawn，显著减少启动开销。Node.js 可使用 ",{"type":19,"tag":127,"props":263,"children":265},{"className":264},[],[266],{"type":24,"value":267},"worker_threads",{"type":24,"value":269}," 或外部进程池管理。",{"type":19,"tag":180,"props":271,"children":273},{"id":272},"_4-任务分解与分布式执行",[274],{"type":24,"value":275},"4) 任务分解与分布式执行",{"type":19,"tag":33,"props":277,"children":278},{},[279],{"type":19,"tag":37,"props":280,"children":281},{},[282],{"type":24,"value":283},"将任务拆为更小子任务（模块化/分块），基于任务队列（RabbitMQ、Kafka、BullMQ）在集群中并行处理，注意幂等性与重试策略。",{"type":19,"tag":180,"props":285,"children":287},{"id":286},"_5-增量生成与依赖跟踪",[288],{"type":24,"value":289},"5) 增量生成与依赖跟踪",{"type":19,"tag":33,"props":291,"children":292},{},[293],{"type":19,"tag":37,"props":294,"children":295},{},[296],{"type":24,"value":297},"只重新生成受改动影响的模块或片段，使用依赖图追踪变更传播，避免全量重建。",{"type":19,"tag":180,"props":299,"children":301},{"id":300},"_6-优先级与资源隔离",[302],{"type":24,"value":303},"6) 优先级与资源隔离",{"type":19,"tag":33,"props":305,"children":306},{},[307],{"type":19,"tag":37,"props":308,"children":309},{},[310],{"type":24,"value":311},"为交互型短任务 (低延迟) 与批处理型长任务分配不同队列与资源池，避免长任务挤占响应资源。",{"type":19,"tag":27,"props":313,"children":315},{"id":314},"实战示例nodejs-worker-池-批处理",[316],{"type":24,"value":317},"实战示例：Node.js Worker 池 + 批处理",{"type":19,"tag":20,"props":319,"children":320},{},[321],{"type":24,"value":322},"下面示例演示主进程派发批次到固定大小的 worker 池，worker 内部并行处理子任务（示例为简化伪代码）。",{"type":19,"tag":20,"props":324,"children":325},{},[326],{"type":24,"value":327},"master.js (伪代码)：",{"type":19,"tag":329,"props":330,"children":334},"pre",{"className":331,"code":332,"language":333,"meta":7,"style":7},"language-js shiki shiki-themes github-dark github-dark","// master.js\nconst pool = createWorkerPool('./worker.js', { size: 4 });\n\nasync function submitJobs(jobs) {\n    const batches = chunk(jobs, 16); // 每个 batch 包含多个小任务\n    return Promise.all(batches.map(batch => pool.run({ batch })));\n}\n","js",[335],{"type":19,"tag":127,"props":336,"children":337},{"__ignoreMap":7},[338,350,404,414,448,491,554],{"type":19,"tag":339,"props":340,"children":343},"span",{"class":341,"line":342},"line",1,[344],{"type":19,"tag":339,"props":345,"children":347},{"style":346},"--shiki-default:#6A737D;--shiki-dark:#6A737D",[348],{"type":24,"value":349},"// master.js\n",{"type":19,"tag":339,"props":351,"children":353},{"class":341,"line":352},2,[354,360,366,371,377,383,389,394,399],{"type":19,"tag":339,"props":355,"children":357},{"style":356},"--shiki-default:#F97583;--shiki-dark:#F97583",[358],{"type":24,"value":359},"const",{"type":19,"tag":339,"props":361,"children":363},{"style":362},"--shiki-default:#79B8FF;--shiki-dark:#79B8FF",[364],{"type":24,"value":365}," pool",{"type":19,"tag":339,"props":367,"children":368},{"style":356},[369],{"type":24,"value":370}," =",{"type":19,"tag":339,"props":372,"children":374},{"style":373},"--shiki-default:#B392F0;--shiki-dark:#B392F0",[375],{"type":24,"value":376}," createWorkerPool",{"type":19,"tag":339,"props":378,"children":380},{"style":379},"--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8",[381],{"type":24,"value":382},"(",{"type":19,"tag":339,"props":384,"children":386},{"style":385},"--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF",[387],{"type":24,"value":388},"'./worker.js'",{"type":19,"tag":339,"props":390,"children":391},{"style":379},[392],{"type":24,"value":393},", { size: ",{"type":19,"tag":339,"props":395,"children":396},{"style":362},[397],{"type":24,"value":398},"4",{"type":19,"tag":339,"props":400,"children":401},{"style":379},[402],{"type":24,"value":403}," });\n",{"type":19,"tag":339,"props":405,"children":407},{"class":341,"line":406},3,[408],{"type":19,"tag":339,"props":409,"children":411},{"emptyLinePlaceholder":410},true,[412],{"type":24,"value":413},"\n",{"type":19,"tag":339,"props":415,"children":417},{"class":341,"line":416},4,[418,423,428,433,437,443],{"type":19,"tag":339,"props":419,"children":420},{"style":356},[421],{"type":24,"value":422},"async",{"type":19,"tag":339,"props":424,"children":425},{"style":356},[426],{"type":24,"value":427}," function",{"type":19,"tag":339,"props":429,"children":430},{"style":373},[431],{"type":24,"value":432}," submitJobs",{"type":19,"tag":339,"props":434,"children":435},{"style":379},[436],{"type":24,"value":382},{"type":19,"tag":339,"props":438,"children":440},{"style":439},"--shiki-default:#FFAB70;--shiki-dark:#FFAB70",[441],{"type":24,"value":442},"jobs",{"type":19,"tag":339,"props":444,"children":445},{"style":379},[446],{"type":24,"value":447},") {\n",{"type":19,"tag":339,"props":449,"children":451},{"class":341,"line":450},5,[452,457,462,466,471,476,481,486],{"type":19,"tag":339,"props":453,"children":454},{"style":356},[455],{"type":24,"value":456},"    const",{"type":19,"tag":339,"props":458,"children":459},{"style":362},[460],{"type":24,"value":461}," batches",{"type":19,"tag":339,"props":463,"children":464},{"style":356},[465],{"type":24,"value":370},{"type":19,"tag":339,"props":467,"children":468},{"style":373},[469],{"type":24,"value":470}," chunk",{"type":19,"tag":339,"props":472,"children":473},{"style":379},[474],{"type":24,"value":475},"(jobs, ",{"type":19,"tag":339,"props":477,"children":478},{"style":362},[479],{"type":24,"value":480},"16",{"type":19,"tag":339,"props":482,"children":483},{"style":379},[484],{"type":24,"value":485},"); ",{"type":19,"tag":339,"props":487,"children":488},{"style":346},[489],{"type":24,"value":490},"// 每个 batch 包含多个小任务\n",{"type":19,"tag":339,"props":492,"children":494},{"class":341,"line":493},6,[495,500,505,510,515,520,525,529,534,539,544,549],{"type":19,"tag":339,"props":496,"children":497},{"style":356},[498],{"type":24,"value":499},"    return",{"type":19,"tag":339,"props":501,"children":502},{"style":362},[503],{"type":24,"value":504}," Promise",{"type":19,"tag":339,"props":506,"children":507},{"style":379},[508],{"type":24,"value":509},".",{"type":19,"tag":339,"props":511,"children":512},{"style":373},[513],{"type":24,"value":514},"all",{"type":19,"tag":339,"props":516,"children":517},{"style":379},[518],{"type":24,"value":519},"(batches.",{"type":19,"tag":339,"props":521,"children":522},{"style":373},[523],{"type":24,"value":524},"map",{"type":19,"tag":339,"props":526,"children":527},{"style":379},[528],{"type":24,"value":382},{"type":19,"tag":339,"props":530,"children":531},{"style":439},[532],{"type":24,"value":533},"batch",{"type":19,"tag":339,"props":535,"children":536},{"style":356},[537],{"type":24,"value":538}," =>",{"type":19,"tag":339,"props":540,"children":541},{"style":379},[542],{"type":24,"value":543}," pool.",{"type":19,"tag":339,"props":545,"children":546},{"style":373},[547],{"type":24,"value":548},"run",{"type":19,"tag":339,"props":550,"children":551},{"style":379},[552],{"type":24,"value":553},"({ batch })));\n",{"type":19,"tag":339,"props":555,"children":557},{"class":341,"line":556},7,[558],{"type":19,"tag":339,"props":559,"children":560},{"style":379},[561],{"type":24,"value":562},"}\n",{"type":19,"tag":20,"props":564,"children":565},{},[566],{"type":24,"value":567},"worker.js (伪代码)：",{"type":19,"tag":329,"props":569,"children":571},{"className":331,"code":570,"language":333,"meta":7,"style":7},"// worker.js\nparentPort.on('message', async ({ batch }) => {\n    // 在 worker 内部把 CPU 密集或 I/O 密集任务并行化\n    const promises = batch.map(job => processJob(job));\n    const results = await Promise.all(promises);\n    parentPort.postMessage({ results });\n});\n",[572],{"type":19,"tag":127,"props":573,"children":574},{"__ignoreMap":7},[575,583,638,646,694,732,750],{"type":19,"tag":339,"props":576,"children":577},{"class":341,"line":342},[578],{"type":19,"tag":339,"props":579,"children":580},{"style":346},[581],{"type":24,"value":582},"// worker.js\n",{"type":19,"tag":339,"props":584,"children":585},{"class":341,"line":352},[586,591,596,600,605,610,614,619,623,628,633],{"type":19,"tag":339,"props":587,"children":588},{"style":379},[589],{"type":24,"value":590},"parentPort.",{"type":19,"tag":339,"props":592,"children":593},{"style":373},[594],{"type":24,"value":595},"on",{"type":19,"tag":339,"props":597,"children":598},{"style":379},[599],{"type":24,"value":382},{"type":19,"tag":339,"props":601,"children":602},{"style":385},[603],{"type":24,"value":604},"'message'",{"type":19,"tag":339,"props":606,"children":607},{"style":379},[608],{"type":24,"value":609},", ",{"type":19,"tag":339,"props":611,"children":612},{"style":356},[613],{"type":24,"value":422},{"type":19,"tag":339,"props":615,"children":616},{"style":379},[617],{"type":24,"value":618}," ({ ",{"type":19,"tag":339,"props":620,"children":621},{"style":439},[622],{"type":24,"value":533},{"type":19,"tag":339,"props":624,"children":625},{"style":379},[626],{"type":24,"value":627}," }) ",{"type":19,"tag":339,"props":629,"children":630},{"style":356},[631],{"type":24,"value":632},"=>",{"type":19,"tag":339,"props":634,"children":635},{"style":379},[636],{"type":24,"value":637}," {\n",{"type":19,"tag":339,"props":639,"children":640},{"class":341,"line":406},[641],{"type":19,"tag":339,"props":642,"children":643},{"style":346},[644],{"type":24,"value":645},"    // 在 worker 内部把 CPU 密集或 I/O 密集任务并行化\n",{"type":19,"tag":339,"props":647,"children":648},{"class":341,"line":416},[649,653,658,662,667,671,675,680,684,689],{"type":19,"tag":339,"props":650,"children":651},{"style":356},[652],{"type":24,"value":456},{"type":19,"tag":339,"props":654,"children":655},{"style":362},[656],{"type":24,"value":657}," promises",{"type":19,"tag":339,"props":659,"children":660},{"style":356},[661],{"type":24,"value":370},{"type":19,"tag":339,"props":663,"children":664},{"style":379},[665],{"type":24,"value":666}," batch.",{"type":19,"tag":339,"props":668,"children":669},{"style":373},[670],{"type":24,"value":524},{"type":19,"tag":339,"props":672,"children":673},{"style":379},[674],{"type":24,"value":382},{"type":19,"tag":339,"props":676,"children":677},{"style":439},[678],{"type":24,"value":679},"job",{"type":19,"tag":339,"props":681,"children":682},{"style":356},[683],{"type":24,"value":538},{"type":19,"tag":339,"props":685,"children":686},{"style":373},[687],{"type":24,"value":688}," processJob",{"type":19,"tag":339,"props":690,"children":691},{"style":379},[692],{"type":24,"value":693},"(job));\n",{"type":19,"tag":339,"props":695,"children":696},{"class":341,"line":450},[697,701,706,710,715,719,723,727],{"type":19,"tag":339,"props":698,"children":699},{"style":356},[700],{"type":24,"value":456},{"type":19,"tag":339,"props":702,"children":703},{"style":362},[704],{"type":24,"value":705}," results",{"type":19,"tag":339,"props":707,"children":708},{"style":356},[709],{"type":24,"value":370},{"type":19,"tag":339,"props":711,"children":712},{"style":356},[713],{"type":24,"value":714}," await",{"type":19,"tag":339,"props":716,"children":717},{"style":362},[718],{"type":24,"value":504},{"type":19,"tag":339,"props":720,"children":721},{"style":379},[722],{"type":24,"value":509},{"type":19,"tag":339,"props":724,"children":725},{"style":373},[726],{"type":24,"value":514},{"type":19,"tag":339,"props":728,"children":729},{"style":379},[730],{"type":24,"value":731},"(promises);\n",{"type":19,"tag":339,"props":733,"children":734},{"class":341,"line":493},[735,740,745],{"type":19,"tag":339,"props":736,"children":737},{"style":379},[738],{"type":24,"value":739},"    parentPort.",{"type":19,"tag":339,"props":741,"children":742},{"style":373},[743],{"type":24,"value":744},"postMessage",{"type":19,"tag":339,"props":746,"children":747},{"style":379},[748],{"type":24,"value":749},"({ results });\n",{"type":19,"tag":339,"props":751,"children":752},{"class":341,"line":556},[753],{"type":19,"tag":339,"props":754,"children":755},{"style":379},[756],{"type":24,"value":757},"});\n",{"type":19,"tag":20,"props":759,"children":760},{},[761],{"type":24,"value":762},"要点：",{"type":19,"tag":33,"props":764,"children":765},{},[766],{"type":19,"tag":37,"props":767,"children":768},{},[769],{"type":24,"value":770},"固定池大小避免过度调度；在 worker 内部再并行化能利用多核并减少跨进程通信成本。",{"type":19,"tag":27,"props":772,"children":774},{"id":773},"基准与回归测试建议",[775],{"type":24,"value":773},{"type":19,"tag":33,"props":777,"children":778},{},[779,784],{"type":19,"tag":37,"props":780,"children":781},{},[782],{"type":24,"value":783},"在 CI 中加入基准脚本（例如对 100/1000 条生成任务测量 P50/P95/P99），并设置回归阈值。",{"type":19,"tag":37,"props":785,"children":786},{},[787],{"type":24,"value":788},"使用负载测试（k6、wrk）模拟并发场景，结合 APM（Prometheus/Grafana）收集 CPU、内存、队列深度与网络指标。",{"type":19,"tag":27,"props":790,"children":792},{"id":791},"上线前检查表",[793],{"type":24,"value":791},{"type":19,"tag":33,"props":795,"children":796},{},[797,802,807,812,817,822],{"type":19,"tag":37,"props":798,"children":799},{},[800],{"type":24,"value":801},"是否为可复用片段启用了缓存，并验证缓存命中率？",{"type":19,"tag":37,"props":803,"children":804},{},[805],{"type":24,"value":806},"串行步骤中是否已识别可并行化节点？",{"type":19,"tag":37,"props":808,"children":809},{},[810],{"type":24,"value":811},"是否使用固定大小的 worker 池而非频繁 spawn？",{"type":19,"tag":37,"props":813,"children":814},{},[815],{"type":24,"value":816},"是否对外部依赖采取了批处理或降级策略？",{"type":19,"tag":37,"props":818,"children":819},{},[820],{"type":24,"value":821},"是否实现了增量生成与正确的依赖追踪？",{"type":19,"tag":37,"props":823,"children":824},{},[825],{"type":24,"value":826},"是否为交互型与批处理型任务做了资源隔离与优先级区分？",{"type":19,"tag":27,"props":828,"children":830},{"id":829},"风险与折衷",[831],{"type":24,"value":829},{"type":19,"tag":33,"props":833,"children":834},{},[835],{"type":19,"tag":37,"props":836,"children":837},{},[838],{"type":24,"value":839},"并行度过高可能导致外部服务或内存爆满；批处理带来的单次延迟增加需要与吞吐提升权衡。增量生成需要精确的依赖跟踪，否则会产生不一致输出。",{"type":19,"tag":27,"props":841,"children":843},{"id":842},"总结",[844],{"type":24,"value":842},{"type":19,"tag":20,"props":846,"children":847},{},[848],{"type":24,"value":849},"提升生成速度需要结合可观测性、基准化测试与渐进式改进：先通过测量识别瓶颈，优先采用缓存与 I/O 合并等低风险改进，再逐步引入并行、池化与分布式策略。",{"type":19,"tag":27,"props":851,"children":853},{"id":852},"相关链接",[854],{"type":24,"value":852},{"type":19,"tag":33,"props":856,"children":857},{},[858,868,877],{"type":19,"tag":37,"props":859,"children":860},{},[861],{"type":19,"tag":862,"props":863,"children":865},"a",{"href":864},"/blog",[866],{"type":24,"value":867},"返回博客分类",{"type":19,"tag":37,"props":869,"children":870},{},[871],{"type":19,"tag":862,"props":872,"children":874},{"href":873},"/blog/topic/multi-agent-system",[875],{"type":24,"value":876},"查看热门话题",{"type":19,"tag":37,"props":878,"children":879},{},[880],{"type":19,"tag":862,"props":881,"children":883},{"href":882},"/blog/ai-architecture-deep-dive",[884],{"type":24,"value":885},"AI 架构深入",{"type":19,"tag":887,"props":888,"children":889},"hr",{},[],{"type":19,"tag":20,"props":891,"children":892},{},[893],{"type":24,"value":894},"⚠️ 本文为扩展草稿，已包含可复制的基准脚本与部署示例；如需更深入的具体实现（例如图片处理优化或 Helm 模板），请在后续 issue 中指定具体目标。",{"type":19,"tag":27,"props":896,"children":898},{"id":897},"可复制的基准脚本示例nodejs",[899],{"type":24,"value":900},"可复制的基准脚本示例（Node.js）",{"type":19,"tag":20,"props":902,"children":903},{},[904],{"type":24,"value":905},"下面给出一个简化但可运行的 Node.js 基准脚本，用于测量生成系统在本机或容器内的延迟分布（P50/P95/P99）与吞吐。脚本思路：并发发起 N 次生成任务（可调用本地 HTTP 接口或函数），记录每次延迟并计算统计量。",{"type":19,"tag":20,"props":907,"children":908},{},[909,911,917],{"type":24,"value":910},"保存为 ",{"type":19,"tag":127,"props":912,"children":914},{"className":913},[],[915],{"type":24,"value":916},"bench/benchmark-generate.js",{"type":24,"value":918},"（项目任意位置）：",{"type":19,"tag":329,"props":920,"children":922},{"className":331,"code":921,"language":333,"meta":7,"style":7},"// bench/benchmark-generate.js\nconst { performance } = require('perf_hooks');\nconst fetch = require('node-fetch'); // npm i node-fetch@2\n\nasync function requestOnce(url) {\n    const t0 = performance.now();\n    const res = await fetch(url, { method: 'POST', body: JSON.stringify({ templateId: 'demo' }), headers: { 'Content-Type': 'application/json' } });\n    await res.text();\n    return performance.now() - t0;\n}\n\nasync function run(url, total = 200, concurrency = 20) {\n    const latencies = [];\n    let inFlight = 0;\n    let completed = 0;\n\n    return new Promise((resolve) => {\n        function schedule() {\n            while (inFlight \u003C concurrency && completed + inFlight \u003C total) {\n                inFlight++;\n                requestOnce(url).then(lat => {\n                    latencies.push(lat);\n                }).catch(err => {\n                    latencies.push(Number.POSITIVE_INFINITY);\n                }).finally(() => {\n                    inFlight--;\n                    completed++;\n                    if (completed === total) {\n                        resolve(latencies);\n                    } else {\n                        schedule();\n                    }\n                });\n            }\n        }\n        schedule();\n    });\n}\n\nfunction stats(arr) {\n    const finite = arr.filter(x => Number.isFinite(x)).sort((a,b)=>a-b);\n    const sum = finite.reduce((s,x)=>s+x,0);\n    const p = (q) => finite[Math.floor(finite.length * q) - 1] || 0;\n    return {\n        count: arr.length,\n        ok: finite.length,\n        p50: p(0.5).toFixed(2),\n        p95: p(0.95).toFixed(2),\n        p99: p(0.99).toFixed(2),\n        avg: (sum / finite.length).toFixed(2)\n    };\n}\n\nif (require.main === module) {\n    const url = process.argv[2] || 'http://localhost:3000/api/generate';\n    const total = Number(process.argv[3] || 200);\n    const concurrency = Number(process.argv[4] || 20);\n    (async () => {\n        console.log('Run', { url, total, concurrency });\n        const lat = await run(url, total, concurrency);\n        console.log(stats(lat));\n    })();\n}\n",[923],{"type":19,"tag":127,"props":924,"children":925},{"__ignoreMap":7},[926,934,980,1018,1025,1054,1085,1173,1195,1226,1234,1242,1307,1329,1357,1382,1390,1430,1449,1500,1518,1554,1573,1604,1621,1647,1665,1682,1705,1719,1737,1750,1759,1768,1777,1786,1799,1808,1816,1824,1851,1951,2025,2117,2129,2147,2164,2210,2252,2294,2337,2346,2354,2362,2389,2432,2480,2525,2551,2579,2610,2636,2645],{"type":19,"tag":339,"props":927,"children":928},{"class":341,"line":342},[929],{"type":19,"tag":339,"props":930,"children":931},{"style":346},[932],{"type":24,"value":933},"// bench/benchmark-generate.js\n",{"type":19,"tag":339,"props":935,"children":936},{"class":341,"line":352},[937,941,946,951,956,961,966,970,975],{"type":19,"tag":339,"props":938,"children":939},{"style":356},[940],{"type":24,"value":359},{"type":19,"tag":339,"props":942,"children":943},{"style":379},[944],{"type":24,"value":945}," { ",{"type":19,"tag":339,"props":947,"children":948},{"style":362},[949],{"type":24,"value":950},"performance",{"type":19,"tag":339,"props":952,"children":953},{"style":379},[954],{"type":24,"value":955}," } ",{"type":19,"tag":339,"props":957,"children":958},{"style":356},[959],{"type":24,"value":960},"=",{"type":19,"tag":339,"props":962,"children":963},{"style":373},[964],{"type":24,"value":965}," require",{"type":19,"tag":339,"props":967,"children":968},{"style":379},[969],{"type":24,"value":382},{"type":19,"tag":339,"props":971,"children":972},{"style":385},[973],{"type":24,"value":974},"'perf_hooks'",{"type":19,"tag":339,"props":976,"children":977},{"style":379},[978],{"type":24,"value":979},");\n",{"type":19,"tag":339,"props":981,"children":982},{"class":341,"line":406},[983,987,992,996,1000,1004,1009,1013],{"type":19,"tag":339,"props":984,"children":985},{"style":356},[986],{"type":24,"value":359},{"type":19,"tag":339,"props":988,"children":989},{"style":362},[990],{"type":24,"value":991}," fetch",{"type":19,"tag":339,"props":993,"children":994},{"style":356},[995],{"type":24,"value":370},{"type":19,"tag":339,"props":997,"children":998},{"style":373},[999],{"type":24,"value":965},{"type":19,"tag":339,"props":1001,"children":1002},{"style":379},[1003],{"type":24,"value":382},{"type":19,"tag":339,"props":1005,"children":1006},{"style":385},[1007],{"type":24,"value":1008},"'node-fetch'",{"type":19,"tag":339,"props":1010,"children":1011},{"style":379},[1012],{"type":24,"value":485},{"type":19,"tag":339,"props":1014,"children":1015},{"style":346},[1016],{"type":24,"value":1017},"// npm i node-fetch@2\n",{"type":19,"tag":339,"props":1019,"children":1020},{"class":341,"line":416},[1021],{"type":19,"tag":339,"props":1022,"children":1023},{"emptyLinePlaceholder":410},[1024],{"type":24,"value":413},{"type":19,"tag":339,"props":1026,"children":1027},{"class":341,"line":450},[1028,1032,1036,1041,1045,1050],{"type":19,"tag":339,"props":1029,"children":1030},{"style":356},[1031],{"type":24,"value":422},{"type":19,"tag":339,"props":1033,"children":1034},{"style":356},[1035],{"type":24,"value":427},{"type":19,"tag":339,"props":1037,"children":1038},{"style":373},[1039],{"type":24,"value":1040}," requestOnce",{"type":19,"tag":339,"props":1042,"children":1043},{"style":379},[1044],{"type":24,"value":382},{"type":19,"tag":339,"props":1046,"children":1047},{"style":439},[1048],{"type":24,"value":1049},"url",{"type":19,"tag":339,"props":1051,"children":1052},{"style":379},[1053],{"type":24,"value":447},{"type":19,"tag":339,"props":1055,"children":1056},{"class":341,"line":493},[1057,1061,1066,1070,1075,1080],{"type":19,"tag":339,"props":1058,"children":1059},{"style":356},[1060],{"type":24,"value":456},{"type":19,"tag":339,"props":1062,"children":1063},{"style":362},[1064],{"type":24,"value":1065}," t0",{"type":19,"tag":339,"props":1067,"children":1068},{"style":356},[1069],{"type":24,"value":370},{"type":19,"tag":339,"props":1071,"children":1072},{"style":379},[1073],{"type":24,"value":1074}," performance.",{"type":19,"tag":339,"props":1076,"children":1077},{"style":373},[1078],{"type":24,"value":1079},"now",{"type":19,"tag":339,"props":1081,"children":1082},{"style":379},[1083],{"type":24,"value":1084},"();\n",{"type":19,"tag":339,"props":1086,"children":1087},{"class":341,"line":556},[1088,1092,1097,1101,1105,1109,1114,1119,1124,1129,1133,1138,1143,1148,1153,1158,1163,1168],{"type":19,"tag":339,"props":1089,"children":1090},{"style":356},[1091],{"type":24,"value":456},{"type":19,"tag":339,"props":1093,"children":1094},{"style":362},[1095],{"type":24,"value":1096}," res",{"type":19,"tag":339,"props":1098,"children":1099},{"style":356},[1100],{"type":24,"value":370},{"type":19,"tag":339,"props":1102,"children":1103},{"style":356},[1104],{"type":24,"value":714},{"type":19,"tag":339,"props":1106,"children":1107},{"style":373},[1108],{"type":24,"value":991},{"type":19,"tag":339,"props":1110,"children":1111},{"style":379},[1112],{"type":24,"value":1113},"(url, { method: ",{"type":19,"tag":339,"props":1115,"children":1116},{"style":385},[1117],{"type":24,"value":1118},"'POST'",{"type":19,"tag":339,"props":1120,"children":1121},{"style":379},[1122],{"type":24,"value":1123},", body: ",{"type":19,"tag":339,"props":1125,"children":1126},{"style":362},[1127],{"type":24,"value":1128},"JSON",{"type":19,"tag":339,"props":1130,"children":1131},{"style":379},[1132],{"type":24,"value":509},{"type":19,"tag":339,"props":1134,"children":1135},{"style":373},[1136],{"type":24,"value":1137},"stringify",{"type":19,"tag":339,"props":1139,"children":1140},{"style":379},[1141],{"type":24,"value":1142},"({ templateId: ",{"type":19,"tag":339,"props":1144,"children":1145},{"style":385},[1146],{"type":24,"value":1147},"'demo'",{"type":19,"tag":339,"props":1149,"children":1150},{"style":379},[1151],{"type":24,"value":1152}," }), headers: { ",{"type":19,"tag":339,"props":1154,"children":1155},{"style":385},[1156],{"type":24,"value":1157},"'Content-Type'",{"type":19,"tag":339,"props":1159,"children":1160},{"style":379},[1161],{"type":24,"value":1162},": ",{"type":19,"tag":339,"props":1164,"children":1165},{"style":385},[1166],{"type":24,"value":1167},"'application/json'",{"type":19,"tag":339,"props":1169,"children":1170},{"style":379},[1171],{"type":24,"value":1172}," } });\n",{"type":19,"tag":339,"props":1174,"children":1176},{"class":341,"line":1175},8,[1177,1182,1187,1191],{"type":19,"tag":339,"props":1178,"children":1179},{"style":356},[1180],{"type":24,"value":1181},"    await",{"type":19,"tag":339,"props":1183,"children":1184},{"style":379},[1185],{"type":24,"value":1186}," res.",{"type":19,"tag":339,"props":1188,"children":1189},{"style":373},[1190],{"type":24,"value":24},{"type":19,"tag":339,"props":1192,"children":1193},{"style":379},[1194],{"type":24,"value":1084},{"type":19,"tag":339,"props":1196,"children":1198},{"class":341,"line":1197},9,[1199,1203,1207,1211,1216,1221],{"type":19,"tag":339,"props":1200,"children":1201},{"style":356},[1202],{"type":24,"value":499},{"type":19,"tag":339,"props":1204,"children":1205},{"style":379},[1206],{"type":24,"value":1074},{"type":19,"tag":339,"props":1208,"children":1209},{"style":373},[1210],{"type":24,"value":1079},{"type":19,"tag":339,"props":1212,"children":1213},{"style":379},[1214],{"type":24,"value":1215},"() ",{"type":19,"tag":339,"props":1217,"children":1218},{"style":356},[1219],{"type":24,"value":1220},"-",{"type":19,"tag":339,"props":1222,"children":1223},{"style":379},[1224],{"type":24,"value":1225}," t0;\n",{"type":19,"tag":339,"props":1227,"children":1229},{"class":341,"line":1228},10,[1230],{"type":19,"tag":339,"props":1231,"children":1232},{"style":379},[1233],{"type":24,"value":562},{"type":19,"tag":339,"props":1235,"children":1237},{"class":341,"line":1236},11,[1238],{"type":19,"tag":339,"props":1239,"children":1240},{"emptyLinePlaceholder":410},[1241],{"type":24,"value":413},{"type":19,"tag":339,"props":1243,"children":1245},{"class":341,"line":1244},12,[1246,1250,1254,1259,1263,1267,1271,1276,1280,1285,1289,1294,1298,1303],{"type":19,"tag":339,"props":1247,"children":1248},{"style":356},[1249],{"type":24,"value":422},{"type":19,"tag":339,"props":1251,"children":1252},{"style":356},[1253],{"type":24,"value":427},{"type":19,"tag":339,"props":1255,"children":1256},{"style":373},[1257],{"type":24,"value":1258}," run",{"type":19,"tag":339,"props":1260,"children":1261},{"style":379},[1262],{"type":24,"value":382},{"type":19,"tag":339,"props":1264,"children":1265},{"style":439},[1266],{"type":24,"value":1049},{"type":19,"tag":339,"props":1268,"children":1269},{"style":379},[1270],{"type":24,"value":609},{"type":19,"tag":339,"props":1272,"children":1273},{"style":439},[1274],{"type":24,"value":1275},"total",{"type":19,"tag":339,"props":1277,"children":1278},{"style":356},[1279],{"type":24,"value":370},{"type":19,"tag":339,"props":1281,"children":1282},{"style":362},[1283],{"type":24,"value":1284}," 200",{"type":19,"tag":339,"props":1286,"children":1287},{"style":379},[1288],{"type":24,"value":609},{"type":19,"tag":339,"props":1290,"children":1291},{"style":439},[1292],{"type":24,"value":1293},"concurrency",{"type":19,"tag":339,"props":1295,"children":1296},{"style":356},[1297],{"type":24,"value":370},{"type":19,"tag":339,"props":1299,"children":1300},{"style":362},[1301],{"type":24,"value":1302}," 20",{"type":19,"tag":339,"props":1304,"children":1305},{"style":379},[1306],{"type":24,"value":447},{"type":19,"tag":339,"props":1308,"children":1310},{"class":341,"line":1309},13,[1311,1315,1320,1324],{"type":19,"tag":339,"props":1312,"children":1313},{"style":356},[1314],{"type":24,"value":456},{"type":19,"tag":339,"props":1316,"children":1317},{"style":362},[1318],{"type":24,"value":1319}," latencies",{"type":19,"tag":339,"props":1321,"children":1322},{"style":356},[1323],{"type":24,"value":370},{"type":19,"tag":339,"props":1325,"children":1326},{"style":379},[1327],{"type":24,"value":1328}," [];\n",{"type":19,"tag":339,"props":1330,"children":1332},{"class":341,"line":1331},14,[1333,1338,1343,1347,1352],{"type":19,"tag":339,"props":1334,"children":1335},{"style":356},[1336],{"type":24,"value":1337},"    let",{"type":19,"tag":339,"props":1339,"children":1340},{"style":379},[1341],{"type":24,"value":1342}," inFlight ",{"type":19,"tag":339,"props":1344,"children":1345},{"style":356},[1346],{"type":24,"value":960},{"type":19,"tag":339,"props":1348,"children":1349},{"style":362},[1350],{"type":24,"value":1351}," 0",{"type":19,"tag":339,"props":1353,"children":1354},{"style":379},[1355],{"type":24,"value":1356},";\n",{"type":19,"tag":339,"props":1358,"children":1360},{"class":341,"line":1359},15,[1361,1365,1370,1374,1378],{"type":19,"tag":339,"props":1362,"children":1363},{"style":356},[1364],{"type":24,"value":1337},{"type":19,"tag":339,"props":1366,"children":1367},{"style":379},[1368],{"type":24,"value":1369}," completed ",{"type":19,"tag":339,"props":1371,"children":1372},{"style":356},[1373],{"type":24,"value":960},{"type":19,"tag":339,"props":1375,"children":1376},{"style":362},[1377],{"type":24,"value":1351},{"type":19,"tag":339,"props":1379,"children":1380},{"style":379},[1381],{"type":24,"value":1356},{"type":19,"tag":339,"props":1383,"children":1385},{"class":341,"line":1384},16,[1386],{"type":19,"tag":339,"props":1387,"children":1388},{"emptyLinePlaceholder":410},[1389],{"type":24,"value":413},{"type":19,"tag":339,"props":1391,"children":1393},{"class":341,"line":1392},17,[1394,1398,1403,1407,1412,1417,1422,1426],{"type":19,"tag":339,"props":1395,"children":1396},{"style":356},[1397],{"type":24,"value":499},{"type":19,"tag":339,"props":1399,"children":1400},{"style":356},[1401],{"type":24,"value":1402}," new",{"type":19,"tag":339,"props":1404,"children":1405},{"style":362},[1406],{"type":24,"value":504},{"type":19,"tag":339,"props":1408,"children":1409},{"style":379},[1410],{"type":24,"value":1411},"((",{"type":19,"tag":339,"props":1413,"children":1414},{"style":439},[1415],{"type":24,"value":1416},"resolve",{"type":19,"tag":339,"props":1418,"children":1419},{"style":379},[1420],{"type":24,"value":1421},") ",{"type":19,"tag":339,"props":1423,"children":1424},{"style":356},[1425],{"type":24,"value":632},{"type":19,"tag":339,"props":1427,"children":1428},{"style":379},[1429],{"type":24,"value":637},{"type":19,"tag":339,"props":1431,"children":1433},{"class":341,"line":1432},18,[1434,1439,1444],{"type":19,"tag":339,"props":1435,"children":1436},{"style":356},[1437],{"type":24,"value":1438},"        function",{"type":19,"tag":339,"props":1440,"children":1441},{"style":373},[1442],{"type":24,"value":1443}," schedule",{"type":19,"tag":339,"props":1445,"children":1446},{"style":379},[1447],{"type":24,"value":1448},"() {\n",{"type":19,"tag":339,"props":1450,"children":1452},{"class":341,"line":1451},19,[1453,1458,1463,1468,1473,1478,1482,1487,1491,1495],{"type":19,"tag":339,"props":1454,"children":1455},{"style":356},[1456],{"type":24,"value":1457},"            while",{"type":19,"tag":339,"props":1459,"children":1460},{"style":379},[1461],{"type":24,"value":1462}," (inFlight ",{"type":19,"tag":339,"props":1464,"children":1465},{"style":356},[1466],{"type":24,"value":1467},"\u003C",{"type":19,"tag":339,"props":1469,"children":1470},{"style":379},[1471],{"type":24,"value":1472}," concurrency ",{"type":19,"tag":339,"props":1474,"children":1475},{"style":356},[1476],{"type":24,"value":1477},"&&",{"type":19,"tag":339,"props":1479,"children":1480},{"style":379},[1481],{"type":24,"value":1369},{"type":19,"tag":339,"props":1483,"children":1484},{"style":356},[1485],{"type":24,"value":1486},"+",{"type":19,"tag":339,"props":1488,"children":1489},{"style":379},[1490],{"type":24,"value":1342},{"type":19,"tag":339,"props":1492,"children":1493},{"style":356},[1494],{"type":24,"value":1467},{"type":19,"tag":339,"props":1496,"children":1497},{"style":379},[1498],{"type":24,"value":1499}," total) {\n",{"type":19,"tag":339,"props":1501,"children":1503},{"class":341,"line":1502},20,[1504,1509,1514],{"type":19,"tag":339,"props":1505,"children":1506},{"style":379},[1507],{"type":24,"value":1508},"                inFlight",{"type":19,"tag":339,"props":1510,"children":1511},{"style":356},[1512],{"type":24,"value":1513},"++",{"type":19,"tag":339,"props":1515,"children":1516},{"style":379},[1517],{"type":24,"value":1356},{"type":19,"tag":339,"props":1519,"children":1521},{"class":341,"line":1520},21,[1522,1527,1532,1537,1541,1546,1550],{"type":19,"tag":339,"props":1523,"children":1524},{"style":373},[1525],{"type":24,"value":1526},"                requestOnce",{"type":19,"tag":339,"props":1528,"children":1529},{"style":379},[1530],{"type":24,"value":1531},"(url).",{"type":19,"tag":339,"props":1533,"children":1534},{"style":373},[1535],{"type":24,"value":1536},"then",{"type":19,"tag":339,"props":1538,"children":1539},{"style":379},[1540],{"type":24,"value":382},{"type":19,"tag":339,"props":1542,"children":1543},{"style":439},[1544],{"type":24,"value":1545},"lat",{"type":19,"tag":339,"props":1547,"children":1548},{"style":356},[1549],{"type":24,"value":538},{"type":19,"tag":339,"props":1551,"children":1552},{"style":379},[1553],{"type":24,"value":637},{"type":19,"tag":339,"props":1555,"children":1557},{"class":341,"line":1556},22,[1558,1563,1568],{"type":19,"tag":339,"props":1559,"children":1560},{"style":379},[1561],{"type":24,"value":1562},"                    latencies.",{"type":19,"tag":339,"props":1564,"children":1565},{"style":373},[1566],{"type":24,"value":1567},"push",{"type":19,"tag":339,"props":1569,"children":1570},{"style":379},[1571],{"type":24,"value":1572},"(lat);\n",{"type":19,"tag":339,"props":1574,"children":1576},{"class":341,"line":1575},23,[1577,1582,1587,1591,1596,1600],{"type":19,"tag":339,"props":1578,"children":1579},{"style":379},[1580],{"type":24,"value":1581},"                }).",{"type":19,"tag":339,"props":1583,"children":1584},{"style":373},[1585],{"type":24,"value":1586},"catch",{"type":19,"tag":339,"props":1588,"children":1589},{"style":379},[1590],{"type":24,"value":382},{"type":19,"tag":339,"props":1592,"children":1593},{"style":439},[1594],{"type":24,"value":1595},"err",{"type":19,"tag":339,"props":1597,"children":1598},{"style":356},[1599],{"type":24,"value":538},{"type":19,"tag":339,"props":1601,"children":1602},{"style":379},[1603],{"type":24,"value":637},{"type":19,"tag":339,"props":1605,"children":1607},{"class":341,"line":1606},24,[1608,1612,1616],{"type":19,"tag":339,"props":1609,"children":1610},{"style":379},[1611],{"type":24,"value":1562},{"type":19,"tag":339,"props":1613,"children":1614},{"style":373},[1615],{"type":24,"value":1567},{"type":19,"tag":339,"props":1617,"children":1618},{"style":379},[1619],{"type":24,"value":1620},"(Number.POSITIVE_INFINITY);\n",{"type":19,"tag":339,"props":1622,"children":1624},{"class":341,"line":1623},25,[1625,1629,1634,1639,1643],{"type":19,"tag":339,"props":1626,"children":1627},{"style":379},[1628],{"type":24,"value":1581},{"type":19,"tag":339,"props":1630,"children":1631},{"style":373},[1632],{"type":24,"value":1633},"finally",{"type":19,"tag":339,"props":1635,"children":1636},{"style":379},[1637],{"type":24,"value":1638},"(() ",{"type":19,"tag":339,"props":1640,"children":1641},{"style":356},[1642],{"type":24,"value":632},{"type":19,"tag":339,"props":1644,"children":1645},{"style":379},[1646],{"type":24,"value":637},{"type":19,"tag":339,"props":1648,"children":1650},{"class":341,"line":1649},26,[1651,1656,1661],{"type":19,"tag":339,"props":1652,"children":1653},{"style":379},[1654],{"type":24,"value":1655},"                    inFlight",{"type":19,"tag":339,"props":1657,"children":1658},{"style":356},[1659],{"type":24,"value":1660},"--",{"type":19,"tag":339,"props":1662,"children":1663},{"style":379},[1664],{"type":24,"value":1356},{"type":19,"tag":339,"props":1666,"children":1668},{"class":341,"line":1667},27,[1669,1674,1678],{"type":19,"tag":339,"props":1670,"children":1671},{"style":379},[1672],{"type":24,"value":1673},"                    completed",{"type":19,"tag":339,"props":1675,"children":1676},{"style":356},[1677],{"type":24,"value":1513},{"type":19,"tag":339,"props":1679,"children":1680},{"style":379},[1681],{"type":24,"value":1356},{"type":19,"tag":339,"props":1683,"children":1685},{"class":341,"line":1684},28,[1686,1691,1696,1701],{"type":19,"tag":339,"props":1687,"children":1688},{"style":356},[1689],{"type":24,"value":1690},"                    if",{"type":19,"tag":339,"props":1692,"children":1693},{"style":379},[1694],{"type":24,"value":1695}," (completed ",{"type":19,"tag":339,"props":1697,"children":1698},{"style":356},[1699],{"type":24,"value":1700},"===",{"type":19,"tag":339,"props":1702,"children":1703},{"style":379},[1704],{"type":24,"value":1499},{"type":19,"tag":339,"props":1706,"children":1708},{"class":341,"line":1707},29,[1709,1714],{"type":19,"tag":339,"props":1710,"children":1711},{"style":373},[1712],{"type":24,"value":1713},"                        resolve",{"type":19,"tag":339,"props":1715,"children":1716},{"style":379},[1717],{"type":24,"value":1718},"(latencies);\n",{"type":19,"tag":339,"props":1720,"children":1722},{"class":341,"line":1721},30,[1723,1728,1733],{"type":19,"tag":339,"props":1724,"children":1725},{"style":379},[1726],{"type":24,"value":1727},"                    } ",{"type":19,"tag":339,"props":1729,"children":1730},{"style":356},[1731],{"type":24,"value":1732},"else",{"type":19,"tag":339,"props":1734,"children":1735},{"style":379},[1736],{"type":24,"value":637},{"type":19,"tag":339,"props":1738,"children":1740},{"class":341,"line":1739},31,[1741,1746],{"type":19,"tag":339,"props":1742,"children":1743},{"style":373},[1744],{"type":24,"value":1745},"                        schedule",{"type":19,"tag":339,"props":1747,"children":1748},{"style":379},[1749],{"type":24,"value":1084},{"type":19,"tag":339,"props":1751,"children":1753},{"class":341,"line":1752},32,[1754],{"type":19,"tag":339,"props":1755,"children":1756},{"style":379},[1757],{"type":24,"value":1758},"                    }\n",{"type":19,"tag":339,"props":1760,"children":1762},{"class":341,"line":1761},33,[1763],{"type":19,"tag":339,"props":1764,"children":1765},{"style":379},[1766],{"type":24,"value":1767},"                });\n",{"type":19,"tag":339,"props":1769,"children":1771},{"class":341,"line":1770},34,[1772],{"type":19,"tag":339,"props":1773,"children":1774},{"style":379},[1775],{"type":24,"value":1776},"            }\n",{"type":19,"tag":339,"props":1778,"children":1780},{"class":341,"line":1779},35,[1781],{"type":19,"tag":339,"props":1782,"children":1783},{"style":379},[1784],{"type":24,"value":1785},"        }\n",{"type":19,"tag":339,"props":1787,"children":1789},{"class":341,"line":1788},36,[1790,1795],{"type":19,"tag":339,"props":1791,"children":1792},{"style":373},[1793],{"type":24,"value":1794},"        schedule",{"type":19,"tag":339,"props":1796,"children":1797},{"style":379},[1798],{"type":24,"value":1084},{"type":19,"tag":339,"props":1800,"children":1802},{"class":341,"line":1801},37,[1803],{"type":19,"tag":339,"props":1804,"children":1805},{"style":379},[1806],{"type":24,"value":1807},"    });\n",{"type":19,"tag":339,"props":1809,"children":1811},{"class":341,"line":1810},38,[1812],{"type":19,"tag":339,"props":1813,"children":1814},{"style":379},[1815],{"type":24,"value":562},{"type":19,"tag":339,"props":1817,"children":1819},{"class":341,"line":1818},39,[1820],{"type":19,"tag":339,"props":1821,"children":1822},{"emptyLinePlaceholder":410},[1823],{"type":24,"value":413},{"type":19,"tag":339,"props":1825,"children":1827},{"class":341,"line":1826},40,[1828,1833,1838,1842,1847],{"type":19,"tag":339,"props":1829,"children":1830},{"style":356},[1831],{"type":24,"value":1832},"function",{"type":19,"tag":339,"props":1834,"children":1835},{"style":373},[1836],{"type":24,"value":1837}," stats",{"type":19,"tag":339,"props":1839,"children":1840},{"style":379},[1841],{"type":24,"value":382},{"type":19,"tag":339,"props":1843,"children":1844},{"style":439},[1845],{"type":24,"value":1846},"arr",{"type":19,"tag":339,"props":1848,"children":1849},{"style":379},[1850],{"type":24,"value":447},{"type":19,"tag":339,"props":1852,"children":1854},{"class":341,"line":1853},41,[1855,1859,1864,1868,1873,1878,1882,1887,1891,1896,1901,1906,1911,1915,1919,1924,1929,1934,1938,1942,1946],{"type":19,"tag":339,"props":1856,"children":1857},{"style":356},[1858],{"type":24,"value":456},{"type":19,"tag":339,"props":1860,"children":1861},{"style":362},[1862],{"type":24,"value":1863}," finite",{"type":19,"tag":339,"props":1865,"children":1866},{"style":356},[1867],{"type":24,"value":370},{"type":19,"tag":339,"props":1869,"children":1870},{"style":379},[1871],{"type":24,"value":1872}," arr.",{"type":19,"tag":339,"props":1874,"children":1875},{"style":373},[1876],{"type":24,"value":1877},"filter",{"type":19,"tag":339,"props":1879,"children":1880},{"style":379},[1881],{"type":24,"value":382},{"type":19,"tag":339,"props":1883,"children":1884},{"style":439},[1885],{"type":24,"value":1886},"x",{"type":19,"tag":339,"props":1888,"children":1889},{"style":356},[1890],{"type":24,"value":538},{"type":19,"tag":339,"props":1892,"children":1893},{"style":379},[1894],{"type":24,"value":1895}," Number.",{"type":19,"tag":339,"props":1897,"children":1898},{"style":373},[1899],{"type":24,"value":1900},"isFinite",{"type":19,"tag":339,"props":1902,"children":1903},{"style":379},[1904],{"type":24,"value":1905},"(x)).",{"type":19,"tag":339,"props":1907,"children":1908},{"style":373},[1909],{"type":24,"value":1910},"sort",{"type":19,"tag":339,"props":1912,"children":1913},{"style":379},[1914],{"type":24,"value":1411},{"type":19,"tag":339,"props":1916,"children":1917},{"style":439},[1918],{"type":24,"value":862},{"type":19,"tag":339,"props":1920,"children":1921},{"style":379},[1922],{"type":24,"value":1923},",",{"type":19,"tag":339,"props":1925,"children":1926},{"style":439},[1927],{"type":24,"value":1928},"b",{"type":19,"tag":339,"props":1930,"children":1931},{"style":379},[1932],{"type":24,"value":1933},")",{"type":19,"tag":339,"props":1935,"children":1936},{"style":356},[1937],{"type":24,"value":632},{"type":19,"tag":339,"props":1939,"children":1940},{"style":379},[1941],{"type":24,"value":862},{"type":19,"tag":339,"props":1943,"children":1944},{"style":356},[1945],{"type":24,"value":1220},{"type":19,"tag":339,"props":1947,"children":1948},{"style":379},[1949],{"type":24,"value":1950},"b);\n",{"type":19,"tag":339,"props":1952,"children":1954},{"class":341,"line":1953},42,[1955,1959,1964,1968,1973,1978,1982,1987,1991,1995,1999,2003,2007,2011,2016,2021],{"type":19,"tag":339,"props":1956,"children":1957},{"style":356},[1958],{"type":24,"value":456},{"type":19,"tag":339,"props":1960,"children":1961},{"style":362},[1962],{"type":24,"value":1963}," sum",{"type":19,"tag":339,"props":1965,"children":1966},{"style":356},[1967],{"type":24,"value":370},{"type":19,"tag":339,"props":1969,"children":1970},{"style":379},[1971],{"type":24,"value":1972}," finite.",{"type":19,"tag":339,"props":1974,"children":1975},{"style":373},[1976],{"type":24,"value":1977},"reduce",{"type":19,"tag":339,"props":1979,"children":1980},{"style":379},[1981],{"type":24,"value":1411},{"type":19,"tag":339,"props":1983,"children":1984},{"style":439},[1985],{"type":24,"value":1986},"s",{"type":19,"tag":339,"props":1988,"children":1989},{"style":379},[1990],{"type":24,"value":1923},{"type":19,"tag":339,"props":1992,"children":1993},{"style":439},[1994],{"type":24,"value":1886},{"type":19,"tag":339,"props":1996,"children":1997},{"style":379},[1998],{"type":24,"value":1933},{"type":19,"tag":339,"props":2000,"children":2001},{"style":356},[2002],{"type":24,"value":632},{"type":19,"tag":339,"props":2004,"children":2005},{"style":379},[2006],{"type":24,"value":1986},{"type":19,"tag":339,"props":2008,"children":2009},{"style":356},[2010],{"type":24,"value":1486},{"type":19,"tag":339,"props":2012,"children":2013},{"style":379},[2014],{"type":24,"value":2015},"x,",{"type":19,"tag":339,"props":2017,"children":2018},{"style":362},[2019],{"type":24,"value":2020},"0",{"type":19,"tag":339,"props":2022,"children":2023},{"style":379},[2024],{"type":24,"value":979},{"type":19,"tag":339,"props":2026,"children":2028},{"class":341,"line":2027},43,[2029,2033,2038,2042,2047,2052,2056,2060,2065,2070,2075,2080,2085,2090,2094,2099,2104,2109,2113],{"type":19,"tag":339,"props":2030,"children":2031},{"style":356},[2032],{"type":24,"value":456},{"type":19,"tag":339,"props":2034,"children":2035},{"style":373},[2036],{"type":24,"value":2037}," p",{"type":19,"tag":339,"props":2039,"children":2040},{"style":356},[2041],{"type":24,"value":370},{"type":19,"tag":339,"props":2043,"children":2044},{"style":379},[2045],{"type":24,"value":2046}," (",{"type":19,"tag":339,"props":2048,"children":2049},{"style":439},[2050],{"type":24,"value":2051},"q",{"type":19,"tag":339,"props":2053,"children":2054},{"style":379},[2055],{"type":24,"value":1421},{"type":19,"tag":339,"props":2057,"children":2058},{"style":356},[2059],{"type":24,"value":632},{"type":19,"tag":339,"props":2061,"children":2062},{"style":379},[2063],{"type":24,"value":2064}," finite[Math.",{"type":19,"tag":339,"props":2066,"children":2067},{"style":373},[2068],{"type":24,"value":2069},"floor",{"type":19,"tag":339,"props":2071,"children":2072},{"style":379},[2073],{"type":24,"value":2074},"(finite.",{"type":19,"tag":339,"props":2076,"children":2077},{"style":362},[2078],{"type":24,"value":2079},"length",{"type":19,"tag":339,"props":2081,"children":2082},{"style":356},[2083],{"type":24,"value":2084}," *",{"type":19,"tag":339,"props":2086,"children":2087},{"style":379},[2088],{"type":24,"value":2089}," q) ",{"type":19,"tag":339,"props":2091,"children":2092},{"style":356},[2093],{"type":24,"value":1220},{"type":19,"tag":339,"props":2095,"children":2096},{"style":362},[2097],{"type":24,"value":2098}," 1",{"type":19,"tag":339,"props":2100,"children":2101},{"style":379},[2102],{"type":24,"value":2103},"] ",{"type":19,"tag":339,"props":2105,"children":2106},{"style":356},[2107],{"type":24,"value":2108},"||",{"type":19,"tag":339,"props":2110,"children":2111},{"style":362},[2112],{"type":24,"value":1351},{"type":19,"tag":339,"props":2114,"children":2115},{"style":379},[2116],{"type":24,"value":1356},{"type":19,"tag":339,"props":2118,"children":2120},{"class":341,"line":2119},44,[2121,2125],{"type":19,"tag":339,"props":2122,"children":2123},{"style":356},[2124],{"type":24,"value":499},{"type":19,"tag":339,"props":2126,"children":2127},{"style":379},[2128],{"type":24,"value":637},{"type":19,"tag":339,"props":2130,"children":2132},{"class":341,"line":2131},45,[2133,2138,2142],{"type":19,"tag":339,"props":2134,"children":2135},{"style":379},[2136],{"type":24,"value":2137},"        count: arr.",{"type":19,"tag":339,"props":2139,"children":2140},{"style":362},[2141],{"type":24,"value":2079},{"type":19,"tag":339,"props":2143,"children":2144},{"style":379},[2145],{"type":24,"value":2146},",\n",{"type":19,"tag":339,"props":2148,"children":2150},{"class":341,"line":2149},46,[2151,2156,2160],{"type":19,"tag":339,"props":2152,"children":2153},{"style":379},[2154],{"type":24,"value":2155},"        ok: finite.",{"type":19,"tag":339,"props":2157,"children":2158},{"style":362},[2159],{"type":24,"value":2079},{"type":19,"tag":339,"props":2161,"children":2162},{"style":379},[2163],{"type":24,"value":2146},{"type":19,"tag":339,"props":2165,"children":2167},{"class":341,"line":2166},47,[2168,2173,2177,2181,2186,2191,2196,2200,2205],{"type":19,"tag":339,"props":2169,"children":2170},{"style":379},[2171],{"type":24,"value":2172},"        p50: ",{"type":19,"tag":339,"props":2174,"children":2175},{"style":373},[2176],{"type":24,"value":20},{"type":19,"tag":339,"props":2178,"children":2179},{"style":379},[2180],{"type":24,"value":382},{"type":19,"tag":339,"props":2182,"children":2183},{"style":362},[2184],{"type":24,"value":2185},"0.5",{"type":19,"tag":339,"props":2187,"children":2188},{"style":379},[2189],{"type":24,"value":2190},").",{"type":19,"tag":339,"props":2192,"children":2193},{"style":373},[2194],{"type":24,"value":2195},"toFixed",{"type":19,"tag":339,"props":2197,"children":2198},{"style":379},[2199],{"type":24,"value":382},{"type":19,"tag":339,"props":2201,"children":2202},{"style":362},[2203],{"type":24,"value":2204},"2",{"type":19,"tag":339,"props":2206,"children":2207},{"style":379},[2208],{"type":24,"value":2209},"),\n",{"type":19,"tag":339,"props":2211,"children":2213},{"class":341,"line":2212},48,[2214,2219,2223,2227,2232,2236,2240,2244,2248],{"type":19,"tag":339,"props":2215,"children":2216},{"style":379},[2217],{"type":24,"value":2218},"        p95: ",{"type":19,"tag":339,"props":2220,"children":2221},{"style":373},[2222],{"type":24,"value":20},{"type":19,"tag":339,"props":2224,"children":2225},{"style":379},[2226],{"type":24,"value":382},{"type":19,"tag":339,"props":2228,"children":2229},{"style":362},[2230],{"type":24,"value":2231},"0.95",{"type":19,"tag":339,"props":2233,"children":2234},{"style":379},[2235],{"type":24,"value":2190},{"type":19,"tag":339,"props":2237,"children":2238},{"style":373},[2239],{"type":24,"value":2195},{"type":19,"tag":339,"props":2241,"children":2242},{"style":379},[2243],{"type":24,"value":382},{"type":19,"tag":339,"props":2245,"children":2246},{"style":362},[2247],{"type":24,"value":2204},{"type":19,"tag":339,"props":2249,"children":2250},{"style":379},[2251],{"type":24,"value":2209},{"type":19,"tag":339,"props":2253,"children":2255},{"class":341,"line":2254},49,[2256,2261,2265,2269,2274,2278,2282,2286,2290],{"type":19,"tag":339,"props":2257,"children":2258},{"style":379},[2259],{"type":24,"value":2260},"        p99: ",{"type":19,"tag":339,"props":2262,"children":2263},{"style":373},[2264],{"type":24,"value":20},{"type":19,"tag":339,"props":2266,"children":2267},{"style":379},[2268],{"type":24,"value":382},{"type":19,"tag":339,"props":2270,"children":2271},{"style":362},[2272],{"type":24,"value":2273},"0.99",{"type":19,"tag":339,"props":2275,"children":2276},{"style":379},[2277],{"type":24,"value":2190},{"type":19,"tag":339,"props":2279,"children":2280},{"style":373},[2281],{"type":24,"value":2195},{"type":19,"tag":339,"props":2283,"children":2284},{"style":379},[2285],{"type":24,"value":382},{"type":19,"tag":339,"props":2287,"children":2288},{"style":362},[2289],{"type":24,"value":2204},{"type":19,"tag":339,"props":2291,"children":2292},{"style":379},[2293],{"type":24,"value":2209},{"type":19,"tag":339,"props":2295,"children":2297},{"class":341,"line":2296},50,[2298,2303,2308,2312,2316,2320,2324,2328,2332],{"type":19,"tag":339,"props":2299,"children":2300},{"style":379},[2301],{"type":24,"value":2302},"        avg: (sum ",{"type":19,"tag":339,"props":2304,"children":2305},{"style":356},[2306],{"type":24,"value":2307},"/",{"type":19,"tag":339,"props":2309,"children":2310},{"style":379},[2311],{"type":24,"value":1972},{"type":19,"tag":339,"props":2313,"children":2314},{"style":362},[2315],{"type":24,"value":2079},{"type":19,"tag":339,"props":2317,"children":2318},{"style":379},[2319],{"type":24,"value":2190},{"type":19,"tag":339,"props":2321,"children":2322},{"style":373},[2323],{"type":24,"value":2195},{"type":19,"tag":339,"props":2325,"children":2326},{"style":379},[2327],{"type":24,"value":382},{"type":19,"tag":339,"props":2329,"children":2330},{"style":362},[2331],{"type":24,"value":2204},{"type":19,"tag":339,"props":2333,"children":2334},{"style":379},[2335],{"type":24,"value":2336},")\n",{"type":19,"tag":339,"props":2338,"children":2340},{"class":341,"line":2339},51,[2341],{"type":19,"tag":339,"props":2342,"children":2343},{"style":379},[2344],{"type":24,"value":2345},"    };\n",{"type":19,"tag":339,"props":2347,"children":2349},{"class":341,"line":2348},52,[2350],{"type":19,"tag":339,"props":2351,"children":2352},{"style":379},[2353],{"type":24,"value":562},{"type":19,"tag":339,"props":2355,"children":2357},{"class":341,"line":2356},53,[2358],{"type":19,"tag":339,"props":2359,"children":2360},{"emptyLinePlaceholder":410},[2361],{"type":24,"value":413},{"type":19,"tag":339,"props":2363,"children":2365},{"class":341,"line":2364},54,[2366,2371,2376,2380,2385],{"type":19,"tag":339,"props":2367,"children":2368},{"style":356},[2369],{"type":24,"value":2370},"if",{"type":19,"tag":339,"props":2372,"children":2373},{"style":379},[2374],{"type":24,"value":2375}," (require.main ",{"type":19,"tag":339,"props":2377,"children":2378},{"style":356},[2379],{"type":24,"value":1700},{"type":19,"tag":339,"props":2381,"children":2382},{"style":362},[2383],{"type":24,"value":2384}," module",{"type":19,"tag":339,"props":2386,"children":2387},{"style":379},[2388],{"type":24,"value":447},{"type":19,"tag":339,"props":2390,"children":2392},{"class":341,"line":2391},55,[2393,2397,2402,2406,2411,2415,2419,2423,2428],{"type":19,"tag":339,"props":2394,"children":2395},{"style":356},[2396],{"type":24,"value":456},{"type":19,"tag":339,"props":2398,"children":2399},{"style":362},[2400],{"type":24,"value":2401}," url",{"type":19,"tag":339,"props":2403,"children":2404},{"style":356},[2405],{"type":24,"value":370},{"type":19,"tag":339,"props":2407,"children":2408},{"style":379},[2409],{"type":24,"value":2410}," process.argv[",{"type":19,"tag":339,"props":2412,"children":2413},{"style":362},[2414],{"type":24,"value":2204},{"type":19,"tag":339,"props":2416,"children":2417},{"style":379},[2418],{"type":24,"value":2103},{"type":19,"tag":339,"props":2420,"children":2421},{"style":356},[2422],{"type":24,"value":2108},{"type":19,"tag":339,"props":2424,"children":2425},{"style":385},[2426],{"type":24,"value":2427}," 'http://localhost:3000/api/generate'",{"type":19,"tag":339,"props":2429,"children":2430},{"style":379},[2431],{"type":24,"value":1356},{"type":19,"tag":339,"props":2433,"children":2435},{"class":341,"line":2434},56,[2436,2440,2445,2449,2454,2459,2464,2468,2472,2476],{"type":19,"tag":339,"props":2437,"children":2438},{"style":356},[2439],{"type":24,"value":456},{"type":19,"tag":339,"props":2441,"children":2442},{"style":362},[2443],{"type":24,"value":2444}," total",{"type":19,"tag":339,"props":2446,"children":2447},{"style":356},[2448],{"type":24,"value":370},{"type":19,"tag":339,"props":2450,"children":2451},{"style":373},[2452],{"type":24,"value":2453}," Number",{"type":19,"tag":339,"props":2455,"children":2456},{"style":379},[2457],{"type":24,"value":2458},"(process.argv[",{"type":19,"tag":339,"props":2460,"children":2461},{"style":362},[2462],{"type":24,"value":2463},"3",{"type":19,"tag":339,"props":2465,"children":2466},{"style":379},[2467],{"type":24,"value":2103},{"type":19,"tag":339,"props":2469,"children":2470},{"style":356},[2471],{"type":24,"value":2108},{"type":19,"tag":339,"props":2473,"children":2474},{"style":362},[2475],{"type":24,"value":1284},{"type":19,"tag":339,"props":2477,"children":2478},{"style":379},[2479],{"type":24,"value":979},{"type":19,"tag":339,"props":2481,"children":2483},{"class":341,"line":2482},57,[2484,2488,2493,2497,2501,2505,2509,2513,2517,2521],{"type":19,"tag":339,"props":2485,"children":2486},{"style":356},[2487],{"type":24,"value":456},{"type":19,"tag":339,"props":2489,"children":2490},{"style":362},[2491],{"type":24,"value":2492}," concurrency",{"type":19,"tag":339,"props":2494,"children":2495},{"style":356},[2496],{"type":24,"value":370},{"type":19,"tag":339,"props":2498,"children":2499},{"style":373},[2500],{"type":24,"value":2453},{"type":19,"tag":339,"props":2502,"children":2503},{"style":379},[2504],{"type":24,"value":2458},{"type":19,"tag":339,"props":2506,"children":2507},{"style":362},[2508],{"type":24,"value":398},{"type":19,"tag":339,"props":2510,"children":2511},{"style":379},[2512],{"type":24,"value":2103},{"type":19,"tag":339,"props":2514,"children":2515},{"style":356},[2516],{"type":24,"value":2108},{"type":19,"tag":339,"props":2518,"children":2519},{"style":362},[2520],{"type":24,"value":1302},{"type":19,"tag":339,"props":2522,"children":2523},{"style":379},[2524],{"type":24,"value":979},{"type":19,"tag":339,"props":2526,"children":2528},{"class":341,"line":2527},58,[2529,2534,2538,2543,2547],{"type":19,"tag":339,"props":2530,"children":2531},{"style":379},[2532],{"type":24,"value":2533},"    (",{"type":19,"tag":339,"props":2535,"children":2536},{"style":356},[2537],{"type":24,"value":422},{"type":19,"tag":339,"props":2539,"children":2540},{"style":379},[2541],{"type":24,"value":2542}," () ",{"type":19,"tag":339,"props":2544,"children":2545},{"style":356},[2546],{"type":24,"value":632},{"type":19,"tag":339,"props":2548,"children":2549},{"style":379},[2550],{"type":24,"value":637},{"type":19,"tag":339,"props":2552,"children":2554},{"class":341,"line":2553},59,[2555,2560,2565,2569,2574],{"type":19,"tag":339,"props":2556,"children":2557},{"style":379},[2558],{"type":24,"value":2559},"        console.",{"type":19,"tag":339,"props":2561,"children":2562},{"style":373},[2563],{"type":24,"value":2564},"log",{"type":19,"tag":339,"props":2566,"children":2567},{"style":379},[2568],{"type":24,"value":382},{"type":19,"tag":339,"props":2570,"children":2571},{"style":385},[2572],{"type":24,"value":2573},"'Run'",{"type":19,"tag":339,"props":2575,"children":2576},{"style":379},[2577],{"type":24,"value":2578},", { url, total, concurrency });\n",{"type":19,"tag":339,"props":2580,"children":2582},{"class":341,"line":2581},60,[2583,2588,2593,2597,2601,2605],{"type":19,"tag":339,"props":2584,"children":2585},{"style":356},[2586],{"type":24,"value":2587},"        const",{"type":19,"tag":339,"props":2589,"children":2590},{"style":362},[2591],{"type":24,"value":2592}," lat",{"type":19,"tag":339,"props":2594,"children":2595},{"style":356},[2596],{"type":24,"value":370},{"type":19,"tag":339,"props":2598,"children":2599},{"style":356},[2600],{"type":24,"value":714},{"type":19,"tag":339,"props":2602,"children":2603},{"style":373},[2604],{"type":24,"value":1258},{"type":19,"tag":339,"props":2606,"children":2607},{"style":379},[2608],{"type":24,"value":2609},"(url, total, concurrency);\n",{"type":19,"tag":339,"props":2611,"children":2613},{"class":341,"line":2612},61,[2614,2618,2622,2626,2631],{"type":19,"tag":339,"props":2615,"children":2616},{"style":379},[2617],{"type":24,"value":2559},{"type":19,"tag":339,"props":2619,"children":2620},{"style":373},[2621],{"type":24,"value":2564},{"type":19,"tag":339,"props":2623,"children":2624},{"style":379},[2625],{"type":24,"value":382},{"type":19,"tag":339,"props":2627,"children":2628},{"style":373},[2629],{"type":24,"value":2630},"stats",{"type":19,"tag":339,"props":2632,"children":2633},{"style":379},[2634],{"type":24,"value":2635},"(lat));\n",{"type":19,"tag":339,"props":2637,"children":2639},{"class":341,"line":2638},62,[2640],{"type":19,"tag":339,"props":2641,"children":2642},{"style":379},[2643],{"type":24,"value":2644},"    })();\n",{"type":19,"tag":339,"props":2646,"children":2648},{"class":341,"line":2647},63,[2649],{"type":19,"tag":339,"props":2650,"children":2651},{"style":379},[2652],{"type":24,"value":562},{"type":19,"tag":20,"props":2654,"children":2655},{},[2656],{"type":24,"value":2657},"运行命令示例：",{"type":19,"tag":329,"props":2659,"children":2663},{"className":2660,"code":2661,"language":2662,"meta":7,"style":7},"language-bash shiki shiki-themes github-dark github-dark","# 在项目中安装依赖（如果没有）\npnpm add -w node-fetch@2\n\n# 运行本地基准：\nnode bench/benchmark-generate.js http://localhost:3000/api/generate 500 50\n","bash",[2664],{"type":19,"tag":127,"props":2665,"children":2666},{"__ignoreMap":7},[2667,2675,2698,2705,2713],{"type":19,"tag":339,"props":2668,"children":2669},{"class":341,"line":342},[2670],{"type":19,"tag":339,"props":2671,"children":2672},{"style":346},[2673],{"type":24,"value":2674},"# 在项目中安装依赖（如果没有）\n",{"type":19,"tag":339,"props":2676,"children":2677},{"class":341,"line":352},[2678,2683,2688,2693],{"type":19,"tag":339,"props":2679,"children":2680},{"style":373},[2681],{"type":24,"value":2682},"pnpm",{"type":19,"tag":339,"props":2684,"children":2685},{"style":385},[2686],{"type":24,"value":2687}," add",{"type":19,"tag":339,"props":2689,"children":2690},{"style":362},[2691],{"type":24,"value":2692}," -w",{"type":19,"tag":339,"props":2694,"children":2695},{"style":385},[2696],{"type":24,"value":2697}," node-fetch@2\n",{"type":19,"tag":339,"props":2699,"children":2700},{"class":341,"line":406},[2701],{"type":19,"tag":339,"props":2702,"children":2703},{"emptyLinePlaceholder":410},[2704],{"type":24,"value":413},{"type":19,"tag":339,"props":2706,"children":2707},{"class":341,"line":416},[2708],{"type":19,"tag":339,"props":2709,"children":2710},{"style":346},[2711],{"type":24,"value":2712},"# 运行本地基准：\n",{"type":19,"tag":339,"props":2714,"children":2715},{"class":341,"line":450},[2716,2721,2726,2731,2736],{"type":19,"tag":339,"props":2717,"children":2718},{"style":373},[2719],{"type":24,"value":2720},"node",{"type":19,"tag":339,"props":2722,"children":2723},{"style":385},[2724],{"type":24,"value":2725}," bench/benchmark-generate.js",{"type":19,"tag":339,"props":2727,"children":2728},{"style":385},[2729],{"type":24,"value":2730}," http://localhost:3000/api/generate",{"type":19,"tag":339,"props":2732,"children":2733},{"style":362},[2734],{"type":24,"value":2735}," 500",{"type":19,"tag":339,"props":2737,"children":2738},{"style":362},[2739],{"type":24,"value":2740}," 50\n",{"type":19,"tag":20,"props":2742,"children":2743},{},[2744],{"type":24,"value":2745},"说明与改进：",{"type":19,"tag":33,"props":2747,"children":2748},{},[2749,2754],{"type":19,"tag":37,"props":2750,"children":2751},{},[2752],{"type":24,"value":2753},"将压力调度到多个并发（concurrency）以观察系统在不同并发度下的延迟与错误率。",{"type":19,"tag":37,"props":2755,"children":2756},{},[2757],{"type":24,"value":2758},"可把请求改为直接调用本地函数以排除网络变量，或通过容器化环境复现生产网络条件。",{"type":19,"tag":27,"props":2760,"children":2762},{"id":2761},"使用-k6-做更接近真实网络的负载测试",[2763],{"type":24,"value":2764},"使用 k6 做更接近真实网络的负载测试",{"type":19,"tag":20,"props":2766,"children":2767},{},[2768,2770,2776],{"type":24,"value":2769},"k6 支持脚本化的 HTTP 负载并在 CI 中集成，适合长期负载测试。示例 ",{"type":19,"tag":127,"props":2771,"children":2773},{"className":2772},[],[2774],{"type":24,"value":2775},"bench/k6-generate.js",{"type":24,"value":2777},"：",{"type":19,"tag":329,"props":2779,"children":2781},{"className":331,"code":2780,"language":333,"meta":7,"style":7},"import http from 'k6/http';\nimport { sleep } from 'k6';\n\nexport let options = {\n    vus: 50,\n    duration: '60s',\n};\n\nexport default function () {\n    const url = __ENV.TARGET_URL || 'http://localhost:3000/api/generate';\n    const payload = JSON.stringify({ templateId: 'demo' });\n    http.post(url, payload, { headers: { 'Content-Type': 'application/json' } });\n    sleep(0.1);\n}\n",[2782],{"type":19,"tag":127,"props":2783,"children":2784},{"__ignoreMap":7},[2785,2812,2837,2844,2870,2887,2904,2912,2919,2940,2978,3019,3053,3074],{"type":19,"tag":339,"props":2786,"children":2787},{"class":341,"line":342},[2788,2793,2798,2803,2808],{"type":19,"tag":339,"props":2789,"children":2790},{"style":356},[2791],{"type":24,"value":2792},"import",{"type":19,"tag":339,"props":2794,"children":2795},{"style":379},[2796],{"type":24,"value":2797}," http ",{"type":19,"tag":339,"props":2799,"children":2800},{"style":356},[2801],{"type":24,"value":2802},"from",{"type":19,"tag":339,"props":2804,"children":2805},{"style":385},[2806],{"type":24,"value":2807}," 'k6/http'",{"type":19,"tag":339,"props":2809,"children":2810},{"style":379},[2811],{"type":24,"value":1356},{"type":19,"tag":339,"props":2813,"children":2814},{"class":341,"line":352},[2815,2819,2824,2828,2833],{"type":19,"tag":339,"props":2816,"children":2817},{"style":356},[2818],{"type":24,"value":2792},{"type":19,"tag":339,"props":2820,"children":2821},{"style":379},[2822],{"type":24,"value":2823}," { sleep } ",{"type":19,"tag":339,"props":2825,"children":2826},{"style":356},[2827],{"type":24,"value":2802},{"type":19,"tag":339,"props":2829,"children":2830},{"style":385},[2831],{"type":24,"value":2832}," 'k6'",{"type":19,"tag":339,"props":2834,"children":2835},{"style":379},[2836],{"type":24,"value":1356},{"type":19,"tag":339,"props":2838,"children":2839},{"class":341,"line":406},[2840],{"type":19,"tag":339,"props":2841,"children":2842},{"emptyLinePlaceholder":410},[2843],{"type":24,"value":413},{"type":19,"tag":339,"props":2845,"children":2846},{"class":341,"line":416},[2847,2852,2857,2862,2866],{"type":19,"tag":339,"props":2848,"children":2849},{"style":356},[2850],{"type":24,"value":2851},"export",{"type":19,"tag":339,"props":2853,"children":2854},{"style":356},[2855],{"type":24,"value":2856}," let",{"type":19,"tag":339,"props":2858,"children":2859},{"style":379},[2860],{"type":24,"value":2861}," options ",{"type":19,"tag":339,"props":2863,"children":2864},{"style":356},[2865],{"type":24,"value":960},{"type":19,"tag":339,"props":2867,"children":2868},{"style":379},[2869],{"type":24,"value":637},{"type":19,"tag":339,"props":2871,"children":2872},{"class":341,"line":450},[2873,2878,2883],{"type":19,"tag":339,"props":2874,"children":2875},{"style":379},[2876],{"type":24,"value":2877},"    vus: ",{"type":19,"tag":339,"props":2879,"children":2880},{"style":362},[2881],{"type":24,"value":2882},"50",{"type":19,"tag":339,"props":2884,"children":2885},{"style":379},[2886],{"type":24,"value":2146},{"type":19,"tag":339,"props":2888,"children":2889},{"class":341,"line":493},[2890,2895,2900],{"type":19,"tag":339,"props":2891,"children":2892},{"style":379},[2893],{"type":24,"value":2894},"    duration: ",{"type":19,"tag":339,"props":2896,"children":2897},{"style":385},[2898],{"type":24,"value":2899},"'60s'",{"type":19,"tag":339,"props":2901,"children":2902},{"style":379},[2903],{"type":24,"value":2146},{"type":19,"tag":339,"props":2905,"children":2906},{"class":341,"line":556},[2907],{"type":19,"tag":339,"props":2908,"children":2909},{"style":379},[2910],{"type":24,"value":2911},"};\n",{"type":19,"tag":339,"props":2913,"children":2914},{"class":341,"line":1175},[2915],{"type":19,"tag":339,"props":2916,"children":2917},{"emptyLinePlaceholder":410},[2918],{"type":24,"value":413},{"type":19,"tag":339,"props":2920,"children":2921},{"class":341,"line":1197},[2922,2926,2931,2935],{"type":19,"tag":339,"props":2923,"children":2924},{"style":356},[2925],{"type":24,"value":2851},{"type":19,"tag":339,"props":2927,"children":2928},{"style":356},[2929],{"type":24,"value":2930}," default",{"type":19,"tag":339,"props":2932,"children":2933},{"style":356},[2934],{"type":24,"value":427},{"type":19,"tag":339,"props":2936,"children":2937},{"style":379},[2938],{"type":24,"value":2939}," () {\n",{"type":19,"tag":339,"props":2941,"children":2942},{"class":341,"line":1228},[2943,2947,2951,2955,2960,2965,2970,2974],{"type":19,"tag":339,"props":2944,"children":2945},{"style":356},[2946],{"type":24,"value":456},{"type":19,"tag":339,"props":2948,"children":2949},{"style":362},[2950],{"type":24,"value":2401},{"type":19,"tag":339,"props":2952,"children":2953},{"style":356},[2954],{"type":24,"value":370},{"type":19,"tag":339,"props":2956,"children":2957},{"style":379},[2958],{"type":24,"value":2959}," __ENV.",{"type":19,"tag":339,"props":2961,"children":2962},{"style":362},[2963],{"type":24,"value":2964},"TARGET_URL",{"type":19,"tag":339,"props":2966,"children":2967},{"style":356},[2968],{"type":24,"value":2969}," ||",{"type":19,"tag":339,"props":2971,"children":2972},{"style":385},[2973],{"type":24,"value":2427},{"type":19,"tag":339,"props":2975,"children":2976},{"style":379},[2977],{"type":24,"value":1356},{"type":19,"tag":339,"props":2979,"children":2980},{"class":341,"line":1236},[2981,2985,2990,2994,2999,3003,3007,3011,3015],{"type":19,"tag":339,"props":2982,"children":2983},{"style":356},[2984],{"type":24,"value":456},{"type":19,"tag":339,"props":2986,"children":2987},{"style":362},[2988],{"type":24,"value":2989}," payload",{"type":19,"tag":339,"props":2991,"children":2992},{"style":356},[2993],{"type":24,"value":370},{"type":19,"tag":339,"props":2995,"children":2996},{"style":362},[2997],{"type":24,"value":2998}," JSON",{"type":19,"tag":339,"props":3000,"children":3001},{"style":379},[3002],{"type":24,"value":509},{"type":19,"tag":339,"props":3004,"children":3005},{"style":373},[3006],{"type":24,"value":1137},{"type":19,"tag":339,"props":3008,"children":3009},{"style":379},[3010],{"type":24,"value":1142},{"type":19,"tag":339,"props":3012,"children":3013},{"style":385},[3014],{"type":24,"value":1147},{"type":19,"tag":339,"props":3016,"children":3017},{"style":379},[3018],{"type":24,"value":403},{"type":19,"tag":339,"props":3020,"children":3021},{"class":341,"line":1244},[3022,3027,3032,3037,3041,3045,3049],{"type":19,"tag":339,"props":3023,"children":3024},{"style":379},[3025],{"type":24,"value":3026},"    http.",{"type":19,"tag":339,"props":3028,"children":3029},{"style":373},[3030],{"type":24,"value":3031},"post",{"type":19,"tag":339,"props":3033,"children":3034},{"style":379},[3035],{"type":24,"value":3036},"(url, payload, { headers: { ",{"type":19,"tag":339,"props":3038,"children":3039},{"style":385},[3040],{"type":24,"value":1157},{"type":19,"tag":339,"props":3042,"children":3043},{"style":379},[3044],{"type":24,"value":1162},{"type":19,"tag":339,"props":3046,"children":3047},{"style":385},[3048],{"type":24,"value":1167},{"type":19,"tag":339,"props":3050,"children":3051},{"style":379},[3052],{"type":24,"value":1172},{"type":19,"tag":339,"props":3054,"children":3055},{"class":341,"line":1309},[3056,3061,3065,3070],{"type":19,"tag":339,"props":3057,"children":3058},{"style":373},[3059],{"type":24,"value":3060},"    sleep",{"type":19,"tag":339,"props":3062,"children":3063},{"style":379},[3064],{"type":24,"value":382},{"type":19,"tag":339,"props":3066,"children":3067},{"style":362},[3068],{"type":24,"value":3069},"0.1",{"type":19,"tag":339,"props":3071,"children":3072},{"style":379},[3073],{"type":24,"value":979},{"type":19,"tag":339,"props":3075,"children":3076},{"class":341,"line":1331},[3077],{"type":19,"tag":339,"props":3078,"children":3079},{"style":379},[3080],{"type":24,"value":562},{"type":19,"tag":20,"props":3082,"children":3083},{},[3084],{"type":24,"value":3085},"运行：",{"type":19,"tag":329,"props":3087,"children":3089},{"className":2660,"code":3088,"language":2662,"meta":7,"style":7},"# 安装 k6 并运行\nk6 run bench/k6-generate.js --env TARGET_URL=http://localhost:3000/api/generate\n",[3090],{"type":19,"tag":127,"props":3091,"children":3092},{"__ignoreMap":7},[3093,3101],{"type":19,"tag":339,"props":3094,"children":3095},{"class":341,"line":342},[3096],{"type":19,"tag":339,"props":3097,"children":3098},{"style":346},[3099],{"type":24,"value":3100},"# 安装 k6 并运行\n",{"type":19,"tag":339,"props":3102,"children":3103},{"class":341,"line":352},[3104,3109,3113,3118,3123],{"type":19,"tag":339,"props":3105,"children":3106},{"style":373},[3107],{"type":24,"value":3108},"k6",{"type":19,"tag":339,"props":3110,"children":3111},{"style":385},[3112],{"type":24,"value":1258},{"type":19,"tag":339,"props":3114,"children":3115},{"style":385},[3116],{"type":24,"value":3117}," bench/k6-generate.js",{"type":19,"tag":339,"props":3119,"children":3120},{"style":362},[3121],{"type":24,"value":3122}," --env",{"type":19,"tag":339,"props":3124,"children":3125},{"style":385},[3126],{"type":24,"value":3127}," TARGET_URL=http://localhost:3000/api/generate\n",{"type":19,"tag":20,"props":3129,"children":3130},{},[3131],{"type":24,"value":3132},"结合 Prometheus/Grafana，可以将 k6 的指标与应用的 APM/系统指标关联，帮助分析延迟来源（CPU、GC、队列积压）。",{"type":19,"tag":27,"props":3134,"children":3136},{"id":3135},"kubernetes-部署与-hpa-示例",[3137],{"type":24,"value":3138},"Kubernetes 部署与 HPA 示例",{"type":19,"tag":20,"props":3140,"children":3141},{},[3142,3144,3150,3152,3158],{"type":24,"value":3143},"在生产或预生产环境中，你可能在 Kubernetes 上运行生成服务。下面是一个最小化 ",{"type":19,"tag":127,"props":3145,"children":3147},{"className":3146},[],[3148],{"type":24,"value":3149},"Deployment",{"type":24,"value":3151}," 与 ",{"type":19,"tag":127,"props":3153,"children":3155},{"className":3154},[],[3156],{"type":24,"value":3157},"HorizontalPodAutoscaler",{"type":24,"value":3159}," 示例，展示资源请求/限制与基于 CPU 的自动扩缩容：",{"type":19,"tag":329,"props":3161,"children":3165},{"className":3162,"code":3163,"language":3164,"meta":7,"style":7},"language-yaml shiki shiki-themes github-dark github-dark","# deployment-generate.yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n    name: generator\nspec:\n    replicas: 2\n    selector:\n        matchLabels:\n            app: generator\n    template:\n        metadata:\n            labels:\n                app: generator\n        spec:\n            containers:\n                - name: generator\n                    image: your-registry/generator:latest\n                    resources:\n                        requests:\n                            cpu: \"500m\"\n                            memory: \"512Mi\"\n                        limits:\n                            cpu: \"2\"\n                            memory: \"2Gi\"\n                    ports:\n                        - containerPort: 3000\n\n---\napiVersion: autoscaling/v2\nkind: HorizontalPodAutoscaler\nmetadata:\n    name: generator-hpa\nspec:\n    scaleTargetRef:\n        apiVersion: apps/v1\n        kind: Deployment\n        name: generator\n    minReplicas: 2\n    maxReplicas: 10\n    metrics:\n        - type: Resource\n            resource:\n                name: cpu\n                target:\n                    type: Utilization\n                    averageUtilization: 60\n","yaml",[3166],{"type":19,"tag":127,"props":3167,"children":3168},{"__ignoreMap":7},[3169,3177,3195,3212,3225,3242,3254,3271,3283,3295,3311,3323,3335,3347,3363,3375,3387,3408,3425,3437,3449,3466,3483,3495,3511,3527,3539,3561,3568,3576,3592,3608,3619,3635,3646,3658,3674,3690,3706,3722,3739,3751,3773,3785,3802,3814,3831],{"type":19,"tag":339,"props":3170,"children":3171},{"class":341,"line":342},[3172],{"type":19,"tag":339,"props":3173,"children":3174},{"style":346},[3175],{"type":24,"value":3176},"# deployment-generate.yaml\n",{"type":19,"tag":339,"props":3178,"children":3179},{"class":341,"line":352},[3180,3186,3190],{"type":19,"tag":339,"props":3181,"children":3183},{"style":3182},"--shiki-default:#85E89D;--shiki-dark:#85E89D",[3184],{"type":24,"value":3185},"apiVersion",{"type":19,"tag":339,"props":3187,"children":3188},{"style":379},[3189],{"type":24,"value":1162},{"type":19,"tag":339,"props":3191,"children":3192},{"style":385},[3193],{"type":24,"value":3194},"apps/v1\n",{"type":19,"tag":339,"props":3196,"children":3197},{"class":341,"line":406},[3198,3203,3207],{"type":19,"tag":339,"props":3199,"children":3200},{"style":3182},[3201],{"type":24,"value":3202},"kind",{"type":19,"tag":339,"props":3204,"children":3205},{"style":379},[3206],{"type":24,"value":1162},{"type":19,"tag":339,"props":3208,"children":3209},{"style":385},[3210],{"type":24,"value":3211},"Deployment\n",{"type":19,"tag":339,"props":3213,"children":3214},{"class":341,"line":416},[3215,3220],{"type":19,"tag":339,"props":3216,"children":3217},{"style":3182},[3218],{"type":24,"value":3219},"metadata",{"type":19,"tag":339,"props":3221,"children":3222},{"style":379},[3223],{"type":24,"value":3224},":\n",{"type":19,"tag":339,"props":3226,"children":3227},{"class":341,"line":450},[3228,3233,3237],{"type":19,"tag":339,"props":3229,"children":3230},{"style":3182},[3231],{"type":24,"value":3232},"    name",{"type":19,"tag":339,"props":3234,"children":3235},{"style":379},[3236],{"type":24,"value":1162},{"type":19,"tag":339,"props":3238,"children":3239},{"style":385},[3240],{"type":24,"value":3241},"generator\n",{"type":19,"tag":339,"props":3243,"children":3244},{"class":341,"line":493},[3245,3250],{"type":19,"tag":339,"props":3246,"children":3247},{"style":3182},[3248],{"type":24,"value":3249},"spec",{"type":19,"tag":339,"props":3251,"children":3252},{"style":379},[3253],{"type":24,"value":3224},{"type":19,"tag":339,"props":3255,"children":3256},{"class":341,"line":556},[3257,3262,3266],{"type":19,"tag":339,"props":3258,"children":3259},{"style":3182},[3260],{"type":24,"value":3261},"    replicas",{"type":19,"tag":339,"props":3263,"children":3264},{"style":379},[3265],{"type":24,"value":1162},{"type":19,"tag":339,"props":3267,"children":3268},{"style":362},[3269],{"type":24,"value":3270},"2\n",{"type":19,"tag":339,"props":3272,"children":3273},{"class":341,"line":1175},[3274,3279],{"type":19,"tag":339,"props":3275,"children":3276},{"style":3182},[3277],{"type":24,"value":3278},"    selector",{"type":19,"tag":339,"props":3280,"children":3281},{"style":379},[3282],{"type":24,"value":3224},{"type":19,"tag":339,"props":3284,"children":3285},{"class":341,"line":1197},[3286,3291],{"type":19,"tag":339,"props":3287,"children":3288},{"style":3182},[3289],{"type":24,"value":3290},"        matchLabels",{"type":19,"tag":339,"props":3292,"children":3293},{"style":379},[3294],{"type":24,"value":3224},{"type":19,"tag":339,"props":3296,"children":3297},{"class":341,"line":1228},[3298,3303,3307],{"type":19,"tag":339,"props":3299,"children":3300},{"style":3182},[3301],{"type":24,"value":3302},"            app",{"type":19,"tag":339,"props":3304,"children":3305},{"style":379},[3306],{"type":24,"value":1162},{"type":19,"tag":339,"props":3308,"children":3309},{"style":385},[3310],{"type":24,"value":3241},{"type":19,"tag":339,"props":3312,"children":3313},{"class":341,"line":1236},[3314,3319],{"type":19,"tag":339,"props":3315,"children":3316},{"style":3182},[3317],{"type":24,"value":3318},"    template",{"type":19,"tag":339,"props":3320,"children":3321},{"style":379},[3322],{"type":24,"value":3224},{"type":19,"tag":339,"props":3324,"children":3325},{"class":341,"line":1244},[3326,3331],{"type":19,"tag":339,"props":3327,"children":3328},{"style":3182},[3329],{"type":24,"value":3330},"        metadata",{"type":19,"tag":339,"props":3332,"children":3333},{"style":379},[3334],{"type":24,"value":3224},{"type":19,"tag":339,"props":3336,"children":3337},{"class":341,"line":1309},[3338,3343],{"type":19,"tag":339,"props":3339,"children":3340},{"style":3182},[3341],{"type":24,"value":3342},"            labels",{"type":19,"tag":339,"props":3344,"children":3345},{"style":379},[3346],{"type":24,"value":3224},{"type":19,"tag":339,"props":3348,"children":3349},{"class":341,"line":1331},[3350,3355,3359],{"type":19,"tag":339,"props":3351,"children":3352},{"style":3182},[3353],{"type":24,"value":3354},"                app",{"type":19,"tag":339,"props":3356,"children":3357},{"style":379},[3358],{"type":24,"value":1162},{"type":19,"tag":339,"props":3360,"children":3361},{"style":385},[3362],{"type":24,"value":3241},{"type":19,"tag":339,"props":3364,"children":3365},{"class":341,"line":1359},[3366,3371],{"type":19,"tag":339,"props":3367,"children":3368},{"style":3182},[3369],{"type":24,"value":3370},"        spec",{"type":19,"tag":339,"props":3372,"children":3373},{"style":379},[3374],{"type":24,"value":3224},{"type":19,"tag":339,"props":3376,"children":3377},{"class":341,"line":1384},[3378,3383],{"type":19,"tag":339,"props":3379,"children":3380},{"style":3182},[3381],{"type":24,"value":3382},"            containers",{"type":19,"tag":339,"props":3384,"children":3385},{"style":379},[3386],{"type":24,"value":3224},{"type":19,"tag":339,"props":3388,"children":3389},{"class":341,"line":1392},[3390,3395,3400,3404],{"type":19,"tag":339,"props":3391,"children":3392},{"style":379},[3393],{"type":24,"value":3394},"                - ",{"type":19,"tag":339,"props":3396,"children":3397},{"style":3182},[3398],{"type":24,"value":3399},"name",{"type":19,"tag":339,"props":3401,"children":3402},{"style":379},[3403],{"type":24,"value":1162},{"type":19,"tag":339,"props":3405,"children":3406},{"style":385},[3407],{"type":24,"value":3241},{"type":19,"tag":339,"props":3409,"children":3410},{"class":341,"line":1432},[3411,3416,3420],{"type":19,"tag":339,"props":3412,"children":3413},{"style":3182},[3414],{"type":24,"value":3415},"                    image",{"type":19,"tag":339,"props":3417,"children":3418},{"style":379},[3419],{"type":24,"value":1162},{"type":19,"tag":339,"props":3421,"children":3422},{"style":385},[3423],{"type":24,"value":3424},"your-registry/generator:latest\n",{"type":19,"tag":339,"props":3426,"children":3427},{"class":341,"line":1451},[3428,3433],{"type":19,"tag":339,"props":3429,"children":3430},{"style":3182},[3431],{"type":24,"value":3432},"                    resources",{"type":19,"tag":339,"props":3434,"children":3435},{"style":379},[3436],{"type":24,"value":3224},{"type":19,"tag":339,"props":3438,"children":3439},{"class":341,"line":1502},[3440,3445],{"type":19,"tag":339,"props":3441,"children":3442},{"style":3182},[3443],{"type":24,"value":3444},"                        requests",{"type":19,"tag":339,"props":3446,"children":3447},{"style":379},[3448],{"type":24,"value":3224},{"type":19,"tag":339,"props":3450,"children":3451},{"class":341,"line":1520},[3452,3457,3461],{"type":19,"tag":339,"props":3453,"children":3454},{"style":3182},[3455],{"type":24,"value":3456},"                            cpu",{"type":19,"tag":339,"props":3458,"children":3459},{"style":379},[3460],{"type":24,"value":1162},{"type":19,"tag":339,"props":3462,"children":3463},{"style":385},[3464],{"type":24,"value":3465},"\"500m\"\n",{"type":19,"tag":339,"props":3467,"children":3468},{"class":341,"line":1556},[3469,3474,3478],{"type":19,"tag":339,"props":3470,"children":3471},{"style":3182},[3472],{"type":24,"value":3473},"                            memory",{"type":19,"tag":339,"props":3475,"children":3476},{"style":379},[3477],{"type":24,"value":1162},{"type":19,"tag":339,"props":3479,"children":3480},{"style":385},[3481],{"type":24,"value":3482},"\"512Mi\"\n",{"type":19,"tag":339,"props":3484,"children":3485},{"class":341,"line":1575},[3486,3491],{"type":19,"tag":339,"props":3487,"children":3488},{"style":3182},[3489],{"type":24,"value":3490},"                        limits",{"type":19,"tag":339,"props":3492,"children":3493},{"style":379},[3494],{"type":24,"value":3224},{"type":19,"tag":339,"props":3496,"children":3497},{"class":341,"line":1606},[3498,3502,3506],{"type":19,"tag":339,"props":3499,"children":3500},{"style":3182},[3501],{"type":24,"value":3456},{"type":19,"tag":339,"props":3503,"children":3504},{"style":379},[3505],{"type":24,"value":1162},{"type":19,"tag":339,"props":3507,"children":3508},{"style":385},[3509],{"type":24,"value":3510},"\"2\"\n",{"type":19,"tag":339,"props":3512,"children":3513},{"class":341,"line":1623},[3514,3518,3522],{"type":19,"tag":339,"props":3515,"children":3516},{"style":3182},[3517],{"type":24,"value":3473},{"type":19,"tag":339,"props":3519,"children":3520},{"style":379},[3521],{"type":24,"value":1162},{"type":19,"tag":339,"props":3523,"children":3524},{"style":385},[3525],{"type":24,"value":3526},"\"2Gi\"\n",{"type":19,"tag":339,"props":3528,"children":3529},{"class":341,"line":1649},[3530,3535],{"type":19,"tag":339,"props":3531,"children":3532},{"style":3182},[3533],{"type":24,"value":3534},"                    ports",{"type":19,"tag":339,"props":3536,"children":3537},{"style":379},[3538],{"type":24,"value":3224},{"type":19,"tag":339,"props":3540,"children":3541},{"class":341,"line":1667},[3542,3547,3552,3556],{"type":19,"tag":339,"props":3543,"children":3544},{"style":379},[3545],{"type":24,"value":3546},"                        - ",{"type":19,"tag":339,"props":3548,"children":3549},{"style":3182},[3550],{"type":24,"value":3551},"containerPort",{"type":19,"tag":339,"props":3553,"children":3554},{"style":379},[3555],{"type":24,"value":1162},{"type":19,"tag":339,"props":3557,"children":3558},{"style":362},[3559],{"type":24,"value":3560},"3000\n",{"type":19,"tag":339,"props":3562,"children":3563},{"class":341,"line":1684},[3564],{"type":19,"tag":339,"props":3565,"children":3566},{"emptyLinePlaceholder":410},[3567],{"type":24,"value":413},{"type":19,"tag":339,"props":3569,"children":3570},{"class":341,"line":1707},[3571],{"type":19,"tag":339,"props":3572,"children":3573},{"style":373},[3574],{"type":24,"value":3575},"---\n",{"type":19,"tag":339,"props":3577,"children":3578},{"class":341,"line":1721},[3579,3583,3587],{"type":19,"tag":339,"props":3580,"children":3581},{"style":3182},[3582],{"type":24,"value":3185},{"type":19,"tag":339,"props":3584,"children":3585},{"style":379},[3586],{"type":24,"value":1162},{"type":19,"tag":339,"props":3588,"children":3589},{"style":385},[3590],{"type":24,"value":3591},"autoscaling/v2\n",{"type":19,"tag":339,"props":3593,"children":3594},{"class":341,"line":1739},[3595,3599,3603],{"type":19,"tag":339,"props":3596,"children":3597},{"style":3182},[3598],{"type":24,"value":3202},{"type":19,"tag":339,"props":3600,"children":3601},{"style":379},[3602],{"type":24,"value":1162},{"type":19,"tag":339,"props":3604,"children":3605},{"style":385},[3606],{"type":24,"value":3607},"HorizontalPodAutoscaler\n",{"type":19,"tag":339,"props":3609,"children":3610},{"class":341,"line":1752},[3611,3615],{"type":19,"tag":339,"props":3612,"children":3613},{"style":3182},[3614],{"type":24,"value":3219},{"type":19,"tag":339,"props":3616,"children":3617},{"style":379},[3618],{"type":24,"value":3224},{"type":19,"tag":339,"props":3620,"children":3621},{"class":341,"line":1761},[3622,3626,3630],{"type":19,"tag":339,"props":3623,"children":3624},{"style":3182},[3625],{"type":24,"value":3232},{"type":19,"tag":339,"props":3627,"children":3628},{"style":379},[3629],{"type":24,"value":1162},{"type":19,"tag":339,"props":3631,"children":3632},{"style":385},[3633],{"type":24,"value":3634},"generator-hpa\n",{"type":19,"tag":339,"props":3636,"children":3637},{"class":341,"line":1770},[3638,3642],{"type":19,"tag":339,"props":3639,"children":3640},{"style":3182},[3641],{"type":24,"value":3249},{"type":19,"tag":339,"props":3643,"children":3644},{"style":379},[3645],{"type":24,"value":3224},{"type":19,"tag":339,"props":3647,"children":3648},{"class":341,"line":1779},[3649,3654],{"type":19,"tag":339,"props":3650,"children":3651},{"style":3182},[3652],{"type":24,"value":3653},"    scaleTargetRef",{"type":19,"tag":339,"props":3655,"children":3656},{"style":379},[3657],{"type":24,"value":3224},{"type":19,"tag":339,"props":3659,"children":3660},{"class":341,"line":1788},[3661,3666,3670],{"type":19,"tag":339,"props":3662,"children":3663},{"style":3182},[3664],{"type":24,"value":3665},"        apiVersion",{"type":19,"tag":339,"props":3667,"children":3668},{"style":379},[3669],{"type":24,"value":1162},{"type":19,"tag":339,"props":3671,"children":3672},{"style":385},[3673],{"type":24,"value":3194},{"type":19,"tag":339,"props":3675,"children":3676},{"class":341,"line":1801},[3677,3682,3686],{"type":19,"tag":339,"props":3678,"children":3679},{"style":3182},[3680],{"type":24,"value":3681},"        kind",{"type":19,"tag":339,"props":3683,"children":3684},{"style":379},[3685],{"type":24,"value":1162},{"type":19,"tag":339,"props":3687,"children":3688},{"style":385},[3689],{"type":24,"value":3211},{"type":19,"tag":339,"props":3691,"children":3692},{"class":341,"line":1810},[3693,3698,3702],{"type":19,"tag":339,"props":3694,"children":3695},{"style":3182},[3696],{"type":24,"value":3697},"        name",{"type":19,"tag":339,"props":3699,"children":3700},{"style":379},[3701],{"type":24,"value":1162},{"type":19,"tag":339,"props":3703,"children":3704},{"style":385},[3705],{"type":24,"value":3241},{"type":19,"tag":339,"props":3707,"children":3708},{"class":341,"line":1818},[3709,3714,3718],{"type":19,"tag":339,"props":3710,"children":3711},{"style":3182},[3712],{"type":24,"value":3713},"    minReplicas",{"type":19,"tag":339,"props":3715,"children":3716},{"style":379},[3717],{"type":24,"value":1162},{"type":19,"tag":339,"props":3719,"children":3720},{"style":362},[3721],{"type":24,"value":3270},{"type":19,"tag":339,"props":3723,"children":3724},{"class":341,"line":1826},[3725,3730,3734],{"type":19,"tag":339,"props":3726,"children":3727},{"style":3182},[3728],{"type":24,"value":3729},"    maxReplicas",{"type":19,"tag":339,"props":3731,"children":3732},{"style":379},[3733],{"type":24,"value":1162},{"type":19,"tag":339,"props":3735,"children":3736},{"style":362},[3737],{"type":24,"value":3738},"10\n",{"type":19,"tag":339,"props":3740,"children":3741},{"class":341,"line":1853},[3742,3747],{"type":19,"tag":339,"props":3743,"children":3744},{"style":3182},[3745],{"type":24,"value":3746},"    metrics",{"type":19,"tag":339,"props":3748,"children":3749},{"style":379},[3750],{"type":24,"value":3224},{"type":19,"tag":339,"props":3752,"children":3753},{"class":341,"line":1953},[3754,3759,3764,3768],{"type":19,"tag":339,"props":3755,"children":3756},{"style":379},[3757],{"type":24,"value":3758},"        - ",{"type":19,"tag":339,"props":3760,"children":3761},{"style":3182},[3762],{"type":24,"value":3763},"type",{"type":19,"tag":339,"props":3765,"children":3766},{"style":379},[3767],{"type":24,"value":1162},{"type":19,"tag":339,"props":3769,"children":3770},{"style":385},[3771],{"type":24,"value":3772},"Resource\n",{"type":19,"tag":339,"props":3774,"children":3775},{"class":341,"line":2027},[3776,3781],{"type":19,"tag":339,"props":3777,"children":3778},{"style":3182},[3779],{"type":24,"value":3780},"            resource",{"type":19,"tag":339,"props":3782,"children":3783},{"style":379},[3784],{"type":24,"value":3224},{"type":19,"tag":339,"props":3786,"children":3787},{"class":341,"line":2119},[3788,3793,3797],{"type":19,"tag":339,"props":3789,"children":3790},{"style":3182},[3791],{"type":24,"value":3792},"                name",{"type":19,"tag":339,"props":3794,"children":3795},{"style":379},[3796],{"type":24,"value":1162},{"type":19,"tag":339,"props":3798,"children":3799},{"style":385},[3800],{"type":24,"value":3801},"cpu\n",{"type":19,"tag":339,"props":3803,"children":3804},{"class":341,"line":2131},[3805,3810],{"type":19,"tag":339,"props":3806,"children":3807},{"style":3182},[3808],{"type":24,"value":3809},"                target",{"type":19,"tag":339,"props":3811,"children":3812},{"style":379},[3813],{"type":24,"value":3224},{"type":19,"tag":339,"props":3815,"children":3816},{"class":341,"line":2149},[3817,3822,3826],{"type":19,"tag":339,"props":3818,"children":3819},{"style":3182},[3820],{"type":24,"value":3821},"                    type",{"type":19,"tag":339,"props":3823,"children":3824},{"style":379},[3825],{"type":24,"value":1162},{"type":19,"tag":339,"props":3827,"children":3828},{"style":385},[3829],{"type":24,"value":3830},"Utilization\n",{"type":19,"tag":339,"props":3832,"children":3833},{"class":341,"line":2166},[3834,3839,3843],{"type":19,"tag":339,"props":3835,"children":3836},{"style":3182},[3837],{"type":24,"value":3838},"                    averageUtilization",{"type":19,"tag":339,"props":3840,"children":3841},{"style":379},[3842],{"type":24,"value":1162},{"type":19,"tag":339,"props":3844,"children":3845},{"style":362},[3846],{"type":24,"value":3847},"60\n",{"type":19,"tag":20,"props":3849,"children":3850},{},[3851],{"type":24,"value":3852},"要点说明：",{"type":19,"tag":33,"props":3854,"children":3855},{},[3856,3877],{"type":19,"tag":37,"props":3857,"children":3858},{},[3859,3861,3867,3869,3875],{"type":24,"value":3860},"资源 ",{"type":19,"tag":127,"props":3862,"children":3864},{"className":3863},[],[3865],{"type":24,"value":3866},"requests",{"type":24,"value":3868}," 应反映单实例在正常工作负载下的保守消耗，",{"type":19,"tag":127,"props":3870,"children":3872},{"className":3871},[],[3873],{"type":24,"value":3874},"limits",{"type":24,"value":3876}," 则为峰值保护。HPA 基于 CPU 或自定义指标（例如队列深度、请求率）更精细。",{"type":19,"tag":37,"props":3878,"children":3879},{},[3880],{"type":24,"value":3881},"为交互型低延迟请求考虑单独的服务或优先级队列，避免批处理占满 Pod 资源。",{"type":19,"tag":27,"props":3883,"children":3885},{"id":3884},"运行基准并解释结果的快速流程",[3886],{"type":24,"value":3884},{"type":19,"tag":113,"props":3888,"children":3889},{},[3890,3903,3915,3920],{"type":19,"tag":37,"props":3891,"children":3892},{},[3893,3895,3901],{"type":24,"value":3894},"在本地用 ",{"type":19,"tag":127,"props":3896,"children":3898},{"className":3897},[],[3899],{"type":24,"value":3900},"benchmark-generate.js",{"type":24,"value":3902}," 对单节点做初步测量（排除网络抖动）。",{"type":19,"tag":37,"props":3904,"children":3905},{},[3906,3908,3913],{"type":24,"value":3907},"使用 ",{"type":19,"tag":127,"props":3909,"children":3911},{"className":3910},[],[3912],{"type":24,"value":3108},{"type":24,"value":3914}," 模拟真实网络并发，观察系统在 1min/5min 平均下的 P95/P99 变化。",{"type":19,"tag":37,"props":3916,"children":3917},{},[3918],{"type":24,"value":3919},"将 k6 指标与 Prometheus 指标结合，定位是否为 CPU、GC、I/O 或外部依赖导致延迟。",{"type":19,"tag":37,"props":3921,"children":3922},{},[3923],{"type":24,"value":3924},"逐项应用优化（缓存、并行、池化），每次在 CI 或预生产上回放基准，确保没有回归。",{"type":19,"tag":27,"props":3926,"children":3928},{"id":3927},"示例结果解读",[3929],{"type":24,"value":3927},{"type":19,"tag":33,"props":3931,"children":3932},{},[3933,3938],{"type":19,"tag":37,"props":3934,"children":3935},{},[3936],{"type":24,"value":3937},"如果 P95 / P99 明显高于 P50，说明尾延迟问题，优先排查 GC、队列积压与外部调用超时。",{"type":19,"tag":37,"props":3939,"children":3940},{},[3941],{"type":24,"value":3942},"吞吐上不去但 CPU 利用率低，表示存在串行瓶颈或 I/O 阻塞（观察 syscalls 与 iowait）。",{"type":19,"tag":3944,"props":3945,"children":3946},"style",{},[3947],{"type":24,"value":3948},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":7,"searchDepth":406,"depth":406,"links":3950},[3951,3952,3953,3954,3962,3963,3964,3965,3966,3967,3968,3969,3970,3971,3972],{"id":29,"depth":352,"text":29},{"id":60,"depth":352,"text":63},{"id":109,"depth":352,"text":109},{"id":175,"depth":352,"text":178,"children":3955},[3956,3957,3958,3959,3960,3961],{"id":182,"depth":406,"text":185},{"id":221,"depth":406,"text":224},{"id":250,"depth":406,"text":253},{"id":272,"depth":406,"text":275},{"id":286,"depth":406,"text":289},{"id":300,"depth":406,"text":303},{"id":314,"depth":352,"text":317},{"id":773,"depth":352,"text":773},{"id":791,"depth":352,"text":791},{"id":829,"depth":352,"text":829},{"id":842,"depth":352,"text":842},{"id":852,"depth":352,"text":852},{"id":897,"depth":352,"text":900},{"id":2761,"depth":352,"text":2764},{"id":3135,"depth":352,"text":3138},{"id":3884,"depth":352,"text":3884},{"id":3927,"depth":352,"text":3927},"markdown","content:blog:code-generation-speed.md","content","blog/code-generation-speed.md","blog/code-generation-speed","md",[3980,3988,3996],{"_path":3981,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":3982,"description":3983,"keywords":3984,"author":11,"date":12,"category":13,"image":14,"_type":3973,"_id":3985,"_source":3975,"_file":3986,"_stem":3987,"_extension":3978},"/blog/2025-q1-updates","2025 Q1 产品更新","第一季度重大功能发布：AI 生成优化、新模板上线、编辑器增强等","2025 Q1 产品更新, Blog, HTMLPAGE","content:blog:2025-q1-updates.md","blog/2025-q1-updates.md","blog/2025-q1-updates",{"_path":3989,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":3990,"description":3991,"keywords":3992,"author":11,"date":12,"category":13,"image":14,"_type":3973,"_id":3993,"_source":3975,"_file":3994,"_stem":3995,"_extension":3978},"/blog/2025-roadmap","2025 产品路线图","展望 2025 年的产品规划：AI 能力增强、模板扩充、国际化等","2025 产品路线图, Blog, HTMLPAGE","content:blog:2025-roadmap.md","blog/2025-roadmap.md","blog/2025-roadmap",{"_path":3997,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":3998,"description":3999,"keywords":4000,"author":11,"date":12,"category":13,"image":14,"_type":3973,"_id":4001,"_source":3975,"_file":4002,"_stem":4003,"_extension":3978},"/blog/ab-testing","A/B 测试","通过 A/B 测试验证设计方案","A/B 测试, Blog, HTMLPAGE","content:blog:ab-testing.md","blog/ab-testing.md","blog/ab-testing",1774945286106]