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