1 /* eslint-disable no-unused-vars */
2 const Benchmark
= require('benny')
3 const { generateRandomInteger
} = require('./benchmark-utils')
4 const _
= require('lodash')
6 const size
= generateRandomInteger(500)
8 for (let i
= 0; i
< size
; i
++) {
9 testObject
[i
.toString()] = i
13 `Shallow clone object with ${size} keys`,
14 Benchmark
.add('Spread', (obj
= testObject
) => {
15 const objClone
= { ...obj
}
17 Benchmark
.add('Object assign', (obj
= testObject
) => {
18 const objClone
= Object
.assign({}, obj
)
20 Benchmark
.add('lodash clone', (obj
= testObject
) => {
21 const objClone
= _
.clone(obj
)
26 file
: 'shallow-clone-object',
31 file
: 'shallow-clone-object',
36 file
: 'shallow-clone-object',