ed308e9cd944187ed06946b2774b2fdac8666a02
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
= generateRandomObject()
10 `Deep clone object with ${Object.keys(object).length} 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',