import{n as o,a_ as B,d as te,c as v,S as ne,Q as ae,f as le,b4 as re,h as M,o as oe,j as ie,Z as y,$ as R,a0 as u,a7 as s,a5 as C,a9 as x,ay as T,a1 as k,a6 as g,T as m,ck as P,D as se,b8 as ue,C as ce,aP as de,a4 as fe,M as ve,x as me,cl as pe,at as ge}from"./index-8a67e3df.js";/* empty css */import{R as _e,a as be,r as ye}from"./pan-3c2a437f.js";import{b as j,c as F}from"./debug-d93946e9.js";import{u as Ce}from"./index-c6560d80.js";import"./dayjs-919e6097.js";import{_ as he}from"./index-66456a53.js";var we={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"}}]},name:"reload",theme:"outlined"};const Oe=we;function U(r){for(var n=1;nq.value===re.DARK),d=v({samplingIntervalNs:"0",goroutines:[],functions:[],runtimeStats:{blockingTimeNs:"",gcCount:"",gcCpuFraction:0,gcPauseTimeNs:""}}),L=v(null),p=v(null),G=()=>{ye()},O=v("");M(S,e=>{f.value==="graph"&&(p.value&&p.value.querySelector("svg")?$(p.value.querySelector("svg")):N())}),M(f,e=>{e==="graph"?N():ce(()=>{H(d.value)})});const I=Ce();oe(async()=>{try{n.value=!0,await N()}catch(e){console.error("Failed to load heap data:",e)}finally{n.value=!1;const e=await j();d.value=e}});const H=e=>{const t=[e];t.length>0&&I.tableRef.reloadData(t)},V=e=>`${(e*1e4).toFixed(3)}‰`,_=(e,t)=>{if(t==="s")return Number(e)/1e6+"秒";if(t==="ns")return Number(e)+"纳秒";if(t==="ms")return(Number(e)/1e3).toFixed(2)+"毫秒"};async function N(){try{O.value||(O.value=await F()),_e().then(e=>{if(!p.value)return;p.value.innerHTML="";const t=e.renderSVGElement(O.value);$(t),p.value.appendChild(t),be(t)})}catch(e){console.error("Failed to render graph:",e)}}function $(e){if(!e)return;const t=S.value;e.style.backgroundColor=t?"var(--layout-background)":"#f8f8f8";const h=e.querySelectorAll("polygon, ellipse"),w=e.querySelectorAll("text");h.forEach(b=>{b.setAttribute("fill",t?"#1f1f1f":"#ffffff"),b.setAttribute("stroke",t?"#aaaaaa":"#000000")}),w.forEach(b=>{b.setAttribute("fill",t?"var(--text-color)":"#000000")})}const Z={maxHeight:"100%",rowConfig:{className:()=>S.value?"dark-row":"",isHover:!0},columnConfig:{useKey:!0},columns:[{field:"samplingIntervalNs",title:"采样间隔",formatter:({row:e})=>_(e.samplingIntervalNs,"s")},{field:"gcCpuFraction",title:"垃圾回收占用CPU时间比例",formatter:({row:e})=>V(e.runtimeStats.gcCpuFraction),minWidth:"100px"},{field:"gcCount",title:"垃圾回收次数",formatter:({row:e})=>e.runtimeStats.gcCount},{field:"blockingTimeNs",title:"阻塞时间",formatter:({row:e})=>_(e.runtimeStats.blockingTimeNs,"ns")},{field:"gcPauseTimeNs",title:"垃圾回收暂停时间",formatter:({row:e})=>_(e.runtimeStats.gcPauseTimeNs,"ms")},{field:"functions",title:"函数调用栈数量",formatter:({row:e})=>e.functions.length||0},{field:"goroutines",title:"协程数量",formatter:({row:e})=>e.goroutines.length||0}],data:[]},Q=({key:e})=>{W(Number(e))},W=async(e=10)=>{try{n.value=!0,O.value="",c&&c.abort(),c=new AbortController,a.value=e,l&&clearInterval(l),l=setInterval(()=>{a.value>0?(a.value--,i.value=`正在分析,距离完成还剩 ${a.value} 秒...`):l&&(clearInterval(l),l=null)},1e3),await F(!0,e,c.signal);const t=await j();d.value=t}catch(t){t.name==="AbortError"||console.error("Failed to reload data:",t)}finally{l&&(clearInterval(l),l=null),n.value=!1,i.value="正在分析,请稍等...",c=null}},J=()=>{l&&(clearInterval(l),l=null),c&&(c.abort(),c=null),n.value=!1,a.value=0,i.value="正在分析,请稍等..."};return ie(()=>{l&&(clearInterval(l),l=null),c&&(c.abort(),c=null)}),(e,t)=>{const h=de,w=fe,b=ve,X=me,Y=he,K=pe;return y(),R(K,{spinning:n.value,tip:i.value},{indicator:u(()=>[s("div",De,[a.value>0?(y(),R(h,{key:0,type:"danger",onClick:J},{default:u(()=>t[2]||(t[2]=[C(" 取消分析 ")])),_:1})):x("",!0)])]),default:u(()=>[s("div",{class:T(["heap-container",{"graph-view":f.value==="graph"}])},[s("div",Ae,[s("button",{class:T({active:f.value==="graph"}),onClick:t[0]||(t[0]=ee=>f.value="graph")}," Graph View ",2),s("button",{class:T({active:f.value==="text"}),onClick:t[1]||(t[1]=ee=>f.value="text")}," Text View ",2)]),!n.value&&f.value==="graph"?(y(),k("div",Ie,[t[3]||(t[3]=s("h3",null,"Cpu Statistics",-1)),d.value.samplingIntervalNs?(y(),k("div",Ve,[s("div",null," 采样间隔: "+g(_(d.value.samplingIntervalNs,"s")),1),s("div",null," 垃圾回收占用CPU时间比例: "+g(V(d.value.runtimeStats.gcCpuFraction)),1),s("div",null,"垃圾回收次数: "+g(d.value.runtimeStats.gcCount),1),s("div",null," 阻塞时间: "+g(_(d.value.runtimeStats.blockingTimeNs,"ns")),1),s("div",null," 垃圾回收暂停时间: "+g(_(d.value.runtimeStats.gcPauseTimeNs,"ms")),1),s("div",null,"函数调用栈数量: "+g(d.value.functions.length),1),s("div",null,"协程数量: "+g(d.value.goroutines.length),1)])):x("",!0)])):x("",!0),f.value==="graph"?(y(),k("div",{key:1,class:"viz-container",ref_key:"vizContainer",ref:L},[s("div",$e,[o(Y,null,{default:u(()=>[o(h,{class:"reset-btn",onClick:G},{icon:u(()=>[o(m(Pe))]),default:u(()=>[t[4]||(t[4]=C(" 重置视图 "))]),_:1}),o(X,null,{overlay:u(()=>[o(b,{onClick:Q},{default:u(()=>[o(w,{key:"10"},{default:u(()=>[o(m(P)),t[6]||(t[6]=C(" 10秒 "))]),_:1}),o(w,{key:"30"},{default:u(()=>[o(m(P)),t[7]||(t[7]=C(" 30秒 "))]),_:1}),o(w,{key:"60"},{default:u(()=>[o(m(P)),t[8]||(t[8]=C(" 1分钟 "))]),_:1})]),_:1})]),default:u(()=>[o(h,{type:"primary"},{icon:u(()=>[o(m(Se))]),default:u(()=>[t[5]||(t[5]=C(" 重新分析 ")),o(m(se))]),_:1})]),_:1})]),_:1})]),s("div",{class:"main-view",ref_key:"mainView",ref:p},null,512)],512)):(y(),k("div",Me,[o(m(ue),{uid:m(I).uid,gridOptions:Z},null,8,["uid"])]))],2)]),_:1},8,["spinning","tip"])}}});const Le=ge(Re,[["__scopeId","data-v-570f1997"]]);export{Le as default}; //# sourceMappingURL=cpu-8a0ed830.js.map