build(deps-dev): apply updates
[benchmarks-js.git] / shallow-clone-object.mjs
CommitLineData
6dce9ba7 1/* eslint-disable no-unused-vars */
f522d7b9
JB
2import Benchmark from 'benny'
3import _ from 'lodash'
0c01f51c 4
95d31631 5import { generateRandomObject } from './benchmark-utils.mjs'
6dce9ba7 6
8e1fbc06 7const object = generateRandomObject()
6dce9ba7
JB
8
9Benchmark.suite(
8e1fbc06 10 `Shallow clone object with ${Object.keys(object).length} keys`,
5b907dbf 11 Benchmark.add('Spread', (obj = object) => {
6dce9ba7
JB
12 const objClone = { ...obj }
13 }),
5b907dbf 14 Benchmark.add('Object assign', (obj = object) => {
6dce9ba7
JB
15 const objClone = Object.assign({}, obj)
16 }),
5b907dbf 17 Benchmark.add('lodash clone', (obj = object) => {
6dce9ba7
JB
18 const objClone = _.clone(obj)
19 }),
6dce9ba7
JB
20 Benchmark.cycle(),
21 Benchmark.complete(),
22 Benchmark.save({
57f62217 23 file: 'shallow-clone-object',
6dce9ba7
JB
24 format: 'json',
25 details: true
26 }),
27 Benchmark.save({
57f62217 28 file: 'shallow-clone-object',
6dce9ba7
JB
29 format: 'chart.html',
30 details: true
31 }),
32 Benchmark.save({
57f62217 33 file: 'shallow-clone-object',
6dce9ba7
JB
34 format: 'table.html',
35 details: true
36 })
4aa2893a 37).catch(console.error)