X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=shallow-clone-object.mjs;h=f5c79c3bf6542e08d246b3df2012a928eef17a58;hb=HEAD;hp=51ee172b499c830b66772a19942d3005fb684c2f;hpb=4aa2893a787119ef9b3957e82539fee4fad4f98f;p=benchmarks-js.git diff --git a/shallow-clone-object.mjs b/shallow-clone-object.mjs index 51ee172..70b14d9 100644 --- a/shallow-clone-object.mjs +++ b/shallow-clone-object.mjs @@ -1,36 +1,26 @@ -/* 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', () => { + return { ...object } + }) + bench('Object assign', () => { + return Object.assign({}, object) + }) + bench('lodash clone', () => { + _.clone(object) }) -).catch(console.error) + bench('rambda assoc', () => { + assoc(object) + }) +}) + +await run({ + units: true, +})