repositories
/
benchmarks-js.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bump husky from 8.0.2 to 8.0.3
[benchmarks-js.git]
/
deep-clone-object.js
diff --git
a/deep-clone-object.js
b/deep-clone-object.js
index de345fcafd594693740809f1335ea530518c72bf..ed308e9cd944187ed06946b2774b2fdac8666a02 100644
(file)
--- a/
deep-clone-object.js
+++ b/
deep-clone-object.js
@@
-1,27
+1,23
@@
/* eslint-disable no-unused-vars */
const Benchmark = require('benny')
/* eslint-disable no-unused-vars */
const Benchmark = require('benny')
-const { generateRandom
Integer
} = require('./benchmark-utils')
+const { generateRandom
Object
} = require('./benchmark-utils')
const _ = require('lodash')
const clone = require('just-clone')
const _ = require('lodash')
const clone = require('just-clone')
-const size = generateRandomInteger(500)
-const testObject = {}
-for (let i = 0; i < size; i++) {
- testObject[i.toString()] = i
-}
+const object = generateRandomObject()
Benchmark.suite(
Benchmark.suite(
- `Deep clone object with ${
size
} keys`,
- Benchmark.add('JSON stringify/parse', (obj =
testO
bject) => {
+ `Deep clone object with ${
Object.keys(object).length
} keys`,
+ Benchmark.add('JSON stringify/parse', (obj =
o
bject) => {
const objClone = JSON.parse(JSON.stringify(obj))
}),
const objClone = JSON.parse(JSON.stringify(obj))
}),
- Benchmark.add('structuredClone', (obj =
testO
bject) => {
+ Benchmark.add('structuredClone', (obj =
o
bject) => {
const objClone = structuredClone(obj)
}),
const objClone = structuredClone(obj)
}),
- Benchmark.add('lodash cloneDeep', (obj =
testO
bject) => {
+ Benchmark.add('lodash cloneDeep', (obj =
o
bject) => {
const objClone = _.cloneDeep(obj)
}),
const objClone = _.cloneDeep(obj)
}),
- Benchmark.add('just-clone', (obj =
testO
bject) => {
+ Benchmark.add('just-clone', (obj =
o
bject) => {
const objClone = clone(obj)
}),
Benchmark.cycle(),
const objClone = clone(obj)
}),
Benchmark.cycle(),