import{p as e}from"./nc-util.BWncs0l6.js";import{createCommentVNode as t,createElementBlock as n,createElementVNode as r,createTextVNode as i,onMounted as a,openBlock as o,ref as s,toDisplayString as c,unref as l}from"/vue.js";var u={key:0,style:{color:`red`}},d=[`disabled`],f={style:{"font-weight":`bold`}},p=!0,m=1e5,h=256,g=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,_=Object.assign({name:`measure-memory`},{__name:`measure-memory`,setup(_){var v;let y=!((v=window.performance)!=null&&v.memory);y&&(y=e.isSafari()?`Safari`:e.isFirefox()?`Firefox`:`unknown browser`);let b=s(!0),x=s([]),S=s([]),C=s(0),w=s(0),T=s(0),E=s(0),D=s(0),O=s(0),k=s(0),A=new Intl.NumberFormat(`fi-FI`,{maximumSignificantDigits:6}).format;async function j(e,t){var n,r;if(t&&(n=window.performance)!=null&&n.measureUserAgentSpecificMemory){let t=await performance.measureUserAgentSpecificMemory();if(console.debug(`🚀 ~ measureUserAgentSpecificMemory:`,t),t.bytes)return Math.round((t.bytes/1e3**2-e)*10)/10}return(r=window.performance)!=null&&r.memory?Math.round((window.performance.memory.usedJSHeapSize/1e3**2-e)*10)/10:0}async function M(){C.value=await j(0,!0),w.value=await j(0)}a(()=>{b.value=!0,M(),b.value=!1});function N(){let e=``;for(let t=0;t<h;t++)e+=g.charAt(Math.floor(Math.random()*62));return e}async function P(e){b.value=!0,e&&e.preventDefault();let t=new Date().getMilliseconds();k.value+=m,C.value===0&&M();for(let e=0;e<m;e++)t+=864e5,x.value.push({date:t,text:N()});setTimeout(async()=>{T.value=await j(0,!0),E.value=await j(0);for(let e=0;e<k.value;e+=1)S[e]=x.value[e];setTimeout(async()=>{D.value=await j(T.value,!0),O.value=await j(T.value),b.value=!1},400)},400)}return(e,a)=>(o(),n(`div`,null,[a[3]||(a[3]=r(`h2`,null,`Memory Consumption Demo`,-1)),l(y)?(o(),n(`h3`,u,`Results do not show in `+c(l(y))+` because window.performance is not supported.`,1)):t(``,!0),r(`p`,null,[a[0]||(a[0]=i(` Click the button to measure memory consumption: `,-1)),r(`button`,{disabled:l(b),onClick:P},`Remeasure Memory`,8,d)]),r(`p`,null,[a[1]||(a[1]=i(` Test with `,-1)),r(`b`,null,`pointer array: `+c(p)+`, characters `+c(h)),i(`, using \xA0 `+c(l(A)(l(k)))+` element array `,1)]),r(`p`,null,`Memory consumption before creating first array:\xA0 \xA0 \xA0 \xA0 \xA0 \xA0 `+c(l(A)(l(C)))+` / `+c(l(A)(l(w)))+` MB.`,1),r(`p`,null,` Additional memory consumption after creating 1. normal array: `+c(l(A)(l(T)))+` / `+c(l(A)(l(E)))+` MB. `,1),r(`p`,null,[a[2]||(a[2]=i(` Additional memory consumption after creating 2. `,-1)),r(`span`,f,c(`pointer`),1),i(` array: `+c(l(A)(l(D)))+` / `+c(l(A)(l(O)))+` MB. `,1)])]))}});export{_ as default};