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