From a9aa1456a06c073747e52d827129f5f2545200e8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 23 Dec 2022 18:09:02 +0100 Subject: [PATCH] Add just-clone to cloning benchmark MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- clone-object.js | 4 ++++ package-lock.json | 6 ++++++ package.json | 1 + 3 files changed, 11 insertions(+) diff --git a/clone-object.js b/clone-object.js index 671e8c0..73619f2 100644 --- a/clone-object.js +++ b/clone-object.js @@ -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({ diff --git a/package-lock.json b/package-lock.json index ead711f..cee2b93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" @@ -2045,6 +2046,11 @@ "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", diff --git a/package.json b/package.json index 19fe39c..ffccc57 100644 --- a/package.json +++ b/package.json @@ -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" -- 2.34.1