-Benchmark.suite(
- `Shallow clone object with ${Object.keys(object).length} keys`,
- Benchmark.add('Spread', (obj = object) => {
- const objClone = { ...obj }
- }),
- Benchmark.add('Object assign', (obj = object) => {
- const objClone = Object.assign({}, obj)
- }),
- Benchmark.add('lodash clone', (obj = object) => {
- const objClone = _.clone(obj)
- }),
- Benchmark.cycle(),
- Benchmark.complete(),
- Benchmark.save({
- file: 'shallow-clone-object',
- format: 'json',
- details: true
- }),
- Benchmark.save({
- file: 'shallow-clone-object',
- format: 'chart.html',
- details: true
- }),
- Benchmark.save({
- file: 'shallow-clone-object',
- format: 'table.html',
- details: true
+group(`Shallow clone object with ${Object.keys(object).length} keys`, () => {
+ bench('Spread', () => {
+ const objClone = { ...object }
+ })
+ bench('Object assign', () => {
+ const objClone = Object.assign({}, object)
+ })
+ bench('lodash clone', () => {
+ const objClone = _.clone(object)