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