feat: add initial continous benchmarking
[poolifier.git] / benchmarks / worker-selection / least.mjs
similarity index 85%
rename from benchmarks/worker-selection/less.mjs
rename to benchmarks/worker-selection/least.mjs
index e839107d0978cacb32f6d55521bcc4455e5615f0..b8766322d0240156ff2d339b378fb5f5e564db75 100644 (file)
@@ -1,5 +1,5 @@
-import Benchmark from 'benny'
-import { generateRandomInteger } from '../benchmarks-utils.mjs'
+import Benchmark from 'benchmark'
+import { LIST_FORMATTER, generateRandomInteger } from '../benchmarks-utils.mjs'
 
 function generateRandomTasksMap (
   numberOfWorkers,
@@ -167,26 +167,31 @@ function quickSelectRecursionRandomPivot (tasksMap) {
   )
 }
 
-Benchmark.suite(
-  'Least used worker tasks distribution',
-  Benchmark.add('Loop select', () => {
+new Benchmark.Suite('Least used worker tasks distribution')
+  .add('Loop select', () => {
     loopSelect(tasksMap)
-  }),
-  Benchmark.add('Array sort select', () => {
+  })
+  .add('Array sort select', () => {
     arraySortSelect(tasksMap)
-  }),
-  Benchmark.add('Quick select loop', () => {
+  })
+  .add('Quick select loop', () => {
     quickSelectLoop(tasksMap)
-  }),
-  Benchmark.add('Quick select loop with random pivot', () => {
+  })
+  .add('Quick select loop with random pivot', () => {
     quickSelectLoopRandomPivot(tasksMap)
-  }),
-  Benchmark.add('Quick select recursion', () => {
+  })
+  .add('Quick select recursion', () => {
     quickSelectRecursion(tasksMap)
-  }),
-  Benchmark.add('Quick select recursion with random pivot', () => {
+  })
+  .add('Quick select recursion with random pivot', () => {
     quickSelectRecursionRandomPivot(tasksMap)
-  }),
-  Benchmark.cycle(),
-  Benchmark.complete()
-)
+  })
+  .on('cycle', event => {
+    console.info(event.target.toString())
+  })
+  .on('complete', function () {
+    console.info(
+      'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name'))
+    )
+  })
+  .run()