perf: switch to mitata
[benchmarks-js.git] / is-empty-object.mjs
index f110816aae6d83ad6c9de6beae624ba175ff2ba3..bc7faf9610011ba114819e7dfa0f000a0520f768 100644 (file)
@@ -1,40 +1,34 @@
-import Benchmark from 'benny'
+import _ from 'lodash'
+import { bench, group, run } from 'mitata'
+import { isEmpty } from 'rambda'
 
 import { generateRandomObject } from './benchmark-utils.mjs'
 
 const object = generateRandomObject()
 
-Benchmark.suite(
-  `Is empty object with ${Object.keys(object).length} keys`,
-  Benchmark.add('Reflect keys', (obj = object) => {
+group(`Is empty object with ${Object.keys(object).length} keys`, () => {
+  bench('Reflect keys', (obj = object) => {
     return obj?.constructor === Object && Reflect.ownKeys(obj).length === 0
-  }),
-  Benchmark.add('Keys iteration', (obj = object) => {
+  })
+  bench('Keys iteration', (obj = object) => {
     if (obj?.constructor !== Object) return false
     // Iterates over the keys of an object, if
     // any exist, return false.
     // eslint-disable-next-line no-unreachable-loop
     for (const _ in obj) return false
     return true
-  }),
-  Benchmark.add('Object keys', (obj = object) => {
+  })
+  bench('Object keys', (obj = object) => {
     return obj?.constructor === Object && Object.keys(obj).length === 0
-  }),
-  Benchmark.cycle(),
-  Benchmark.complete(),
-  Benchmark.save({
-    file: 'is-empty-object',
-    format: 'json',
-    details: true
-  }),
-  Benchmark.save({
-    file: 'is-empty-object',
-    format: 'chart.html',
-    details: true
-  }),
-  Benchmark.save({
-    file: 'is-empty-object',
-    format: 'table.html',
-    details: true
   })
-).catch(console.error)
+  bench('lodash isEmpty', (obj = object) => {
+    return _.isEmpty(obj)
+  })
+  bench('rambda is Empty', (obj = object) => {
+    return isEmpty(obj)
+  })
+})
+
+await run({
+  units: true
+})