Refactor generateRandomFloat() helper
[benchmarks-js.git] / shallow-clone-object.js
CommitLineData
6dce9ba7
JB
1/* eslint-disable no-unused-vars */
2const Benchmark = require('benny')
5b907dbf 3const { generateRandomObject } = require('./benchmark-utils')
6dce9ba7
JB
4const _ = require('lodash')
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 })
36)