tracker
All repositories: gitoria
5.0 KB
// tests/realdata-027-bench.mjs — mission 027 (re-vendor 06617221: old 190aa11d vs new); copy of realdata-074-bench.mjs, mission 025 (tracker#30: /my/* after the first-start jobs; a copy of realdata-071-bench.mjs with// the /my/ pages), NOT the gate: the big pages on a COPY of live// storage/, signed in as the creator (cookie from $REAL_SID_FILE), $REAL_LOADS (20) loads per page. Each load: the server's own// answer (node fetch, whole body) and the full browser load (to hydrated + visible images; Picard also clicks the cast "Show all"// and waits for "Show less"); the server's RSS after each load (/proc/$REAL_PID). Env: REAL_PORT, REAL_CHROME, REAL_SID_FILE,// REAL_PID, REAL_OUT (a .json with every number), REAL_LOADS, REAL_PATHS (only these, comma list of path prefixes). Procedure: STATUS.md mission 071.import { writeFileSync, readFileSync } from 'node:fs';import { launchBrowser } from './cdp.mjs';process.env.HL_CHROME ||= '/opt/google/chrome/chrome';const PORT = Number(process.env.REAL_PORT || 8758), BASE = `http://127.0.0.1:${PORT}`, LOADS = Number(process.env.REAL_LOADS || 20);const SID = readFileSync(process.env.REAL_SID_FILE, 'utf8').trim(), PID = process.env.REAL_PID;const rss = () => Math.round(Number(readFileSync(`/proc/${PID}/status`, 'utf8').match(/VmRSS:\s+(\d+)/)[1]) / 1024);const browser = await launchBrowser({ debugPortRange: [Number(process.env.REAL_CHROME || 8759), Number(process.env.REAL_CHROME || 8759)] });const page = await browser.newPage();await page.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });await page.send('Network.setCookie', { name: 'trackersid', value: SID, url: BASE });const hydrated = () => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1 && document.readyState === "complete"', { timeout: 120000, label: 'hydrated' });const load = async (path, showAll) => {const t = Date.now(); await page.goto(BASE + path, { timeout: 120000 }); await hydrated();await page.waitFor(`Array.from(document.querySelectorAll('img')).filter(i => { const r = i.getBoundingClientRect(); return r.top < innerHeight && r.bottom > 0 }).every(i => i.complete)`, { timeout: 15000, label: 'images' }).catch(() => {});if (showAll) { await page.click('#casttoggle'); await page.waitFor(`document.querySelector('#casttoggle').innerText.includes('Show less')`, { timeout: 30000, label: 'show less' }); }return Date.now() - t;};const serverTime = async (path) => {const t = Date.now(); const r = await fetch(BASE + path, { headers: { cookie: 'trackersid=' + SID } }); const body = await r.text();return { ms: Date.now() - t, status: r.status, kb: Math.round(body.length / 1024) };};try {// a franchise page and a timeline from /franchises itself (the first ones listed; the seed makes timelines without a franchise)await load('/franchises');const hrefOf = (sel) => page.evaluate(`(document.querySelector('${sel}') || { getAttribute: () => null }).getAttribute('href')`);const franchise = await hrefOf('a.franchise-row'), timeline = await hrefOf('a.timeline-link');let PAGES = [['/my/series'], ['/my/unwatched'], ['/series/Star-Trek-Picard', true], ['/series'], ['/franchises']];// REAL_PATHS (comma list): only these of the pages aboveif (process.env.REAL_PATHS) PAGES = PAGES.filter(([p]) => process.env.REAL_PATHS.split(',').some(x => p.startsWith(x)));const out = { pid: PID, rssStart: rss(), pages: [] };for (const [path, showAll] of PAGES) {const p = { path: path + (showAll ? ' + Show all' : ''), server: [], browser: [], rss: [], rows: null };const before = rss();for (let i = 0; i < LOADS; i++) {const s = await serverTime(path); if (s.status !== 200) throw new Error(path + ' answered ' + s.status);p.server.push(s.ms); p.kb = s.kb;p.browser.push(await load(path, showAll));p.rss.push(rss());}p.rows = await page.evaluate(`document.querySelectorAll('my-show-row, a.tile, a.timeline-item, a.franchise-row, a.timeline-link, episode-row, show-cast a.artist-link, a.unwatched-show, a.schedule-show').length`);const st = (a) => ({ avg: Math.round(a.reduce((x, y) => x + y, 0) / a.length), min: Math.min(...a), max: Math.max(...a), first5: Math.round(a.slice(0, 5).reduce((x, y) => x + y, 0) / 5), last5: Math.round(a.slice(-5).reduce((x, y) => x + y, 0) / 5) });p.sum = { server: st(p.server), browser: st(p.browser), rssBefore: before, rssAfter: p.rss[p.rss.length - 1] };out.pages.push(p);console.log(`${p.path.padEnd(42)} server avg ${p.sum.server.avg} ms (first5 ${p.sum.server.first5}, last5 ${p.sum.server.last5}, max ${p.sum.server.max}) browser avg ${p.sum.browser.avg} ms (first5 ${p.sum.browser.first5}, last5 ${p.sum.browser.last5}, max ${p.sum.browser.max}) RSS ${before} → ${p.sum.rssAfter} MB ${p.kb} kB, ${p.rows} rows`);}out.rssEnd = rss();console.log(`RSS over the whole run: ${out.rssStart} → ${out.rssEnd} MB`);if (process.env.REAL_OUT) writeFileSync(process.env.REAL_OUT, JSON.stringify(out, null, 1));} catch (e) { console.error(e); await browser.close().catch(() => {}); process.exit(1); }await browser.close();process.exit(0);
Branches
Latest commits
- c21aff6bMerge branch 'records-hm55c' into mainTracker
- 9ba258d3|||PR records: HM55b resultTracker
- 64f2d300Merge branch 'records-hm55b2' into mainTracker
- ae3b80dc|||PR records: HM55b briefTracker
- 7ef3cb3bMerge branch 'records-st55' into mainTracker
- fec2e080|||PR records: STATUS HM55Tracker
- 8e174918Merge branch 'records-hm55b' into mainTracker
- b1ecee57|||PR records: HM55 stateTracker
- 28eab08cMerge branch 'records-hm55' into mainTracker
- d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
- 3059f86cMerge branch 'records-design-rule' into mainTracker
- 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
- d1390692Merge branch 'records-dp75b' into mainTracker
- a4d1a7d2|||PR records: later steps checked, branch auditTracker
- e070e16fMerge branch 'records-dp75' into mainTracker
- 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
- bfc4ea4dMerge branch 'ap62' into mainTracker
- 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker
- b9c7c3c8Merge branch 'records-dp74' into mainTracker
- 85cfb4ae|||PR records: AP61 day61, DP74 liveTracker