| 12 |
- import{d as T,c as n,S as A,Q as F,f as H,b4 as N,h as _,o as P,Z as d,a1 as f,a7 as a,ay as m,a6 as i,a9 as z,a5 as B,n as G,T as w,b8 as M,C as $,at as O}from"./index-8a67e3df.js";import{R as q,a as K,r as R}from"./pan-3c2a437f.js";import{g as j,a as E}from"./debug-d93946e9.js";import{u as Z}from"./index-c6560d80.js";import"./dayjs-919e6097.js";const I={class:"view-controls"},L={class:"heap-stats"},U={key:0},Q={key:1,class:"text-view"},W=T({__name:"heap",setup(J){const l=n(),o=n("graph"),u=n([]),x=n(null),s=n(null),k=A(),{getDarkMode:b}=F(k),v=H(()=>b.value===N.DARK),C=()=>{R()};_(v,e=>{o.value==="graph"&&(s.value&&s.value.querySelector("svg")?y(s.value.querySelector("svg")):p())}),_(o,e=>{e==="graph"?p():(u.value,$(()=>{V(u.value),u.value}))});const h=Z();P(async()=>{try{const e=await j();l.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 E();q().then(t=>{if(!s.value)return;s.value.innerHTML="";const r=t.renderSVGElement(e);y(r),s.value.appendChild(r),K(r)})}catch(e){console.error("Failed to render graph:",e)}}function y(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",I,[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",L,[t[2]||(t[2]=a("h3",null,"Heap Statistics",-1)),l.value?(d(),f("div",U,[a("div",null,"Total Alloc: "+i(l.value.totalAlloc),1),a("div",null,"Heap Alloc: "+i(l.value.heapAlloc),1),a("div",null,"Heap Objects: "+i(l.value.heapObjects),1),a("div",null,"GC CPU Fraction: "+i(l.value.gcCPUFraction.toFixed(4)),1),a("div",null,"Number of GCs: "+i(l.value.numGC),1)])):z("",!0)]),o.value==="graph"?(d(),f("div",{key:0,class:"viz-container",ref_key:"vizContainer",ref:x},[a("button",{class:"reset-btn",onClick:C},t[3]||(t[3]=[a("i",{class:"el-icon-refresh"},null,-1),B(" 重置视图 ")])),a("div",{class:"main-view",ref_key:"mainView",ref:s},null,512)],512)):(d(),f("div",Q,[G(w(M),{uid:w(h).uid,gridOptions:D},null,8,["uid"])]))],2))}});const oe=O(W,[["__scopeId","data-v-d7d6a02a"]]);export{oe as default};
- //# sourceMappingURL=heap-d011fed6.js.map
|