Commit | Line | Data |
---|---|---|
f522d7b9 | 1 | import _ from 'lodash' |
ab9a08f3 | 2 | import { assoc } from 'rambda' |
4676a95c | 3 | import { bench, group, run } from 'tatami-ng' |
0c01f51c | 4 | |
95d31631 | 5 | import { generateRandomObject } from './benchmark-utils.mjs' |
6dce9ba7 | 6 | |
8e1fbc06 | 7 | const object = generateRandomObject() |
6dce9ba7 | 8 | |
ab9a08f3 JB |
9 | group(`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 | ||
24 | await run({ | |
ebf80fe4 | 25 | units: true, |
ab9a08f3 | 26 | }) |