From: Jérôme Benoit Date: Fri, 29 Mar 2024 13:34:42 +0000 (+0100) Subject: perf: switch to mitata X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ab9a08f3b8fdd43f8714e90652028621849f9f58;p=benchmarks-js.git perf: switch to mitata Signed-off-by: Jérôme Benoit --- diff --git a/.vscode/settings.json b/.vscode/settings.json index 9a8b7ba..98461ef 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,7 +8,9 @@ "commitlint", "deepmerge", "microtime", + "mitata", "piment", - "preinstall" + "preinstall", + "rambda" ] } diff --git a/busy-wait.mjs b/busy-wait.mjs index e5aaaea..04aa41b 100644 --- a/busy-wait.mjs +++ b/busy-wait.mjs @@ -1,4 +1,4 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' import { sleep } from './benchmark-utils.mjs' @@ -59,23 +59,21 @@ async function setIntervalTimeoutBusyWait (timeoutMs, intervalMs = interval) { }) } -Benchmark.suite( - 'Busy wait', - Benchmark.add('dummyTimeoutBusyWait', () => { +group('Busy wait', () => { + bench('dummyTimeoutBusyWait', () => { dummyTimeoutBusyWait(timeout) - }), - Benchmark.add('sleepTimeoutBusyWait', async () => { + }) + bench('sleepTimeoutBusyWait', async () => { await sleepTimeoutBusyWait(timeout) - }), - Benchmark.add('divideAndConquerTimeoutBusyWait', async () => { + }) + bench('divideAndConquerTimeoutBusyWait', async () => { await divideAndConquerTimeoutBusyWait(timeout) - }), - Benchmark.add('setIntervalTimeoutBusyWait', async () => { + }) + bench('setIntervalTimeoutBusyWait', async () => { await setIntervalTimeoutBusyWait(timeout) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ file: 'busy-wait', format: 'json', details: true }), - Benchmark.save({ file: 'busy-wait', format: 'chart.html', details: true }), - Benchmark.save({ file: 'busy-wait', format: 'table.html', details: true }) -).catch(console.error) + }) +}) + +await run({ + units: true +}) 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 +}) diff --git a/deep-merge-object.mjs b/deep-merge-object.mjs index 1fbf315..5e1ab7b 100644 --- a/deep-merge-object.mjs +++ b/deep-merge-object.mjs @@ -1,42 +1,31 @@ /* eslint-disable no-unused-vars */ -import Benchmark from 'benny' import deepMerge from 'deepmerge' -import merge from 'just-merge' import _ from 'lodash' +import { bench, group, run } from 'mitata' +import { mergeDeepRight } from 'rambda' import { generateRandomObject } from './benchmark-utils.mjs' const object = generateRandomObject() const objectToMerge = generateRandomObject() -Benchmark.suite( +group( `Deep merge two objects: object with ${ Object.keys(object).length } keys, object with ${Object.keys(objectToMerge).length} keys`, - Benchmark.add('lodash merge', (obj = object) => { - const objMerged = _.merge(obj, objectToMerge) - }), - Benchmark.add('just-merge', (obj = object) => { - const objMerged = merge(obj, objectToMerge) - }), - Benchmark.add('deepmerge', (obj = object) => { - const objMerged = deepMerge(obj, objectToMerge) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'deep-merge-object', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'deep-merge-object', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'deep-merge-object', - format: 'table.html', - details: true - }) -).catch(console.error) + () => { + bench('lodash merge', (obj = object) => { + const objMerged = _.merge(obj, objectToMerge) + }) + bench('rambda mergeDeepRight', (obj = object) => { + const objMerged = mergeDeepRight(obj, objectToMerge) + }) + bench('deepmerge', (obj = object) => { + const objMerged = deepMerge(obj, objectToMerge) + }) + } +) + +await run({ + units: true +}) diff --git a/empty-array.mjs b/empty-array.mjs index f9bd214..5a1e081 100644 --- a/empty-array.mjs +++ b/empty-array.mjs @@ -1,34 +1,32 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' import { generateRandomNumberArray } from './benchmark-utils.mjs' const size = 10000 let testArray = generateRandomNumberArray(size) -Benchmark.suite( - `Empty array with ${size} elements`, - Benchmark.add('length = 0', () => { +group(`Empty array with ${size} elements`, () => { + bench('length = 0', () => { testArray.length = 0 - }), - Benchmark.add('pop loop', () => { + }) + bench('pop loop', () => { while (testArray.length > 0) { testArray.pop() } - }), - Benchmark.add('splice', () => { + }) + bench('splice', () => { testArray.splice(0, testArray.length) - }), - Benchmark.add('shift loop', () => { + }) + bench('shift loop', () => { while (testArray.length > 0) { testArray.shift() } - }), - Benchmark.add('new init', () => { + }) + bench('initialize', () => { testArray = [] - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ file: 'empty-array', format: 'json', details: true }), - Benchmark.save({ file: 'empty-array', format: 'chart.html', details: true }), - Benchmark.save({ file: 'empty-array', format: 'table.html', details: true }) -).catch(console.error) + }) +}) + +await run({ + units: true +}) diff --git a/fibonacci.mjs b/fibonacci.mjs index a2fcd24..3a6a96a 100644 --- a/fibonacci.mjs +++ b/fibonacci.mjs @@ -1,4 +1,4 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' const number = 30 @@ -57,23 +57,21 @@ function fibonacciRecursionMemoization (num, memo) { fibonacciRecursionMemoization(num - 2, memo)) } -Benchmark.suite( - `Fibonacci number ${number}`, - Benchmark.add('fibonacciLoop', () => { +group(`Fibonacci number ${number}`, () => { + bench('fibonacciLoop', () => { fibonacciLoop(number) - }), - Benchmark.add('fibonacciLoopWhile', () => { + }) + bench('fibonacciLoopWhile', () => { fibonacciLoopWhile(number) - }), - Benchmark.add('fibonacciRecursion', () => { + }) + bench('fibonacciRecursion', () => { fibonacciRecursion(number) - }), - Benchmark.add('fibonacciRecursionMemoization', () => { + }) + bench('fibonacciRecursionMemoization', () => { fibonacciRecursionMemoization(number) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ file: 'fibonacci', format: 'json', details: true }), - Benchmark.save({ file: 'fibonacci', format: 'chart.html', details: true }), - Benchmark.save({ file: 'fibonacci', format: 'table.html', details: true }) -).catch(console.error) + }) +}) + +await run({ + units: true +}) diff --git a/is-empty-object.mjs b/is-empty-object.mjs index f110816..bc7faf9 100644 --- a/is-empty-object.mjs +++ b/is-empty-object.mjs @@ -1,40 +1,34 @@ -import Benchmark from 'benny' +import _ from 'lodash' +import { bench, group, run } from 'mitata' +import { isEmpty } from 'rambda' import { generateRandomObject } from './benchmark-utils.mjs' const object = generateRandomObject() -Benchmark.suite( - `Is empty object with ${Object.keys(object).length} keys`, - Benchmark.add('Reflect keys', (obj = object) => { +group(`Is empty object with ${Object.keys(object).length} keys`, () => { + bench('Reflect keys', (obj = object) => { return obj?.constructor === Object && Reflect.ownKeys(obj).length === 0 - }), - Benchmark.add('Keys iteration', (obj = object) => { + }) + bench('Keys iteration', (obj = object) => { if (obj?.constructor !== Object) return false // Iterates over the keys of an object, if // any exist, return false. // eslint-disable-next-line no-unreachable-loop for (const _ in obj) return false return true - }), - Benchmark.add('Object keys', (obj = object) => { + }) + bench('Object keys', (obj = object) => { return obj?.constructor === Object && Object.keys(obj).length === 0 - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'is-empty-object', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'is-empty-object', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'is-empty-object', - format: 'table.html', - details: true }) -).catch(console.error) + bench('lodash isEmpty', (obj = object) => { + return _.isEmpty(obj) + }) + bench('rambda is Empty', (obj = object) => { + return isEmpty(obj) + }) +}) + +await run({ + units: true +}) diff --git a/is-undefined.mjs b/is-undefined.mjs index b720507..895d41c 100644 --- a/is-undefined.mjs +++ b/is-undefined.mjs @@ -1,28 +1,14 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' -Benchmark.suite( - 'Is undefined', - Benchmark.add('=== undefined', (value = undefined) => { +group('Is undefined', () => { + bench('=== undefined', (value = undefined) => { return value === undefined - }), - Benchmark.add("typeof === 'undefined'", (value = undefined) => { + }) + bench("typeof === 'undefined'", (value = undefined) => { return typeof value === 'undefined' - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'is-undefined', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'is-undefined', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'is-undefined', - format: 'table.html', - details: true }) -).catch(console.error) +}) + +await run({ + units: true +}) diff --git a/max.mjs b/max.mjs index 2708eb0..778c0ef 100644 --- a/max.mjs +++ b/max.mjs @@ -1,4 +1,4 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' import { generateRandomNumberArray } from './benchmark-utils.mjs' @@ -48,26 +48,24 @@ function sortMax (values) { return values.sort((a, b) => b - a)[0] } -Benchmark.suite( - `Max from ${size} numbers`, - Benchmark.add('Math.max', () => { +group(`Max from ${size} numbers`, () => { + bench('Math.max', () => { Math.max(...testArray) - }), - Benchmark.add('loopMax', () => { + }) + bench('loopMax', () => { loopMax(testArray) - }), - Benchmark.add('reduceTernaryMax', () => { + }) + bench('reduceTernaryMax', () => { reduceTernaryMax(testArray) - }), - Benchmark.add('reduceMath.max', () => { + }) + bench('reduceMathMax', () => { reduceMathMax(testArray) - }), - Benchmark.add('sortMax', () => { + }) + bench('sortMax', () => { sortMax(testArray) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ file: 'max', format: 'json', details: true }), - Benchmark.save({ file: 'max', format: 'chart.html', details: true }), - Benchmark.save({ file: 'max', format: 'table.html', details: true }) -).catch(console.error) + }) +}) + +await run({ + units: true +}) diff --git a/min.mjs b/min.mjs index c7efed1..ebd22cd 100644 --- a/min.mjs +++ b/min.mjs @@ -1,4 +1,4 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' import { generateRandomNumberArray } from './benchmark-utils.mjs' @@ -48,26 +48,24 @@ function sortMin (values) { return values.sort((a, b) => a - b)[0] } -Benchmark.suite( - `Min from ${size} numbers`, - Benchmark.add('Math.min', () => { +group(`Min from ${size} numbers`, () => { + bench('Math.min', () => { Math.min(...testArray) - }), - Benchmark.add('loopMin', () => { + }) + bench('loopMin', () => { loopMin(testArray) - }), - Benchmark.add('reduceTernaryMin', () => { + }) + bench('reduceTernaryMin', () => { reduceTernaryMin(testArray) - }), - Benchmark.add('reduceMath.min', () => { + }) + bench('reduceMathMin', () => { reduceMathMin(testArray) - }), - Benchmark.add('sortMin', () => { + }) + bench('sortMin', () => { sortMin(testArray) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ file: 'min', format: 'json', details: true }), - Benchmark.save({ file: 'min', format: 'chart.html', details: true }), - Benchmark.save({ file: 'min', format: 'table.html', details: true }) -).catch(console.error) + }) +}) + +await run({ + units: true +}) diff --git a/package.json b/package.json index 0d50b12..a4ad1bc 100644 --- a/package.json +++ b/package.json @@ -64,9 +64,10 @@ "deep-clone": "^4.0.0", "deepmerge": "^4.3.1", "just-clone": "^6.2.0", - "just-merge": "^3.2.0", "lodash": "^4.17.21", "microtime": "^3.1.1", + "mitata": "^0.1.11", + "rambda": "^9.1.1", "uuid": "^9.0.1" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 77b6572..ea3255b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,15 +20,18 @@ dependencies: just-clone: specifier: ^6.2.0 version: 6.2.0 - just-merge: - specifier: ^3.2.0 - version: 3.2.0 lodash: specifier: ^4.17.21 version: 4.17.21 microtime: specifier: ^3.1.1 version: 3.1.1 + mitata: + specifier: ^0.1.11 + version: 0.1.11 + rambda: + specifier: ^9.1.1 + version: 9.1.1 uuid: specifier: ^9.0.1 version: 9.0.1 @@ -2213,10 +2216,6 @@ packages: resolution: {integrity: sha512-1IynUYEc/HAwxhi3WDpIpxJbZpMCvvrrmZVqvj9EhpvbH8lls7HhdhiByjL7DkAaWlLIzpC0Xc/VPvy/UxLNjA==} dev: false - /just-merge@3.2.0: - resolution: {integrity: sha512-cNh5FWt44hx4SpQS1xZU8Tzr/fQA69pqCdjbwxmaYYIOuRfA8EIg+dn1bGmIW03ZUtR2vkMOCjWKc+jIbpauSw==} - dev: false - /keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} dependencies: @@ -2433,6 +2432,10 @@ packages: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} dev: true + /mitata@0.1.11: + resolution: {integrity: sha512-cs6FiWcnRxn7atVumm8wA8R70XCDmMXgVgb/qWUSjr5dwuIBr7zC+22mbGYPlbyFixlIOjuP//A0e72Q1ZoGDw==} + dev: false + /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: true @@ -2733,6 +2736,10 @@ packages: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true + /rambda@9.1.1: + resolution: {integrity: sha512-8A8umDmXQf4EG4cpoM358HWF49I5K7/6I8M8ciN5jdo0tOiwEL0DJqq9JRzWOHNYGiTD13OQFJbvayeafEp8xw==} + dev: false + /react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} dev: true diff --git a/promise-handling.mjs b/promise-handling.mjs index 1624bc2..4c20dc2 100644 --- a/promise-handling.mjs +++ b/promise-handling.mjs @@ -1,4 +1,4 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' /** * @@ -9,44 +9,30 @@ async function asyncFunction () { }) } -Benchmark.suite( - 'Promise handling', - Benchmark.add('await promise', async () => { +group('Promise handling', () => { + bench('await promise', async () => { try { return await asyncFunction() } catch (e) { console.error(e) } - }), - Benchmark.add('promise with then().catch()', () => { + }) + bench('promise with then().catch()', () => { asyncFunction() .then(r => { return r }) .catch(console.error) - }), - Benchmark.add('voided promise', () => { + }) + bench('voided promise', () => { // eslint-disable-next-line no-void void asyncFunction() - }), - Benchmark.add('mishandled promise', () => { + }) + bench('mishandled promise', () => { asyncFunction() - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'promise-handling', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'promise-handling', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'promise-handling', - format: 'table.html', - details: true }) -).catch(console.error) +}) + +await run({ + units: true +}) diff --git a/quick-select.mjs b/quick-select.mjs index a829a9e..f416d2d 100644 --- a/quick-select.mjs +++ b/quick-select.mjs @@ -1,6 +1,6 @@ import { randomInt } from 'node:crypto' -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' /** * @param numberOfWorkers @@ -228,41 +228,27 @@ function quickSelectRecursionRandomPivot (tasksMap) { ) } -Benchmark.suite( - 'Quick select', - Benchmark.add('Loop select', () => { +group('Quick select', () => { + bench('Loop select', () => { loopSelect(tasksMap) - }), - Benchmark.add('Array sort select', () => { + }) + bench('Array sort select', () => { arraySortSelect(tasksMap) - }), - Benchmark.add('Quick select loop', () => { + }) + bench('Quick select loop', () => { quickSelectLoop(tasksMap) - }), - Benchmark.add('Quick select loop with random pivot', () => { + }) + bench('Quick select loop with random pivot', () => { quickSelectLoopRandomPivot(tasksMap) - }), - Benchmark.add('Quick select recursion', () => { + }) + bench('Quick select recursion', () => { quickSelectRecursion(tasksMap) - }), - Benchmark.add('Quick select recursion with random pivot', () => { + }) + bench('Quick select recursion with random pivot', () => { quickSelectRecursionRandomPivot(tasksMap) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'quick-select', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'quick-select', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'quick-select', - format: 'table.html', - details: true }) -).catch(console.error) +}) + +await run({ + units: true +}) diff --git a/random.mjs b/random.mjs index 98ff2a2..fa63373 100644 --- a/random.mjs +++ b/random.mjs @@ -1,6 +1,6 @@ import { randomInt } from 'node:crypto' -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' import { secureRandom, @@ -63,38 +63,21 @@ function getRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) { return Math.floor(Math.random() * (max + 1)) } -Benchmark.suite( - 'Random Integer Generator', - Benchmark.add('Secure random integer generator', () => { +group('Random Integer Generator', () => { + bench('Secure random integer generator', () => { getSecureRandomInteger(maximum) - }), - Benchmark.add( - 'Secure random with getRandomValues() integer generator', - () => { - getSecureRandomIntegerWithRandomValues(maximum) - } - ), - Benchmark.add('Crypto random integer generator', () => { + }) + bench('Secure random with getRandomValues() integer generator', () => { + getSecureRandomIntegerWithRandomValues(maximum) + }) + bench('Crypto random integer generator', () => { randomInt(maximum) - }), - Benchmark.add('Math random integer generator', () => { + }) + bench('Math random integer generator', () => { getRandomInteger(maximum) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'random-integer-generator', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'random-integer-generator', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'random-integer-generator', - format: 'table.html', - details: true }) -).catch(console.error) +}) + +await run({ + units: true +}) 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 +}) diff --git a/uuid-generator.mjs b/uuid-generator.mjs index 0b4c9fb..050a0db 100644 --- a/uuid-generator.mjs +++ b/uuid-generator.mjs @@ -1,31 +1,17 @@ import { randomUUID } from 'node:crypto' -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' import { v4 as uuid } from 'uuid' -Benchmark.suite( - 'UUIDv4 generator', - Benchmark.add('crypto randomUUID', () => { +group('UUIDv4 generator', () => { + bench('randomUUID', () => { randomUUID() - }), - Benchmark.add('uuid', () => { + }) + bench('uuid', () => { uuid() - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'uuid-generator', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'uuid-generator', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'uuid-generator', - format: 'table.html', - details: true }) -).catch(console.error) +}) + +await run({ + units: true +})