X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=shallow-clone-object.mjs;h=e01a3c4f61f454b17a575dce06a1620ff6a7ab47;hb=e3201eb925019c6cb7bfe02d53fc3f3bfad73a55;hp=18cf151259a692cc3f1321217ffc8554aa67bcbc;hpb=48f5216deed3bc4d9a64e81822fe8d6bd5c5cdcd;p=benchmarks-js.git diff --git a/shallow-clone-object.mjs b/shallow-clone-object.mjs index 18cf151..e01a3c4 100644 --- a/shallow-clone-object.mjs +++ b/shallow-clone-object.mjs @@ -1,38 +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 } + }) + bench('Object assign', () => { + const objClone = Object.assign({}, object) + }) + bench('lodash clone', () => { + const objClone = _.clone(object) }) -).catch((err) => { - console.error(err) + bench('rambda assoc', () => { + const objClone = assoc(object) + }) +}) + +await run({ + units: true })