1import{i as p,k as U,l as k,J as a,C as x}from"./index-BETrnd6b.js";const y=["Tech","Finance","Healthcare","Consumer","Energy"];function f(o){return Array.from({length:o},(e,t)=>({id:t+1,symbol:`STK${t}`,name:`Stock ${t}`,price:100+Math.random()*900,change:(Math.random()-.5)*50,changePercent:(Math.random()-.5)*5,volume:Math.floor(Math.random()*1e8),high:100+Math.random()*950,low:50+Math.random()*900,open:100+Math.random()*900,marketCap:Math.floor(Math.random()*3e12),pe:5+Math.random()*95,sector:y[t%y.length]}))}const $=["price","change","changePercent","volume","high","low","pe"];function g(){return $[Math.floor(Math.random()*$.length)]}function w(o){switch(o){case"price":return Math.round((10+Math.random()*990)*100)/100;case"change":return Math.round((Math.random()-.5)*100*100)/100;case"changePercent":return Math.round((Math.random()-.5)*10*100)/100;case"volume":return Math.floor(Math.random()*1e8);case"high":case"low":return Math.round((10+Math.random()*990)*100)/100;case"pe":return Math.round((5+Math.random()*95)*10)/10;default:return 0}}async function M(o){await U();const e=k(o),t=e.createTable("stocks").column("id",a.Int64,new x().primaryKey(!0)).column("symbol",a.String,null).column("name",a.String,null).column("price",a.Float64,null).column("change",a.Float64,null).column("changePercent",a.Float64,null).column("volume",a.Int64,null).column("high",a.Float64,null).column("low",a.Float64,null).column("open",a.Float64,null).column("marketCap",a.Int64,null).column("pe",a.Float64,null).column("sector",a.String,null);return e.registerTable(t),e}const h=[];async function T(o,e){const t=await M(`raw_${o}_${e}_${Date.now()}`);await t.insert("stocks").values(f(o)).exec();const n=100,c=100,l=c*e,m=performance.now();for(let r=0;r<c;r++)for(let u=0;u<e;u++){const d=Math.floor(Math.random()*n)+1,i=g();await t.update("stocks").set(i,w(i)).where(p("id").eq(d)).exec()}const s=performance.now()-m;return{name:"Raw Update (no live query)",totalRows:o,batchSize:e,totalUpdates:l,durationMs:s,updatesPerSec:l/(s/1e3),avgUpdateMs:s/l}}async function P(o,e){const t=await M(`livenosub_${o}_${e}_${Date.now()}`);await t.insert("stocks").values(f(o)).exec();const n=100;t.select("*").from("stocks").limit(n).observe();const c=100,l=c*e,m=performance.now();for(let r=0;r<c;r++)for(let u=0;u<e;u++){const d=Math.floor(Math.random()*n)+1,i=g();await t.update("stocks").set(i,w(i)).where(p("id").eq(d)).exec()}const s=performance.now()-m;return{name:"Update (live query exists, no subscribe)",totalRows:o,batchSize:e,totalUpdates:l,durationMs:s,updatesPerSec:l/(s/1e3),avgUpdateMs:s/l}}async function C(o,e){const t=await M(`live_${o}_${e}_${Date.now()}`);await t.insert("stocks").values(f(o)).exec();const n=100;let c=0;const m=t.select("*").from("stocks").limit(n).observe().subscribe(()=>{c++}),s=100,r=s*e,u=performance.now();for(let i=0;i<s;i++)for(let b=0;b<e;b++){const F=Math.floor(Math.random()*n)+1,v=g();await t.update("stocks").set(v,w(v)).where(p("id").eq(F)).exec()}const d=performance.now()-u;return m(),{name:"Live Query Update",totalRows:o,batchSize:e,totalUpdates:r,durationMs:d,updatesPerSec:r/(d/1e3),avgUpdateMs:d/r,notifications:c}}async function L(){console.log("=".repeat(60)),console.log("Cynos High Frequency Update Performance Test"),console.log("=".repeat(60));const o=[{rows:1e3,batch:1},{rows:1e3,batch:10},{rows:1e3,batch:50},{rows:1e3,batch:100},{rows:1e5,batch:1},{rows:1e5,batch:10},{rows:1e5,batch:50},{rows:1e5,batch:100}];console.log(` 2--- Test 1: Raw Update (No Live Query) ---`);for(const{rows:e,batch:t}of o){const n=await T(e,t);h.push(n),console.log(`[${e} rows, batch=${t}] ${n.updatesPerSec.toFixed(0)} updates/sec, avg ${n.avgUpdateMs.toFixed(3)}ms`)}console.log(` 3--- Test 2: Live Query exists but NOT subscribed ---`);for(const{rows:e,batch:t}of o){const n=await P(e,t);h.push(n),console.log(`[${e} rows, batch=${t}] ${n.updatesPerSec.toFixed(0)} updates/sec, avg ${n.avgUpdateMs.toFixed(3)}ms`)}console.log(` 4--- Test 3: Live Query with subscribe ---`);for(const{rows:e,batch:t}of o){const n=await C(e,t);h.push(n),console.log(`[${e} rows, batch=${t}] ${n.updatesPerSec.toFixed(0)} updates/sec, avg ${n.avgUpdateMs.toFixed(3)}ms, ${n.notifications} notifications`)}return console.log(` 5`+"=".repeat(60)),console.log("Summary"),console.log("=".repeat(60)),h}export{L as runPerfTest};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.