From: Jérôme Benoit Date: Tue, 8 Jun 2021 18:28:35 +0000 (+0200) Subject: Keep the dummy busy wait timeout implementation as a reference. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a6c343813ea719afaeeda19eb2126550bf5b6085;p=benchmarks-js.git Keep the dummy busy wait timeout implementation as a reference. Signed-off-by: Jérôme Benoit --- diff --git a/busy-wait.js b/busy-wait.js index d49a5fd..7c8273e 100644 --- a/busy-wait.js +++ b/busy-wait.js @@ -6,6 +6,14 @@ const suite = new Benchmark.Suite() const timeout = 2000 const interval = 1000 +/** + * @param timeoutMs + */ +function dummyTimeoutBusyWait (timeoutMs) { + const timeoutTimestampMs = Date.now() + timeoutMs + do {} while (Date.now() < timeoutTimestampMs) +} + /** * @param timeoutMs */ @@ -48,6 +56,9 @@ function setIntervalTimeoutBusyWait (timeoutMs, intervalMs = interval) { } suite + .add('dummyTimeoutBusyWait', function () { + dummyTimeoutBusyWait(timeout) + }) .add('sleepTimeoutBusyWait', async function () { sleepTimeoutBusyWait(timeout) })