build(deps-dev): apply updates
[benchmarks-js.git] / quick-select.mjs
index d4270268fc58e25763684dff27533d643fbfdcdb..5fc3ef379d9ee7af6e82c5226f25cfb3d36d4f51 100644 (file)
@@ -1,5 +1,6 @@
 import { randomInt } from 'node:crypto'
-import Benchmark from 'benny'
+
+import { bench, group, run } from 'tatami-ng'
 
 /**
  * @param numberOfWorkers
@@ -26,7 +27,7 @@ const tasksMap = generateRandomTasksMap(60, 20)
  */
 function loopSelect (tasksMap) {
   let minKey
-  let minValue = Infinity
+  let minValue = Number.POSITIVE_INFINITY
   for (const [key, value] of tasksMap) {
     if (value === 0) {
       return key
@@ -227,41 +228,27 @@ function quickSelectRecursionRandomPivot (tasksMap) {
   )
 }
 
-Benchmark.suite(
-  'Quick select',
-  Benchmark.add('Loop select', () => {
+group('Quick select', () => {
+  bench('Loop select', () => {
     loopSelect(tasksMap)
-  }),
-  Benchmark.add('Array sort select', () => {
+  })
+  bench('Array sort select', () => {
     arraySortSelect(tasksMap)
-  }),
-  Benchmark.add('Quick select loop', () => {
+  })
+  bench('Quick select loop', () => {
     quickSelectLoop(tasksMap)
-  }),
-  Benchmark.add('Quick select loop with random pivot', () => {
+  })
+  bench('Quick select loop with random pivot', () => {
     quickSelectLoopRandomPivot(tasksMap)
-  }),
-  Benchmark.add('Quick select recursion', () => {
+  })
+  bench('Quick select recursion', () => {
     quickSelectRecursion(tasksMap)
-  }),
-  Benchmark.add('Quick select recursion with random pivot', () => {
+  })
+  bench('Quick select recursion with random pivot', () => {
     quickSelectRecursionRandomPivot(tasksMap)
-  }),
-  Benchmark.cycle(),
-  Benchmark.complete(),
-  Benchmark.save({
-    file: 'quick-select',
-    format: 'json',
-    details: true
-  }),
-  Benchmark.save({
-    file: 'quick-select',
-    format: 'chart.html',
-    details: true
-  }),
-  Benchmark.save({
-    file: 'quick-select',
-    format: 'table.html',
-    details: true
   })
-).catch(console.error)
+})
+
+await run({
+  units: true,
+})