Add just-clone to cloning benchmark
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 23 Dec 2022 17:09:02 +0000 (18:09 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 23 Dec 2022 17:09:02 +0000 (18:09 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
clone-object.js
package-lock.json
package.json

index 671e8c075e5c9bfd6793f5b9be5d231dd8c054d4..73619f246e7fa90e1689a7eae6aa366ed44e8f2b 100644 (file)
@@ -2,6 +2,7 @@
 const Benchmark = require('benny')
 const { generateRandomInteger } = require('./benchmark-utils')
 const _ = require('lodash')
+const clone = require('just-clone')
 
 const size = generateRandomInteger(500)
 const testObject = {}
@@ -29,6 +30,9 @@ Benchmark.suite(
   Benchmark.add('lodash deep clone', (obj = testObject) => {
     const objClone = _.cloneDeep(obj)
   }),
+  Benchmark.add('just-clone', (obj = testObject) => {
+    const objClone = clone(obj)
+  }),
   Benchmark.cycle(),
   Benchmark.complete(),
   Benchmark.save({
index ead711fb9f9fd4a46e2e931d46916513762fde20..cee2b93d747798a119243b205a9662ae9978c5a3 100644 (file)
@@ -10,6 +10,7 @@
       "license": "MIT",
       "dependencies": {
         "benny": "^3.7.1",
+        "just-clone": "^6.2.0",
         "lodash": "^4.17.21",
         "microtime": "^3.1.1",
         "uuid": "^9.0.0"
         "node": ">=4.0"
       }
     },
+    "node_modules/just-clone": {
+      "version": "6.2.0",
+      "resolved": "https://registry.npmjs.org/just-clone/-/just-clone-6.2.0.tgz",
+      "integrity": "sha512-1IynUYEc/HAwxhi3WDpIpxJbZpMCvvrrmZVqvj9EhpvbH8lls7HhdhiByjL7DkAaWlLIzpC0Xc/VPvy/UxLNjA=="
+    },
     "node_modules/kleur": {
       "version": "4.1.5",
       "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
index 19fe39cd5991aa6a544a10a6f4808eba45fc3552..ffccc57d5762bd042d2d3337d4e43f954bcc4823 100644 (file)
@@ -31,6 +31,7 @@
   "license": "MIT",
   "dependencies": {
     "benny": "^3.7.1",
+    "just-clone": "^6.2.0",
     "lodash": "^4.17.21",
     "microtime": "^3.1.1",
     "uuid": "^9.0.0"