"commitlint",
"deepmerge",
"microtime",
+ "mitata",
"piment",
- "preinstall"
+ "preinstall",
+ "rambda"
]
}
-import Benchmark from 'benny'
+import { bench, group, run } from 'mitata'
import { sleep } from './benchmark-utils.mjs'
})
}
-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
+})
/* 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
+})
/* 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
+})
-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
+})
-import Benchmark from 'benny'
+import { bench, group, run } from 'mitata'
const number = 30
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
+})
-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
+})
-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
+})
-import Benchmark from 'benny'
+import { bench, group, run } from 'mitata'
import { generateRandomNumberArray } from './benchmark-utils.mjs'
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
+})
-import Benchmark from 'benny'
+import { bench, group, run } from 'mitata'
import { generateRandomNumberArray } from './benchmark-utils.mjs'
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
+})
"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": {
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
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:
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
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
-import Benchmark from 'benny'
+import { bench, group, run } from 'mitata'
/**
*
})
}
-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
+})
import { randomInt } from 'node:crypto'
-import Benchmark from 'benny'
+import { bench, group, run } from 'mitata'
/**
* @param numberOfWorkers
)
}
-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
+})
import { randomInt } from 'node:crypto'
-import Benchmark from 'benny'
+import { bench, group, run } from 'mitata'
import {
secureRandom,
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
+})
/* 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
+})
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
+})