X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=deep-clone-object.mjs;h=6796eaddea9daa702163f1f2fa5681f794d8e79d;hb=ab9a08f3b8fdd43f8714e90652028621849f9f58;hp=989a04f907e3bf78b51a92d754d2909c2ff19af8;hpb=1b4e2f913afc4f5dfed823720d89dde05d23d184;p=benchmarks-js.git diff --git a/deep-clone-object.mjs b/deep-clone-object.mjs index 989a04f..6796ead 100644 --- a/deep-clone-object.mjs +++ b/deep-clone-object.mjs @@ -1,45 +1,35 @@ /* eslint-disable no-unused-vars */ -import Benchmark from 'benny' import deepClone from 'deep-clone' import clone from 'just-clone' import _ from 'lodash' +import { bench, group, run } from 'mitata' +import { clone as rambdaClone } from 'rambda' import { generateRandomObject } from './benchmark-utils.mjs' const object = generateRandomObject() -Benchmark.suite( - `Deep clone object with ${Object.keys(object).length} keys`, - Benchmark.add('JSON stringify/parse', (obj = object) => { +group(`Deep clone object with ${Object.keys(object).length} keys`, () => { + bench('JSON stringify/parse', (obj = object) => { const objCloned = JSON.parse(JSON.stringify(obj)) - }), - Benchmark.add('structuredClone', (obj = object) => { + }) + bench('structuredClone', (obj = object) => { const objCloned = structuredClone(obj) - }), - Benchmark.add('lodash cloneDeep', (obj = object) => { + }) + bench('lodash cloneDeep', (obj = object) => { const objCloned = _.cloneDeep(obj) - }), - Benchmark.add('just-clone', (obj = object) => { + }) + bench('rambda clone', (obj = object) => { + const objCloned = rambdaClone(obj) + }) + bench('just-clone', (obj = object) => { const objCloned = clone(obj) - }), - Benchmark.add('deep-clone', (obj = object) => { + }) + bench('deep-clone', (obj = object) => { const objCloned = deepClone(obj) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'deep-clone-object', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'deep-clone-object', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'deep-clone-object', - format: 'table.html', - details: true }) -).catch(console.error) +}) + +await run({ + units: true +})