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