X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=shallow-clone-object.mjs;h=e01a3c4f61f454b17a575dce06a1620ff6a7ab47;hb=176dac3229467b4ed7f927ee8f2433efb5acc531;hp=466135e4469deebdbd92f97f524328445b156d01;hpb=0c01f51c5673eefd485edfab3f8cea93a56f400e;p=benchmarks-js.git diff --git a/shallow-clone-object.mjs b/shallow-clone-object.mjs index 466135e..e01a3c4 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 { assoc } from 'rambda' +import { bench, group, run } from 'tatami-ng' 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 +})