Add upload library management and ops diagnostics

This commit is contained in:
Jonathan Sykes
2026-10-14 03:09:12 +08:00
parent 5177a4d441
commit 27c694901d
15 changed files with 467 additions and 36 deletions

View File

@@ -521,3 +521,17 @@ contrast in Glass Stage at 320/390/768/1280px and dark/light/contrast themes. It
also captures Classic, Bento Hub, and Framework7 Swipe at 390/1280px to guard
their existing card presentation. Screenshots are written to
`plans/rec-card-shots/`.
## Admin operations screens
`npx playwright test -c playwright.admin-ops.config.js` checks the Performance,
P2P Devices, and Uploads admin tabs at 390/768/1280px in dark/light/contrast,
including AA body-text contrast, 44px controls, page overflow, and mobile
bottom-navigation clearance. Viewport screenshots are saved under
`plans/admin-ops-shots/` (ignored by Git).
For request-monitor overhead, run two local server instances against separate
data directories, one with `OPS_MONITOR=0` and one with monitoring enabled, then
run `OPS_BASE_URL=http://127.0.0.1:<off-port> OPS_ENABLED_URL=http://127.0.0.1:<on-port> node perf/admin-ops-bench.mjs`.
The harness interleaves 500 `/api/version` requests per mode and prints p50/p95,
mean latency, and the mean delta.

29
perf/admin-ops-bench.mjs Normal file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env node
// Compare local /api/version latency with request monitoring enabled and disabled.
// Start two otherwise identical server instances and set OPS_BASE_URL/OPS_ENABLED_URL.
const urls = { disabled: process.env.OPS_BASE_URL, enabled: process.env.OPS_ENABLED_URL };
if (!urls.disabled || !urls.enabled) {
console.error('Set OPS_BASE_URL and OPS_ENABLED_URL to local server URLs.');
process.exit(2);
}
const samples = { disabled: [], enabled: [] };
async function request(url) {
const start = performance.now();
const response = await fetch(`${url}/api/version`);
await response.arrayBuffer();
if (!response.ok) throw new Error(`${url} returned HTTP ${response.status}`);
return performance.now() - start;
}
for (const key of Object.keys(urls)) for (let i = 0; i < 30; i++) await request(urls[key]);
for (let i = 0; i < 500; i++) {
for (const key of i % 2 ? ['enabled', 'disabled'] : ['disabled', 'enabled']) samples[key].push(await request(urls[key]));
}
const percentile = (values, p) => [...values].sort((a, b) => a - b)[Math.ceil(values.length * p) - 1];
const result = Object.fromEntries(Object.entries(samples).map(([key, values]) => [key, {
requests: values.length,
p50Ms: Number(percentile(values, .5).toFixed(3)),
p95Ms: Number(percentile(values, .95).toFixed(3)),
meanMs: Number((values.reduce((a, b) => a + b, 0) / values.length).toFixed(3)),
}]));
console.log(JSON.stringify({ route: '/api/version', pairs: samples.disabled.length, result,
meanDeltaPercent: Number(((result.enabled.meanMs / result.disabled.meanMs - 1) * 100).toFixed(2)) }, null, 2));