e1d8b1c61fac3860a09cc13d145fd58a250b7c24
1 /* eslint-disable no-unused-vars */
2 const Benchmark
= require('benny')
3 const { generateRandomObject
} = require('./benchmark-utils')
4 const _
= require('lodash')
5 const clone
= require('just-clone')
7 const { object
, size
} = generateRandomObject()
10 `Deep clone object with ${size} keys`,
11 Benchmark
.add('JSON stringify/parse', (obj
= object
) => {
12 const objClone
= JSON
.parse(JSON
.stringify(obj
))
14 Benchmark
.add('structuredClone', (obj
= object
) => {
15 const objClone
= structuredClone(obj
)
17 Benchmark
.add('lodash cloneDeep', (obj
= object
) => {
18 const objClone
= _
.cloneDeep(obj
)
20 Benchmark
.add('just-clone', (obj
= object
) => {
21 const objClone
= clone(obj
)
26 file
: 'deep-clone-object',
31 file
: 'deep-clone-object',
36 file
: 'deep-clone-object',