const Benchmark = require('benny')
const { generateRandomNumberArray } = require('./benchmark-utils')
-let testArray = generateRandomNumberArray(10000)
+const size = 10000
+let testArray = generateRandomNumberArray(size)
Benchmark.suite(
- 'Empty array',
+ `Empty array with ${size} elements`,
Benchmark.add('length = 0', () => {
testArray.length = 0
}),
}
Benchmark.suite(
- 'Fibonacci',
+ `Fibonacci number ${number}`,
Benchmark.add('fibonacciLoop', () => {
fibonacciLoop(number)
}),
const Benchmark = require('benny')
+const { generateRandomInteger } = require('./benchmark-utils')
-const emptyLiteral = {}
+const size = generateRandomInteger(100000)
+const testObject = {}
+for (let i = 0; i < size; i++) {
+ testObject[i.toString()] = i
+}
Benchmark.suite(
- 'Empty object',
- Benchmark.add('Reflect keys', (obj = emptyLiteral) => {
+ `Is empty object with ${size} keys`,
+ Benchmark.add('Reflect keys', (obj = testObject) => {
return Reflect.ownKeys(obj).length === 0 && obj.constructor === Object
}),
- Benchmark.add('Keys iteration ', (obj = emptyLiteral) => {
+ Benchmark.add('Keys iteration ', (obj = testObject) => {
if (obj.constructor !== Object) return false
// Iterates over the keys of an object, if
// any exist, return false.
for (const _ in obj) return false
return true
}),
- Benchmark.add('Object keys', (obj = emptyLiteral) => {
+ Benchmark.add('Object keys', (obj = testObject) => {
return obj.constructor === Object && !Object.keys(obj).length
}),
Benchmark.cycle(),
Benchmark.complete(),
Benchmark.save({
- file: 'empty-object',
+ file: 'is-empty-object',
format: 'json',
details: true
}),
Benchmark.save({
- file: 'empty-object',
+ file: 'is-empty-object',
format: 'chart.html',
details: true
}),
Benchmark.save({
- file: 'empty-object',
+ file: 'is-empty-object',
format: 'table.html',
details: true
})
const Benchmark = require('benny')
const { generateRandomNumberArray } = require('./benchmark-utils')
-const testArray = generateRandomNumberArray(10000)
+const size = 10000
+const testArray = generateRandomNumberArray(size)
/**
*
}
Benchmark.suite(
- 'max',
+ `Max from ${size} numbers`,
Benchmark.add('Math.max', () => {
Math.max(...testArray)
}),
"devDependencies": {
"eslint": "^8.26.0",
"eslint-config-standard": "^17.0.0",
- "eslint-define-config": "^1.7.0",
+ "eslint-define-config": "^1.8.0",
"eslint-plugin-import": "^2.26.0",
- "eslint-plugin-jsdoc": "^39.3.20",
+ "eslint-plugin-jsdoc": "^39.3.24",
"eslint-plugin-n": "^15.3.0",
"eslint-plugin-promise": "^6.1.1",
"husky": "^8.0.1",
}
},
"node_modules/eslint-define-config": {
- "version": "1.7.0",
- "resolved": "https://registry.npmjs.org/eslint-define-config/-/eslint-define-config-1.7.0.tgz",
- "integrity": "sha512-13zk8z8eKO4tpPMvAGV0sa6ok0XuMeu7Zhcizu2bLwcLy1fbNt7/h8PU1wbp9IoIgQETggZJozU0nPXUXOao2g==",
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/eslint-define-config/-/eslint-define-config-1.8.0.tgz",
+ "integrity": "sha512-YibjbNkHKMo3QAnV3bgc+BdvmYCcCpuoRdAIc+6W/P91G02ZOrCVaPrco9Uf4md25NanjkV2bnfwce8XfPRS7A==",
"dev": true,
"funding": [
{
"dev": true
},
"node_modules/eslint-plugin-jsdoc": {
- "version": "39.3.20",
- "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.3.20.tgz",
- "integrity": "sha512-A9pAm4lQeDKyzu6wuMUZS+FQceu6S2G18o9Mld0a48NAeLaLPg9TpoXM2Xv85LZ3AnKUtx+jR9SxXJLgCQiifQ==",
+ "version": "39.3.24",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.3.24.tgz",
+ "integrity": "sha512-ePTnAvTKc/Ux97PgffhsgJcQVJimaNxb5yA4nwhHg+gZ21rjFQmOyowDDYe2u/L9ClwRGmwLq7/K422bTh+2Zg==",
"dev": true,
"dependencies": {
"@es-joy/jsdoccomment": "~0.33.0",
"dev": true
},
"eslint-define-config": {
- "version": "1.7.0",
- "resolved": "https://registry.npmjs.org/eslint-define-config/-/eslint-define-config-1.7.0.tgz",
- "integrity": "sha512-13zk8z8eKO4tpPMvAGV0sa6ok0XuMeu7Zhcizu2bLwcLy1fbNt7/h8PU1wbp9IoIgQETggZJozU0nPXUXOao2g==",
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/eslint-define-config/-/eslint-define-config-1.8.0.tgz",
+ "integrity": "sha512-YibjbNkHKMo3QAnV3bgc+BdvmYCcCpuoRdAIc+6W/P91G02ZOrCVaPrco9Uf4md25NanjkV2bnfwce8XfPRS7A==",
"dev": true
},
"eslint-import-resolver-node": {
}
},
"eslint-plugin-jsdoc": {
- "version": "39.3.20",
- "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.3.20.tgz",
- "integrity": "sha512-A9pAm4lQeDKyzu6wuMUZS+FQceu6S2G18o9Mld0a48NAeLaLPg9TpoXM2Xv85LZ3AnKUtx+jR9SxXJLgCQiifQ==",
+ "version": "39.3.24",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.3.24.tgz",
+ "integrity": "sha512-ePTnAvTKc/Ux97PgffhsgJcQVJimaNxb5yA4nwhHg+gZ21rjFQmOyowDDYe2u/L9ClwRGmwLq7/K422bTh+2Zg==",
"dev": true,
"requires": {
"@es-joy/jsdoccomment": "~0.33.0",
"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:is-empty-object": "node is-empty-object.js",
"benchmark:quick-select": "node quick-select.js",
"benchmark:max": "node max.js",
"benchmark:promise-handling": "node promise-handling.js",
"devDependencies": {
"eslint": "^8.26.0",
"eslint-config-standard": "^17.0.0",
- "eslint-define-config": "^1.7.0",
+ "eslint-define-config": "^1.8.0",
"eslint-plugin-import": "^2.26.0",
- "eslint-plugin-jsdoc": "^39.3.20",
+ "eslint-plugin-jsdoc": "^39.3.24",
"eslint-plugin-n": "^15.3.0",
"eslint-plugin-promise": "^6.1.1",
"husky": "^8.0.1",