build(deps-dev): apply updates
[benchmarks-js.git] / busy-wait.mjs
index dd8a74f5a5c2faa69c3310b718d4542b1d7d614c..ec8a70d816cf8272e5d0af0ca44e3ca3dd45dc9b 100644 (file)
@@ -1,4 +1,5 @@
-import Benchmark from 'benny'
+import { bench, group, run } from 'tatami-ng'
+
 import { sleep } from './benchmark-utils.mjs'
 
 const timeout = 2000
@@ -45,38 +46,34 @@ async function divideAndConquerTimeoutBusyWait (
  * @param intervalMs
  */
 async function setIntervalTimeoutBusyWait (timeoutMs, intervalMs = interval) {
-  return new Promise(resolve => {
+  await new Promise(resolve => {
     const tries = Math.round(timeoutMs / intervalMs)
     let count = 0
     const triesSetInterval = setInterval(() => {
       count++
       if (count === tries) {
         clearInterval(triesSetInterval)
-        return resolve()
+        resolve()
       }
     }, intervalMs)
   })
 }
 
-Benchmark.suite(
-  'Busy wait',
-  Benchmark.add('dummyTimeoutBusyWait', () => {
+group('Busy wait', () => {
+  bench('dummyTimeoutBusyWait', () => {
     dummyTimeoutBusyWait(timeout)
-  }),
-  Benchmark.add('sleepTimeoutBusyWait', async () => {
+  })
+  bench('sleepTimeoutBusyWait', async () => {
     await sleepTimeoutBusyWait(timeout)
-  }),
-  Benchmark.add('divideAndConquerTimeoutBusyWait', async () => {
+  })
+  bench('divideAndConquerTimeoutBusyWait', async () => {
     await divideAndConquerTimeoutBusyWait(timeout)
-  }),
-  Benchmark.add('setIntervalTimeoutBusyWait', async () => {
+  })
+  bench('setIntervalTimeoutBusyWait', async () => {
     await setIntervalTimeoutBusyWait(timeout)
-  }),
-  Benchmark.cycle(),
-  Benchmark.complete(),
-  Benchmark.save({ file: 'busy-wait', format: 'json', details: true }),
-  Benchmark.save({ file: 'busy-wait', format: 'chart.html', details: true }),
-  Benchmark.save({ file: 'busy-wait', format: 'table.html', details: true })
-).catch(err => {
-  console.error(err)
+  })
+})
+
+await run({
+  units: true
 })