--- /dev/null
+const Benchmark = require('benny')
+
+const emptyLiteral = {}
+
+Benchmark.suite(
+ 'Empty object',
+ Benchmark.add('Reflect keys', (obj = emptyLiteral) => {
+ return Reflect.ownKeys(obj).length === 0 && obj.constructor === Object
+ }),
+ Benchmark.add('Keys iteration ', (obj = emptyLiteral) => {
+ 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 = emptyLiteral) => {
+ return obj.constructor === Object && !Object.keys(obj).length
+ }),
+ Benchmark.cycle(),
+ Benchmark.complete(),
+ Benchmark.save({
+ file: 'empty-object',
+ format: 'json',
+ details: true
+ }),
+ Benchmark.save({
+ file: 'empty-object',
+ format: 'chart.html',
+ details: true
+ }),
+ Benchmark.save({
+ file: 'empty-object',
+ format: 'table.html',
+ details: true
+ })
+)
"prepare": "node prepare.js",
"benchmark:busy-wait": "node busy-wait.js",
"benchmark:empty-array": "node empty-array.js",
+ "benchmark:empty-object": "node empty-object.js",
"benchmark:quick-select": "node quick-select.js",
"benchmark:max": "node max.js",
"benchmark:promise-handling": "node promise-handling.js",