let totalLatency = 0; let samples = 0; let startTime; async function work() { button.hidden = true; startTime = performance.now(); totalLatency = 0; samples = 0; await runTest(); } async function runTest() { // Test běží 5 sekund if (performance.now() - startTime >= 5000) { button.hidden = false; return; } await measurePing(); const avgPing = (totalLatency / samples).toFixed(2); if (samples > 0) { mbit.innerHTML = avgPing; divmbit.hidden = false; } requestAnimationFrame(runTest); } async function measurePing() { const t = performance.now(); try { // Načítáme soubor /1 pomocí GET pro minimální režii const response = await fetch('/1', { cache: 'no-store' }); await response.blob(); totalLatency += (performance.now() - t); samples++; } catch (e) { console.error('Chyba:', e); } }