1 |
- import{d as T,k as i,e as A,w as y,q as F,o as H,X as d,a6 as f,a9 as a,a7 as m,_ as n,aa as N,E as P,f as z,u as w}from"./vue-fae2b924.js";import{R as B,a as G,r as M}from"./pan-ce4f7391.js";import{g as $,a as q}from"./debug-bc334308.js";import{k as O}from"./index-7a259168.js";import{u as E}from"./index-ac72395e.js";import{u as K,s as R,T as j,V as I}from"./radical-e583b742.js";const L={class:"view-controls"},U={class:"heap-stats"},Z={key:0},W={key:1,class:"text-view"},X=T({__name:"heap",setup(J){const s=i(),o=i("graph"),u=i([]),k=i(null),l=i(null),x=K(),{getDarkMode:C}=R(x),v=A(()=>C.value===j.DARK),b=()=>{M()};y(v,e=>{o.value==="graph"&&(l.value&&l.value.querySelector("svg")?_(l.value.querySelector("svg")):p())}),y(o,e=>{e==="graph"?p():(u.value,F(()=>{V(u.value),u.value}))});const h=E();H(async()=>{try{const e=await $();s.value=e.stats,u.value=e.objects,p()}catch(e){console.error("Failed to load heap data:",e)}});const V=e=>{e.length>1&&h.tableRef.reloadData(e)};function g(e){return e=Number(e),e<1024?`${e.toFixed(1)}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}async function p(){try{const e=await q();B().then(t=>{if(!l.value)return;l.value.innerHTML="";const r=t.renderSVGElement(e);_(r),l.value.appendChild(r),G(r)})}catch(e){console.error("Failed to render graph:",e)}}function _(e){if(!e)return;const t=v.value;e.style.backgroundColor=t?"var(--layout-background)":"#f8f8f8";const r=e.querySelectorAll("polygon, ellipse"),S=e.querySelectorAll("text");r.forEach(c=>{c.setAttribute("fill",t?"#1f1f1f":"#ffffff"),c.setAttribute("stroke",t?"#aaaaaa":"#000000")}),S.forEach(c=>{c.setAttribute("fill",t?"var(--text-color)":"#000000")})}const D={maxHeight:"100%",rowConfig:{keyField:"type",useKey:!0,className:()=>v.value?"dark-row":"",isHover:!0},columnConfig:{useKey:!0},columns:[{field:"type",title:"type",showOverflow:"tooltip",minWidth:"150px"},{field:"count",title:"count",showOverflow:"tooltip"},{field:"size",title:"size",formatter:({row:e})=>g(e.size)},{field:"sizePerc",title:"sizePerc",formatter:({row:e})=>g(e.sizePerc)},{field:"refs",title:"depth",formatter:({row:e})=>e.refs.length}],data:[]};return(e,t)=>(d(),f("div",{class:m(["heap-container",{"graph-view":o.value==="graph"}])},[a("div",L,[a("button",{class:m({active:o.value==="graph"}),onClick:t[0]||(t[0]=r=>o.value="graph")}," Graph View ",2),a("button",{class:m({active:o.value==="text"}),onClick:t[1]||(t[1]=r=>o.value="text")}," Text View ",2)]),a("div",U,[t[2]||(t[2]=a("h3",null,"Heap Statistics",-1)),s.value?(d(),f("div",Z,[a("div",null,"Total Alloc: "+n(s.value.totalAlloc),1),a("div",null,"Heap Alloc: "+n(s.value.heapAlloc),1),a("div",null,"Heap Objects: "+n(s.value.heapObjects),1),a("div",null,"GC CPU Fraction: "+n(s.value.gcCPUFraction.toFixed(4)),1),a("div",null,"Number of GCs: "+n(s.value.numGC),1)])):N("",!0)]),o.value==="graph"?(d(),f("div",{key:0,class:"viz-container",ref_key:"vizContainer",ref:k},[a("button",{class:"reset-btn",onClick:b},t[3]||(t[3]=[a("i",{class:"el-icon-refresh"},null,-1),P(" 重置视图 ")])),a("div",{class:"main-view",ref_key:"mainView",ref:l},null,512)],512)):(d(),f("div",W,[z(w(O),{uid:w(h).uid,gridOptions:D},null,8,["uid"])]))],2))}});const se=I(X,[["__scopeId","data-v-d7d6a02a"]]);export{se as default};
|