build(deps-dev): apply updates
[benchmarks-js.git] / shallow-clone-object.mjs
CommitLineData
f522d7b9 1import _ from 'lodash'
ab9a08f3 2import { assoc } from 'rambda'
4676a95c 3import { bench, group, run } from 'tatami-ng'
0c01f51c 4
95d31631 5import { generateRandomObject } from './benchmark-utils.mjs'
6dce9ba7 6
8e1fbc06 7const object = generateRandomObject()
6dce9ba7 8
ab9a08f3
JB
9group(`Shallow clone object with ${Object.keys(object).length} keys`, () => {
10 bench('Spread', () => {
bf2f087f 11 return { ...object }
6dce9ba7 12 })
ab9a08f3 13 bench('Object assign', () => {
bf2f087f 14 return Object.assign({}, object)
ab9a08f3
JB
15 })
16 bench('lodash clone', () => {
bf2f087f 17 _.clone(object)
ab9a08f3
JB
18 })
19 bench('rambda assoc', () => {
bf2f087f 20 assoc(object)
ab9a08f3
JB
21 })
22})
23
24await run({
ebf80fe4 25 units: true,
ab9a08f3 26})