const Benchmark = require('benny')
const { generateRandomInteger } = require('./benchmark-utils')
-const size = generateRandomInteger(100000)
+const size = generateRandomInteger(500)
const testObject = {}
for (let i = 0; i < size; i++) {
testObject[i.toString()] = i
Benchmark.suite(
`Is empty object with ${size} keys`,
Benchmark.add('Reflect keys', (obj = testObject) => {
- return Reflect.ownKeys(obj).length === 0 && obj?.constructor === Object
+ return obj?.constructor === Object && Reflect.ownKeys(obj).length === 0
}),
Benchmark.add('Keys iteration', (obj = testObject) => {
if (obj?.constructor !== Object) return false
return true
}),
Benchmark.add('Object keys', (obj = testObject) => {
- return obj?.constructor === Object && !Object.keys(obj).length
+ return obj?.constructor === Object && Object.keys(obj).length === 0
}),
Benchmark.cycle(),
Benchmark.complete(),