1 /* eslint-disable no-unused-vars */
2 const Benchmark
= require('benny')
3 const { generateRandomInteger
} = require('./benchmark-utils')
4 const _
= require('lodash')
5 const clone
= require('just-clone')
7 const size
= generateRandomInteger(500)
9 for (let i
= 0; i
< size
; i
++) {
10 testObject
[i
.toString()] = i
14 `Deep clone object with ${size} keys`,
15 Benchmark
.add('JSON stringify/parse', (obj
= testObject
) => {
16 const objClone
= JSON
.parse(JSON
.stringify(obj
))
18 Benchmark
.add('structuredClone', (obj
= testObject
) => {
19 const objClone
= structuredClone(obj
)
21 Benchmark
.add('lodash cloneDeep', (obj
= testObject
) => {
22 const objClone
= _
.cloneDeep(obj
)
24 Benchmark
.add('just-clone', (obj
= testObject
) => {
25 const objClone
= clone(obj
)
30 file
: 'deep-clone-object',
35 file
: 'deep-clone-object',
40 file
: 'deep-clone-object',