1 /* eslint-disable no-unused-vars */
2 const Benchmark
= require('benny')
3 const _
= require('lodash')
4 const { generateRandomObject
} = require('./benchmark-utils')
6 const object
= generateRandomObject()
9 `Shallow clone object with ${Object.keys(object).length} keys`,
10 Benchmark
.add('Spread', (obj
= object
) => {
11 const objClone
= { ...obj
}
13 Benchmark
.add('Object assign', (obj
= object
) => {
14 const objClone
= Object
.assign({}, obj
)
16 Benchmark
.add('lodash clone', (obj
= object
) => {
17 const objClone
= _
.clone(obj
)
22 file
: 'shallow-clone-object',
27 file
: 'shallow-clone-object',
32 file
: 'shallow-clone-object',