X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=shallow-clone-object.mjs;h=5e68bf8f74194af622252032db81a570b3d445a2;hb=ab9a08f3b8fdd43f8714e90652028621849f9f58;hp=466135e4469deebdbd92f97f524328445b156d01;hpb=1b4e2f913afc4f5dfed823720d89dde05d23d184;p=benchmarks-js.git diff --git a/shallow-clone-object.mjs b/shallow-clone-object.mjs index 466135e..5e68bf8 100644 --- a/shallow-clone-object.mjs +++ b/shallow-clone-object.mjs @@ -1,37 +1,27 @@ /* eslint-disable no-unused-vars */ -import Benchmark from 'benny' import _ from 'lodash' +import { bench, group, run } from 'mitata' +import { assoc } from 'rambda' import { generateRandomObject } from './benchmark-utils.mjs' const object = generateRandomObject() -Benchmark.suite( - `Shallow clone object with ${Object.keys(object).length} keys`, - Benchmark.add('Spread', (obj = object) => { - const objClone = { ...obj } - }), - Benchmark.add('Object assign', (obj = object) => { - const objClone = Object.assign({}, obj) - }), - Benchmark.add('lodash clone', (obj = object) => { - const objClone = _.clone(obj) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'shallow-clone-object', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'shallow-clone-object', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'shallow-clone-object', - format: 'table.html', - details: true +group(`Shallow clone object with ${Object.keys(object).length} keys`, () => { + bench('Spread', () => { + const objClone = { ...object } }) -).catch(console.error) + bench('Object assign', () => { + const objClone = Object.assign({}, object) + }) + bench('lodash clone', () => { + const objClone = _.clone(object) + }) + bench('rambda assoc', () => { + const objClone = assoc(object) + }) +}) + +await run({ + units: true +})