mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 12:05:41 +03:00
3cc1a03519
* chore: add codspeed * chore: fix the benchmark file to clearly distinguish between the comparison targets * chore: fix typo
28 lines
842 B
TypeScript
28 lines
842 B
TypeScript
import { bench, describe } from 'vitest';
|
|
import { uniqWith as uniqWithToolkit } from 'es-toolkit';
|
|
import { uniqWith as uniqWithLodash } from 'lodash';
|
|
import { randomInt } from 'crypto';
|
|
|
|
describe('uniqWith, small arrays', () => {
|
|
bench('es-toolkit/uniqWith', () => {
|
|
uniqWithToolkit([2.1, 1.2, 2.3], (x, y) => Math.floor(x) === Math.floor(y));
|
|
});
|
|
|
|
bench('lodash/uniqWith', () => {
|
|
uniqWithLodash([2.1, 1.2, 2.3], (x, y) => Math.floor(x) === Math.floor(y));
|
|
});
|
|
});
|
|
|
|
describe('uniqWith, large arrays', () => {
|
|
const array = Array.from({ length: 10000 }).map(() => randomInt(0, 10000));
|
|
const comparator = (x, y) => Math.floor(x) === Math.floor(y);
|
|
|
|
bench('es-toolkit/uniqWith', () => {
|
|
uniqWithToolkit(array, comparator);
|
|
});
|
|
|
|
bench('lodash/uniqWith', () => {
|
|
uniqWithLodash(array, comparator);
|
|
});
|
|
});
|