diff --git a/tools/live/m4.ts b/tools/live/m4.ts index dadc647..2d18ab5 100644 --- a/tools/live/m4.ts +++ b/tools/live/m4.ts @@ -2,8 +2,10 @@ // is, and how many updates dragging a device makes. Mia drags a device in a // real browser for two seconds at 60 pointer moves a second (as a finger or // a mouse does); a second person, watching through /sync, counts the updates -// that arrive and their bytes. Then the document's size as F holds it: fresh, -// after the drags, and as one update (what a new person loads). +// that arrive and their bytes, and the presence changes Mia's editor sends +// meanwhile (since F5.6d the drag goes there, the document gets its end). +// Then the document's size as F holds it: fresh, after the drags, and as one +// update (what a new person loads). // // npx vite-node tools/live/m4.ts @@ -28,8 +30,12 @@ try { watcher.doc.on('update', (update: Uint8Array, origin: unknown) => { if (origin !== null && typeof origin === 'object') arrivals.push({ at: performance.now(), bytes: update.length }); }); + let presence = 0; + const awareness = watcher.provider.awareness; + awareness.on('change', ({ updated }: { updated: number[] }) => (presence += updated.filter((client) => client !== awareness.clientID).length)); for (const name of ['Heimrouter', 'webserver.de (120.130.140.80)', 'iPad 1']) { arrivals.length = 0; + presence = 0; const from = await onDevice(page, example.graph.nodes.find((node) => node.displayName === name)!.id); await page.mouse.move(from.x, from.y); await page.mouse.down(); @@ -45,7 +51,7 @@ try { await new Promise((resolve) => setTimeout(resolve, 1500)); const bytes = arrivals.reduce((sum, each) => sum + each.bytes, 0); console.log( - `drag ${name.padEnd(30)} ${dragged.toFixed(1)} s: ${arrivals.length} updates (${(arrivals.length / dragged).toFixed(0)}/s), ${bytes} bytes, ${(bytes / Math.max(1, arrivals.length)).toFixed(0)} per update`, + `drag ${name.padEnd(30)} ${dragged.toFixed(1)} s: ${arrivals.length} updates (${(arrivals.length / dragged).toFixed(0)}/s), ${bytes} bytes, ${(bytes / Math.max(1, arrivals.length)).toFixed(0)} per update; ${presence} presence changes (${(presence / dragged).toFixed(0)}/s)`, ); } console.log(`after the drags: ${Y.encodeStateAsUpdate(watcher.doc).length} bytes as one update`);