refactor: cleanups
[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 { bench, group, run } from 'mitata'
6 import { clone as rambdaClone } from 'rambda'
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 const objCloned = JSON.parse(JSON.stringify(obj))
15 })
16 bench('structuredClone', (obj = object) => {
17 const objCloned = structuredClone(obj)
18 })
19 bench('lodash cloneDeep', (obj = object) => {
20 const objCloned = _.cloneDeep(obj)
21 })
22 bench('rambda clone', (obj = object) => {
23 const objCloned = rambdaClone(obj)
24 })
25 bench('just-clone', (obj = object) => {
26 const objCloned = clone(obj)
27 })
28 bench('deep-clone', (obj = object) => {
29 const objCloned = deepClone(obj)
30 })
31 })
32
33 await run({
34 units: true
35 })