Tests cleanups
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 25 Oct 2022 15:57:13 +0000 (17:57 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 25 Oct 2022 15:57:13 +0000 (17:57 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
empty-array.js
fibonacci.js
is-empty-object.js [moved from empty-object.js with 58% similarity]
max.js
package-lock.json
package.json

index a6a8acd84daa66c81fcdc5fa93c93d76e60841e2..a56a82461f8ef272cf0210df5e81abd069ae8cc6 100644 (file)
@@ -1,10 +1,11 @@
 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
   }),
index edde903ec0c84f45e7dd3edb4ba8106e76875c6e..286c69cf498c688dbd48d99763b80c18d53c2f7c 100644 (file)
@@ -48,7 +48,7 @@ function fibonacciRecursionMemoization (num, memo) {
 }
 
 Benchmark.suite(
-  'Fibonacci',
+  `Fibonacci number ${number}`,
   Benchmark.add('fibonacciLoop', () => {
     fibonacciLoop(number)
   }),
similarity index 58%
rename from empty-object.js
rename to is-empty-object.js
index 17be7fea5585f3f550accb0a4bf8318b356fae98..b27dc104d89ed3a1ec0abf892ff9483ab18431a7 100644 (file)
@@ -1,13 +1,18 @@
 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.
@@ -15,23 +20,23 @@ Benchmark.suite(
     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
   })
diff --git a/max.js b/max.js
index 74f6f43f0be9c03fb87d49bf62c1d662c3467e27..be3f7819314f12757d34e124b445d4941a85a114 100644 (file)
--- a/max.js
+++ b/max.js
@@ -1,7 +1,8 @@
 const Benchmark = require('benny')
 const { generateRandomNumberArray } = require('./benchmark-utils')
 
-const testArray = generateRandomNumberArray(10000)
+const size = 10000
+const testArray = generateRandomNumberArray(size)
 
 /**
  *
@@ -44,7 +45,7 @@ function sortMax (values) {
 }
 
 Benchmark.suite(
-  'max',
+  `Max from ${size} numbers`,
   Benchmark.add('Math.max', () => {
     Math.max(...testArray)
   }),
index ed04714a311de1bc059c879100c60728708781e8..0d482d09cbf59088f52ab428b4e5654717281e0f 100644 (file)
@@ -16,9 +16,9 @@
       "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",
index 74f6bcda3382fc779189efb514af7a8275dc8c75..53fbf27433e5e7b7bf77e6a44c1ebf3034f9d98e 100644 (file)
@@ -10,7 +10,7 @@
     "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",
@@ -32,9 +32,9 @@
   "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",