1 /* eslint-disable no-unused-vars */
2 import Benchmark from 'benny'
4 import clone from 'just-clone'
5 import deepClone from 'deep-clone'
6 import { generateRandomObject } from './benchmark-utils.mjs'
8 const object = generateRandomObject()
11 `Deep clone object with ${Object.keys(object).length} keys`,
12 Benchmark.add('JSON stringify/parse', (obj = object) => {
13 const objCloned = JSON.parse(JSON.stringify(obj))
15 Benchmark.add('structuredClone', (obj = object) => {
16 const objCloned = structuredClone(obj)
18 Benchmark.add('lodash cloneDeep', (obj = object) => {
19 const objCloned = _.cloneDeep(obj)
21 Benchmark.add('just-clone', (obj = object) => {
22 const objCloned = clone(obj)
24 Benchmark.add('deep-clone', (obj = object) => {
25 const objCloned = deepClone(obj)
30 file: 'deep-clone-object',
35 file: 'deep-clone-object',
40 file: 'deep-clone-object',