mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-01 10:45:08 +03:00
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);
|
|
});
|
|
});
|