From ab7a52f89d312183cd4d1b351f772a73348fadd3 Mon Sep 17 00:00:00 2001 From: Antonio Stoilkov Date: Mon, 12 Feb 2024 12:06:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20improve=20playground?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playground/index.html | 3 +++ playground/playground.ts | 9 ++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/playground/index.html b/playground/index.html index 6537985..88091c7 100644 --- a/playground/index.html +++ b/playground/index.html @@ -35,6 +35,7 @@
+ main-thread-scheduling: @@ -44,12 +45,14 @@

+ scheduler.postTask():

+ others: diff --git a/playground/playground.ts b/playground/playground.ts index 927715f..fa6f747 100644 --- a/playground/playground.ts +++ b/playground/playground.ts @@ -49,17 +49,16 @@ document.querySelector('#queue-task')!.addEventListener('click', () => { }) async function run(strategy: SchedulingStrategy, time: number = 1000) { - const start = Date.now() - while (Date.now() - start < time) { + const start = performance.now() + while (performance.now() - start < time) { if (isTimeToYield(strategy)) { await yieldOrContinue(strategy) } simulateWork() } - performance.measure(strategy, { + performance.measure(`${strategy} (${Math.round(time / 1000)}s)`, { start: start, - end: Date.now(), - detail: 'awesome', + end: performance.now(), }) }