build(deps-dev): apply updates
[benchmarks-js.git] / deep-clone-object.mjs
1 import deepClone from 'deep-clone'
2 import clone from 'just-clone'
3 import _ from 'lodash'
4 import { clone as rambdaClone } from 'rambda'
5 import { bench, group, run } from 'tatami-ng'
6
7 import { generateRandomObject } from './benchmark-utils.mjs'
8
9 const object = generateRandomObject()
10
11 group(`Deep clone object with ${Object.keys(object).length} keys`, () => {
12 bench('JSON stringify/parse', (obj = object) => {
13 JSON.parse(JSON.stringify(obj))
14 })
15 bench('structuredClone', (obj = object) => {
16 structuredClone(obj)
17 })
18 bench('lodash cloneDeep', (obj = object) => {
19 _.cloneDeep(obj)
20 })
21 bench('rambda clone', (obj = object) => {
22 rambdaClone(obj)
23 })
24 bench('just-clone', (obj = object) => {
25 clone(obj)
26 })
27 bench('deep-clone', (obj = object) => {
28 deepClone(obj)
29 })
30 })
31
32 await run({
33 units: true,
34 })